1. 先安装 Wget
2. 下载并安装MySQL官方的 Yum Repository
1
| wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
|
3. 安装 Yum Repository
1
| yum install -y mysql57-community-release-el7-10.noarch.rpm
|
4. 安装 Mysql
1
| yum install -y mysql-community-server
|
5. 启动 Mysql
6. 设置开机自启动
7. 查看默认密码
1
| grep "password" /var/log/mysqld.log
|
8. 登录
9. 修改默认密码
1
| ALTER USER 'root'@'localhost' IDENTIFIED BY 'your password';
|
10. 开启远程访问 IP【可选】
1 2 3 4 5
| grant all privileges on *.* to 'root'@'xxx.xxx.xxx.xxx' identified by 'your password' with grant option;
grant all privileges on *.* to 'root'@'%' identified by 'your password' with grant option;
|
11. 刷新权限并退出
12. 更改 Mysql 默认字符集
在文件最底部添加
字符集不一定是utf8也可是utf8mb4
1 2
| [client] default-character-set=utf8
|
在 “[mysqld]” 字样下添加
字符集不一定是utf8也可是utf8mb4
1 2
| character-set-server=utf8 collation-server=utf8_general_ci
|
13. 重启 Mysql 服务
1
| systemctl restart mysqld
|