Centos7安装Mysql单机版采坑笔记
一、下载rpm文件
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
二、安装mysql源
通过cd到文件夹路径下,输入下面命令
yum localinstall xxx.rpm(xxx.rpm为下载的文件名)
三、检查mysql源是否安装成功
yum repolist enabled | grep "mysql.*-community.*"
三、安装MySQL
yum install mysql-community-server
三、启动MySQL服务和设置开机启动
systemctl start mysqld
systemctl enable mysqld
systemctl daemon-reload
四、开放防火墙端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
五、关闭密码强度验证(可省略)
编辑 my.cnf 配置文件
vi /etc/my.cnf
在[mysqld]节点下添加下在配置
validate_password.check_user_name=OFF
validate_password.length=4
validate_password.mixed_case_count=0
validate_password.number_count=0
validate_password.policy=0
validate_password.special_char_count=0
重启mySql
systemctl stop mysqld
systemctl start mysqld
六、修改root密码
1、查看默认
grep 'temporary password' /var/log/mysqld.log
2、连接mySql
mysql -uroot -pxxx (xxx:为mySql的密码)
3、修改root密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
七、开启远程访问
1、mysql -uroot -p 123456
3、use mysql;
4、select host,user from user;
5、update user set host='%' where user = 'root';
6、flush privileges;
参考:https://www.cnblogs.com/caoxb/p/9405323.html