MySQL错误日志提示mysql RSA private key file not found
[Note] RSA private key file not found: /usr/local/mysql/data//private_key.pem. Some authentication plugins will not work.
[Note] RSA public key file not found: /usr/local/mysql/data//public_key.pem. Some authentication plugins will not work.
解决方法如下:
1.检查是否安装openssl
[root@dbserver data]# rpm -qa openssl
openssl-1.0.2k-19.el7.x86_64
[root@dbserver data]#
2.利用openssl生成私有key
[root@dbserver ~]# openssl genrsa -out private_key.pem 1024
Generating RSA private key, 1024 bit long modulus
..........................++++++
....++++++
e is 65537 (0x10001)
[root@dbserver ~]#
利用openssl生成公有key
[root@dbserver ~]# openssl rsa -in private_key.pem -pubout -out public_key.pem
writing RSA key
[root@dbserver ~]#
3.复制key文件到数据库数据目录,修改key的权限
[root@dbserver data]# pwd
/usr/local/mysql/data
[root@dbserver data]# chmod 400 private_key.pem
[root@dbserver data]# chmod 444 public_key.pem
[root@dbserver data]# chown mysql.mysql private_key.pem
[root@dbserver data]# chown mysql.mysql public_key.pem
4.把公私有key的路径加入到my.cnf中
sha256_password_private_key_path=private_key.pem
sha256_password_public_key_path=public_key.pem
如果key放在datadir目录下,直接写key名即可,否则要指定key的全路径。
5.重启mysql
[root@dbserver data]# service mysql restart
重启后使用SHOW STATUS查看Rsa_public_key状态。
如果不为空,则OK,如下所示。
mysql> SHOW STATUS LIKE 'Rsa_public_key'\G
1. row
Variable_name: Rsa_public_key
Value:
1 row in set (0.00 sec)
mysql> SHOW STATUS LIKE 'Rsa_public_key'\G
1. row
Variable_name: Rsa_public_key
Value: -----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC5aroCSfaUP0Xc0d9+tXS8+iiE
QHwlWcK453Ms5zr50JEjIp4/nkfGtYIU7oXkXjG/fWTqX9/RW0ALqhU6rhtvUW8r
e6rxUCcYEaeyrhlU32jAaymyqgA3yMHhtKD7/MHWbDsbQGjjLxUov+zh40xNRcSe
ZS4ORRm8ZxBUaKARiQIDAQAB
-----END PUBLIC KEY-----
1 row in set (0.00 sec)
mysql>
再次查看mysql日志后发现不再提示之前的错误信息