MySQL版本:5.7
1、进入home目录:cd /home
2、下载MySQL源安装包:wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
3、安装MySQL源:yum localinstall mysql57-community-release-el7-8.noarch.rpm
4、检测MySQL源是否安装成功:yum repolist enabled| grep "mysql.*-community.*"
5、安装MySQL:yum install mysql-community-server
6、启动MySQL:systemctl start mysqld 或 service mysqld start
7、检查MySQL启动状态:systemctl status mysqld
8、开机启动:
systemctl enable mysqld
systemctl daemon-reload
9、修改root默认密码:grep 'temporary password' /var/log/mysqld.log
这时他会给你返回一个默认密码:A temporary password is generated for root@localhost: OkS&Kkn+w6qm
登录MySQL:mysql -u root -p
修改密码:ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
或者:set password for 'root'@'localhost' =password('你的密码');
通过msyql环境变量可以查看密码策略的相关信息:show variables like '%password%';
/***********************************************************************************/
拓展:下面的操作主要用于navcat外网远程连接上mysql
使用MySQL:use mysql;
flush privileges;
把localhost这条记录的host改为 %; 意思是root可以由任何主机登录mysql,网上很多写法,都没有and host='localhost'这个条件,经常报错:update user set host = '%' where user = 'root' and host= 'localhost';
/***********************************************************************************/
退出MySQL:quit;
10、重启:systemctl restart mysqld 或 service mysqld restart