mysql远程连接有SSL模式与非SSL模式。
查看mysql是否启用ssl远程安全连接模式,一般在生成环境中需要启用SSL远程连接模式。
mysql> STATUS;
mysql Ver 14.14 Distrib 5.7.18, for Linux (x86_64) using EditLine wrapper
Connection id: 5
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.18 MySQL Community Server (GPL)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: latin1
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /var/lib/mysql/mysql.sock
Uptime: 1 min 2 sec
1. 未启用SSL模式,配置远程连接授权
登录系统
# mysql -u root -p
创建一个新用户:
mysql> CREATE USER 'gmolica'@'%' IDENTIFIED BY 'Unixmen1!';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'gmolica'@'%' IDENTIFIED BY 'Unixmen1!';
mysql> FLUSH PRIVILEGES;
mysql> EXIT;
2. 启用SSL模式,配置远程连接授权
登录系统
# mysql -u root -p
创建一个新用户:
mysql> CREATE USER 'gmolica'@'%' IDENTIFIED BY 'Unixmen1!' REQUIRE X509;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'gmolica'@'%' IDENTIFIED BY 'Unixmen1!' REQUIRE X509;
mysql> FLUSH PRIVILEGES;
mysql> EXIT;