前端之家收集整理的这篇文章主要介绍了
centos安装mysql,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
一、安装
#获取安装用的Yum Repository
wget -i -c http://dev.MysqL.com/get/MysqL57-community-release-el7-10.noarch.rpm
yum -y install MysqL57-community-release-el7-10.noarch.rpm
#安装MysqL服务
yum -y install MysqL-community-server
#查看版本
MysqL -v
#启动MysqL
systemctl start MysqLd.service
#找回初始密码并登录
grep 'temporary password' /var/log/MysqLd.log
MysqL -uroot -p
#注意;找不到初始密码及其他情况参考下文"修改密码"
#使用初始密码登录后需要先修改一次密码后才能操作
ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';
#为避免Repository每次yum操作都会自动更新
yum -y remove MysqL57-community-release-el7-10.noarch
#1.找回密码
grep 'temporary password' /var/log/MysqLd.log
#2.强制修改密码
systemctl stop MysqLd #停止服务
systemctl set-environment MysqLD_OPTS="--skip-grant-tables" #跳过密码
systemctl start MysqLd #启动服务
MysqL -u root #登录
UPDATE MysqL.user SET authentication_string = PASSWORD('新密码') WHERE User = 'root' AND Host = 'localhost'; #设置新密码
FLUSH PRIVILEGES; #刷新权限
quit #退出
#3.用操作系统账号修改密码
MysqL -uroot -p #使用centos账号密码登录
UPDATE MysqL.user SET authentication_string = PASSWORD('新密码') WHERE User = 'root' AND Host = 'localhost'; #设置新密码
FLUSH PRIVILEGES; #刷新权限
quit #退出
三、修改远程连接权限(为了使用navicat)
#选择MysqL
use MysqL;
#授权远程连接
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'YYBrhr_2018' WITH GRANT OPTION;
#注意:如果navicat远程连接报1521错误
GRANT ALL ON *.* TO 'root'@'%'; #远程连接授权
ALTER USER 'root'@'%' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; #更改加密规则
ALTER USER 'root'@'%' IDENTIFIED WITH MysqL_native_password BY '123456'; #更改密码
FLUSH PRIVILEGES; #刷新权限
原文链接:/centos/990635.html