CentOS7完美安装MySQL8教程
Posted 捷码开源
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS7完美安装MySQL8教程相关的知识,希望对你有一定的参考价值。
rpm -qa | grep mysql
#如果已安装先卸载
yum remove mysql-xxx-xxx
#查找卸载残余文件
find / -name mysql
#强制删除残余文件
rm -rf /var/lib/mysql
#查看是否安装mariadb(有冲突)
rpm -pa | grep mariadb
#如果已安装先卸载
yum -y remove mariadb-libs.x86_64
wget http://dev.mysql.com/get/Downloads/mysql80-community-release-el7-3.noarch.rpm
#安装rpm
rpm -ivh mysql80-community-release-el7-3.noarch.rpm
#安装mysql
yum install mysql-community-server
#安装完毕后默认配置文件路径:
配置文件:/etc/my.cnf
日志文件:/var/log/var/log/mysqld.log
服务启动脚本:
/usr/lib/systemd/system/mysqld.service
Socket文件:/var/run/mysqld/mysqld.pid
#这是centos7的命令
systemctl start mysqld.service
systemctl enable mysqld.service
#修改mysql配置文件
vim /etc/my.cnf
#修改密码,开启跳过默认密码
#配置文件本来就有注释打开即可
default-authentication-plugin=mysql_native_password
symbolic-links=0
skip-grant-tables
#每次修改完配置文件请重复运行此重启命令
systemctl restart mysqld
温馨提示:
#停止服务命令是:
systemctl stop mysqld
#1登录mysql
mysql -uroot -p
#2先将密码更新成空
update user set authentication_string='' where user='root';
#3然后把配置文件之前设置的跳过密码注释掉(重启mysql)
#4重新连接mysql后会提示先重置密码才能继续操作
#5重置密码(注:这里设置密码太弱会提示不满足安全规则)
alter user 'root'@'localhost' identified by '12345678@Qwe';
#6设置密码加密方式永不过期
ALTER USER 'root'@'localhost' IDENTIFIED BY '12345678@Qwe' PASSWORD EXPIRE NEVER;
# 7修改加密方式为mysql_native_password
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '12345678@Qwe';
#创建aaa用户
CREATE USER 'aaa'@'%' IDENTIFIED BY '12345678@Qaa';
#用户授权
GRANT EXECUTE,INSERT,SELECT,UPDATE ON * TO 'aaa'@'%';
GRANT ALL PRIVILEGES ON *.* TO 'aaa'@'%' WITH GRANT OPTION
#查看用户
select host, user, authentication_string, plugin from user;
#查看创建&授权
SHOW CREATE USER aaa;
SHOW GRANTS FOR aaa;
#修改mysql配置后请刷新
flush privileges;
End
以上是关于CentOS7完美安装MySQL8教程的主要内容,如果未能解决你的问题,请参考以下文章
Linux(CentOS7)安装与卸载MySQL8.0图文详解