RSA private key file not found, RSA public key file not found

之前一个朋友的小水管服务器,MariaDB版本比较高,切换到MySQL 5.7,开销还是吓人,换到MySQL 5.6好了,但是有个启动日志出现:

2021-12-22 09:38:30 10826 [Note] RSA private key file not found: /var/lib/mysql//private_key.pem. Some authentication plugins will not work.
2021-12-22 09:38:30 10826 [Note] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.
2021-12-22 09:38:30 10826 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
2021-12-22 09:38:30 10826 [Note]   - '127.0.0.1' resolves to '127.0.0.1';
2021-12-22 09:38:30 10826 [Note] Server socket created on IP: '127.0.0.1'.
2021-12-22 09:38:30 10826 [Note] Event Scheduler: Loaded 0 events
2021-12-22 09:38:30 10826 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.6.51'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server (GPL)

解决方法如下:

1.检查是否安装openssl

$rpm -qa openssl
openssl-1.0.0-20.el6_2.5.x86_64

2.利用openssl生成公有和私有key

$openssl genrsa -out mykey.pem 1024
 
Generating RSA private key, 1024 bit long modulus
..........++++++
.++++++
e is 65537 (0x10001)
$openssl rsa -in mykey.pem -pubout -out mykey.pub
 
writing RSA key

3.修改key的权限

$chmod 400 mykey.pem
$chmod 444 mykey.pub
chown mysql:mysql mykey.pem
chown mysql:mysql mykey.pub

4.把公私有key的路径加入到my.cnf中

sha256_password_private_key_path=mykey.pem
sha256_password_public_key_path=mykey.pub

如果key放在datadir目录下,直接写key名即可。否则要指定key的全路径

5.重启mysql

SHOW STATUS查看Rsa_public_key状态,如果不为空,则OK.

mysql> SHOW STATUS LIKE 'Rsa_public_key'\G
*************************** 1. row ***************************
Variable_name: Rsa_public_key
        Value: -----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDEALeNX9dY4EMlaDHCIYPBvFNN
NJG2f6dtsyV/IG94TFsKtx/Xobiiz9ihBZSWvUhlfz6aVy9TbN68YEn58G5oOS3o
sxKZQvDF9XvjN0thDPwCgfIwTZgatqmrV/qGewCxQpQ03WHPx+GXQmM9iFSfM84F
pZ8QtiI3m+fIUaOd/QIDAQAB
-----END PUBLIC KEY-----
 
1 row in set (0.00 sec)

发表回复

您的电子邮箱地址不会被公开。