快速部署使用yum在Linux下进行安装
YUM)
1. 下载MySQL源安装包
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
2. 安装
yum localinstall mysql57-community-release-el7-8.noarch.rpm
3.检查mysql源是否安装成功
yum repolist enabled | grep "mysql.*-community.*"
4.修改yum源
vim /etc/yum.repos.d/mysql-community.repo 改变默认安装的mysql版本。比如要安装5.6版本,将5.7源的enabled=1改成enabled=0。然后再将5.6源的enabled=0改成enabled=1即可。 备注:enabled=1表示即将要安装的mysql版本,这个文件也可以不修改,默认安装mysql最高版本
5. 安装MySQL
yum install mysql-community-server
6.启动MySQL并设置开机启动
$ systemctl start mysqld
$ systemctl enable mysqld
$ systemctl daemon-reload
7.端口开放
$ firewall-cmd --zone=public --add-port=3306/tcp --permanent $ firewall-cmd --reload
8.修改root本地登录密码
1)查看默认密码
grep ‘temporary password‘ /var/log/mysqld.log
2)使用临时密码登录MySQL
$ mysql -uroot -p
3)修改密码(首先需要操作)
mysql> ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘MyNewPass4!‘; 或者: mysql> set password for ‘root‘@‘localhost‘=password(‘MyNewPass4!‘);
4)查看密码策略
mysql> show variables like ‘%password%‘;
9.添加远程登录用户
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘caoxiaobo‘@‘%‘ IDENTIFIED BY ‘Caoxiaobo0917!‘ WITH GRANT OPTION;
10.使用客户端连接测试即可