背景:在虚拟机CentOS7上安装mysql8,第一次使用压缩安装包形式安装,中途出现了很多错误,于是就抛弃了这种安装方式,改用yum源方式安装,结果在启动时没有看到期待的结果,出现了错误。根据提示查看,有这样的提示:mysqld.service; enabled; vendor preset: disabled
[root@CentOS7domain ~]# systemctl -l status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2021-11-17 10:16:14 CST; 16min ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 1604 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS (code=exited, status=1/FAILURE)
Process: 997 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 1604 (code=exited, status=1/FAILURE)
Status: "Server startup in progress"
Error: 2 (No such file or directory)
Nov 17 10:16:14 CentOS7domain mysqld[1604]: 2021-11-17T02:16:00.968591Z 0 [Warning] [MY-010141] [Server] Changed limits: max_connections: 9190 (requested 10000)
Nov 17 10:16:14 CentOS7domain mysqld[1604]: 2021-11-17T02:16:00.968599Z 0 [Warning] [MY-010142] [Server] Changed limits: table_open_cache: 400 (requested 4000)
Nov 17 10:16:14 CentOS7domain mysqld[1604]: 2021-11-17T02:16:14.481824Z 0 [Warning] [MY-010091] [Server] Can't create test file /usr/local/mysql/data/mysqld_tmp_file_case_insensitive_test.lower-test
Nov 17 10:16:14 CentOS7domain mysqld[1604]: 2021-11-17T02:16:14.481982Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
Nov 17 10:16:14 CentOS7domain mysqld[1604]: 2021-11-17T02:16:14.482015Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.27) starting as process 1604
Nov 17 10:16:14 CentOS7domain mysqld[1604]: 2021-11-17T02:16:14.482117Z 0 [ERROR] [MY-010338] [Server] Can't find error-message file '/usr/local/mysql/share/mysql-8.0/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
Nov 17 10:16:14 CentOS7domain systemd[1]: mysqld.service: main process exited, code=exited, status=1/FAILURE
Nov 17 10:16:14 CentOS7domain systemd[1]: Failed to start MySQL Server.
Nov 17 10:16:14 CentOS7domain systemd[1]: Unit mysqld.service entered failed state.
Nov 17 10:16:14 CentOS7domain systemd[1]: mysqld.service failed.
[root@CentOS7domain ~]# journalctl -xe
Nov 17 10:47:31 CentOS7domain mysqld_pre_systemd[3248]: 2021-11-17T02:47:31.618156Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complet
Nov 17 10:47:32 CentOS7domain mysqld[3283]: 2021-11-17T02:47:31.668020Z 0 [Warning] [MY-010139] [Server] Changed limits: max_open_files: 10000 (reques
Nov 17 10:47:32 CentOS7domain mysqld[3283]: 2021-11-17T02:47:31.668037Z 0 [Warning] [MY-010141] [Server] Changed limits: max_connections: 9190 (reques
Nov 17 10:47:32 CentOS7domain mysqld[3283]: 2021-11-17T02:47:31.668046Z 0 [Warning] [MY-010142] [Server] Changed limits: table_open_cache: 400 (reques
Nov 17 10:47:32 CentOS7domain mysqld[3283]: 2021-11-17T02:47:32.727935Z 0 [Warning] [MY-010091] [Server] Can't create test file /usr/local/mysql/data/
Nov 17 10:47:32 CentOS7domain mysqld[3283]: 2021-11-17T02:47:32.728180Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated
Nov 17 10:47:32 CentOS7domain mysqld[3283]: 2021-11-17T02:47:32.728203Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.27) starting as p
Nov 17 10:47:32 CentOS7domain mysqld[3283]: 2021-11-17T02:47:32.728282Z 0 [ERROR] [MY-010338] [Server] Can't find error-message file '/usr/local/mysql
Nov 17 10:47:32 CentOS7domain mysqld[3283]: 2021-11-17T02:47:32.728931Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently a
Nov 17 10:47:32 CentOS7domain mysqld[3283]: 2021-11-17T02:47:32.729725Z 0 [Warning] [MY-010091] [Server] Can't create test file /usr/local/mysql/data/
Nov 17 10:47:32 CentOS7domain mysqld[3283]: 2021-11-17T02:47:32.729733Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file
Nov 17 10:47:32 CentOS7domain mysqld[3283]: 2021-11-17T02:47:32.730453Z 0 [ERROR] [MY-013276] [Server] Failed to set datadir to '/usr/local/mysql/data
Nov 17 10:47:32 CentOS7domain mysqld[3283]: 2021-11-17T02:47:32.730600Z 0 [ERROR] [MY-010119] [Server] Aborting
Nov 17 10:47:32 CentOS7domain mysqld[3283]: 2021-11-17T02:47:32.730868Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.
Nov 17 10:47:32 CentOS7domain systemd[1]: mysqld.service: main process exited, code=exited, status=1/FAILURE
Nov 17 10:47:32 CentOS7domain systemd[1]: Failed to start MySQL Server.
-- Subject: Unit mysqld.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysqld.service has failed.
--
-- The result is failed.
Nov 17 10:47:32 CentOS7domain systemd[1]: Unit mysqld.service entered failed state.
Nov 17 10:47:32 CentOS7domain systemd[1]: mysqld.service failed.
Nov 17 10:47:32 CentOS7domain polkitd[707]: Unregistered Authentication Agent for unix-process:3242:193972 (system bus name :1.133, object path /org/f
lines 3126-3151/3151 (END)
之后直接放在网上搜索解决办法,有提到查看日志,但当我用cat或者tail命令查看/var/log/mysqld.log,日志是空的,或者说并没有产生日志,于是我认真看错误提示,下面两处文字引起了我的注意,第一次用压缩包安装的时候,我的安装目录就是/usr/local/mysql,下面还提到了/usr/local/mysql/data,于是我猜测可能是配置文件/etc/my.cnf没有删除导致的错误。
?用cat 命令查看,/etc/my.cnf文件仍然存在,于是将该文件删除,重新启动mysql服务,等来了正确的启动。
另外,卸载后/etc/my.cnf.d目录文件夹也需要手工删除,这个在上面正常启动后我找不到临时密码进行卸载重装的时候看到的需要删除的文件及目录,不知道文件夹的具体影响,最好也删除了。
rm -rf /etc/my.cnf.d
|