一、安装Mysql8
1. 下载MySQL官方的rpm
官方Yum Repository: https://dev.mysql.com/downloads/repo/yum/
选择相应的版本进行下载
wget -i -c http://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

2. 安装Mysql Yum Repository
yum -y install mysql80-community-release-el7-3.noarch.rpm
成功之后,会在/etc/yum.repos.d多两个文件

3. 安装Mysql(500M左右,耗时可能很久)
yum -y install mysql-community-server
4. 启动Mysql
systemctl start mysqld.service
5. 查看Mysql状态
systemctl status mysqld.service

6. 获取初始密码
grep 'temporary password' /var/log/mysqld.log

7. 登录Mysql
mysql -u root -p

8. 修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'YourNewPassword';
二、设置允许远程访问
1. 查看当前 root 用户的相关信息
use mysql
select host, user, authentication_string, plugin from user;
不知道为什么在控制台显示root那一行的记录很奇怪,但是设置能远程访问之后在MySQL Workbench中显示完整


2, 更新host为% ,并刷新
update user set host='%' where user='root';
flush privileges;
三、设置防火墙(腾讯云服务器默认没有防火墙)
1. 查看所有端口
netstat -ntlp
2. 防火墙开启Mysql端口3306
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
3. 查看防火墙开放的端口
firewall-cmd --list-ports
四、用MySQL Workbench测试

显示内部数据库
Edit -> Preferences

中文展示不完整
默认字体大小都是10,将Resultset Grid改为Tahoma 12.5就可以显示全了;此外还可以将SQL Editor字体调大一点(11号),写SQL语句时的字体就比较舒服了

安全模式(非主键条件下无法执行update或者delete命令)
Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. To disable safe mode, toggle the option in Preferences -> SQL Editor and reconnect.
