sudo mysql_secure_installation 不适用于 Kubuntu 19.10 的 Mysql Server 8.0

sudo mysql_secure_installation 不适用于 Kubuntu 19.10 的 Mysql Server 8.0

在为 Kubuntu 19.10 全新安装 mysql-server-8.0 后,我从命令提示符输入了 mysql_secure_installation。并按照说明进行操作。

以下是我的流程的输出:

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Please set the password for root here.

New password: 

Re-enter new password: 

Estimated strength of the password: 0 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n

 ... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done! 

然后

da@n53sm:~$ mysql -u root -p
Enter password: 
ERROR 1698 (28000): Access denied for user 'root'@'localhost'

我不明白到底哪里出了问题?

以下是错误日志的输出:

da@n53sm:~$ tail -f /var/log/mysql/error.log 
2020-01-21T07:27:02.077614Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.18-0ubuntu0.19.10.1)  (Ubuntu).
2020-01-21T07:27:03.414829Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.18-0ubuntu0.19.10.1) starting as process 2774
2020-01-21T07:27:03.966655Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-01-21T07:27:03.973831Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/tmp' in the path is accessible to all OS users. Consider choosing a different directory.
2020-01-21T07:27:04.010871Z 6 [System] [MY-013172] [Server] Received SHUTDOWN from user boot. Shutting down mysqld (Version: 8.0.18-0ubuntu0.19.10.1).
2020-01-21T07:27:04.994403Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.18-0ubuntu0.19.10.1)  (Ubuntu).
2020-01-21T07:27:09.363280Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.18-0ubuntu0.19.10.1) starting as process 2939
2020-01-21T07:27:09.847387Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-01-21T07:27:09.872284Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.18-0ubuntu0.19.10.1'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Ubuntu).
2020-01-21T07:27:10.013629Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060

重新启动mysql后,日志变为:

2020-01-21T07:49:41.567105Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.18-0ubuntu0.19.10.1)  (Ubuntu).
2020-01-21T07:49:41.941350Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.18-0ubuntu0.19.10.1) starting as process 5006
2020-01-21T07:49:42.479793Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-01-21T07:49:42.501480Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.18-0ubuntu0.19.10.1'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Ubuntu).
2020-01-21T07:49:42.591749Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060

答案1

答案就在您的输出日志中。

Insecure configuration for --pid-file: Location '/tmp' in the path is accessible to all OS users. Consider choosing a different directory

将 MySQL 的配置更改为位置等于用户文件夹内的文件夹(即 ~/tmp 或 /root/tmp)。

请注意,此故障后会收到关闭信号。这表明上述函数是导致 MySQL 关闭的原因。

编辑:我看到 MySQL 正在抱怨自签名证书,并且通过 SSL 初始化失败可能是根本原因。

參閱此链接来自 StackOverflow

相关内容