安装依赖
yum install libaio wget -y
查看是否已经安装mysql,若已安装先卸载
yum list installed |grep mysql
下载
wget http://repo.mysql.com/mysql80-community-release-el7-1.noarch.rpm
yum localinstall mysql80-community-release-el7-1.noarch.rpm
查看是否下载成功
yum repolist enabled |grep "mysql.*-community.*"
安装
yum install mysql-community-server -y
提示Complete!后安装成功
查看安装目录
whereis mysql
启动服务
systemctl start mysqld
查看mysql进程
ps -ef | grep mysql
也可以查询mysql状态
systemctl status mysqld
设置开机启动项
systemctl enable mysqld
查看初始密码
/cat/var/log/mysqld.log |grep password
进入mysql
mysql -u root -p
修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY'12345678‘;
这时会报错,是因为mysql密码安全策略问题
解决办法:
先把密码修改为复杂密码,如ALTER USER 'root'@'localhost' IDENTIFIED BY'mysql_123MYSQL';
set global validate_password.policy=0;
set global validate_password.policy=0;
修改成功后,再把密码修改为想要的简单密码ALTER USER 'root'@'localhost' IDENTIFIED BY'12345678';
刷新权限表
flush privileges;
navicat可能还连接失败
use mysql;
update user set host='%'where user='root';
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123';
flush privileges;