当我尝试使用mysql -u root -p
连接到MySQL时,得到以下输出:
? ~ mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)
我检查了mysql.sock
,它在那里,但似乎是一个空文件。
? ~ ll /var/lib/mysql/mysql.sock
srwxrwxrwx 1 mysql mysql 0 May 21 18:19 /var/lib/mysql/mysql.sock
并且当我tail -f /var/log/mysqld.log
时,我注意到MySQL一直都在重新启动。
ps aux | grep mysql
也帮助我确认了这一点。
? mysql ps aux | grep mysql
mysql 31358 15.5 2.1 987400 171176 ? Sl 13:43 0:00 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
root 31386 0.0 0.0 112708 976 pts/0 S+ 13:43 0:00 grep --color mysql
? mysql
? mysql ps aux | grep mysql
mysql 31422 16.5 2.1 971008 172740 ? Sl 13:43 0:00 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
root 31460 0.0 0.0 112708 972 pts/0 S+ 13:43 0:00 grep --color mysql
? mysql
? mysql ps aux | grep mysql
mysql 31593 31.0 2.1 1020184 171800 ? Sl 13:43 0:00 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
root 31620 0.0 0.0 112708 976 pts/0 S+ 13:43 0:00 grep --color mysql
以下是/var/log/mysqld.log
的输出:
2020-06-02T04:31:37.695633Z 0 [Note] Binlog end
2020-06-02T04:31:37.695746Z 0 [Note] Shutting down plugin 'ngram'
2020-06-02T04:31:37.695760Z 0 [Note] Shutting down plugin 'partition'
2020-06-02T04:31:37.695767Z 0 [Note] Shutting down plugin 'BLACKHOLE'
2020-06-02T04:31:37.695774Z 0 [Note] Shutting down plugin 'ARCHIVE'
2020-06-02T04:31:37.695781Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2020-06-02T04:31:37.695862Z 0 [Note] Shutting down plugin 'MRG_MYISAM'
2020-06-02T04:31:37.695888Z 0 [Note] Shutting down plugin 'MyISAM'
2020-06-02T04:31:37.695918Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL'
2020-06-02T04:31:37.695925Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2020-06-02T04:31:37.695931Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2020-06-02T04:31:37.695938Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2020-06-02T04:31:37.695944Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2020-06-02T04:31:37.695950Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2020-06-02T04:31:37.695957Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2020-06-02T04:31:37.695963Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2020-06-02T04:31:37.695970Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2020-06-02T04:31:37.695976Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2020-06-02T04:31:37.695982Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2020-06-02T04:31:37.695988Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2020-06-02T04:31:37.695994Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2020-06-02T04:31:37.696001Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2020-06-02T04:31:37.696007Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2020-06-02T04:31:37.696013Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2020-06-02T04:31:37.696019Z 0 [Note] Shutting down plugin 'INNODB_METRICS'
2020-06-02T04:31:37.696025Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO'
2020-06-02T04:31:37.696032Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2020-06-02T04:31:37.696038Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2020-06-02T04:31:37.696044Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2020-06-02T04:31:37.696050Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2020-06-02T04:31:37.696056Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2020-06-02T04:31:37.696062Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2020-06-02T04:31:37.696069Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM'
2020-06-02T04:31:37.696075Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2020-06-02T04:31:37.696088Z 0 [Note] Shutting down plugin 'INNODB_CMP'
2020-06-02T04:31:37.696095Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2020-06-02T04:31:37.696101Z 0 [Note] Shutting down plugin 'INNODB_LOCKS'
2020-06-02T04:31:37.696107Z 0 [Note] Shutting down plugin 'INNODB_TRX'
2020-06-02T04:31:37.696114Z 0 [Note] Shutting down plugin 'InnoDB'
2020-06-02T04:31:37.696274Z 0 [Note] InnoDB: FTS optimize thread exiting.
2020-06-02T04:31:37.696443Z 0 [Note] InnoDB: Starting shutdown...
2020-06-02T04:31:37.796721Z 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
2020-06-02T04:31:37.797439Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 200602 12:31:37
2020-06-02T04:31:39.307303Z 0 [Note] InnoDB: Shutdown completed; log sequence number 1426867487
2020-06-02T04:31:39.310233Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2020-06-02T04:31:39.310264Z 0 [Note] Shutting down plugin 'MEMORY'
2020-06-02T04:31:39.310280Z 0 [Note] Shutting down plugin 'CSV'
2020-06-02T04:31:39.310289Z 0 [Note] Shutting down plugin 'sha256_password'
2020-06-02T04:31:39.310296Z 0 [Note] Shutting down plugin 'mysql_native_password'
2020-06-02T04:31:39.310488Z 0 [Note] Shutting down plugin 'binlog'
2020-06-02T04:31:39.310742Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
2020-06-02T04:31:40.010722Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-06-02T04:31:40.012577Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.30) starting as process 21337 ...
2020-06-02T04:31:40.017971Z 0 [Note] InnoDB: PUNCH HOLE support available
2020-06-02T04:31:40.018028Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-06-02T04:31:40.018038Z 0 [Note] InnoDB: Uses event mutexes
2020-06-02T04:31:40.018046Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2020-06-02T04:31:40.018055Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-06-02T04:31:40.018063Z 0 [Note] InnoDB: Using Linux native AIO
2020-06-02T04:31:40.018583Z 0 [Note] InnoDB: Number of pools: 1
2020-06-02T04:31:40.018811Z 0 [Note] InnoDB: Using CPU crc32 instructions
2020-06-02T04:31:40.021640Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2020-06-02T04:31:40.036065Z 0 [Note] InnoDB: Completed initialization of buffer pool
2020-06-02T04:31:40.039597Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2020-06-02T04:31:40.052480Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2020-06-02T04:31:40.103517Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2020-06-02T04:31:40.103646Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2020-06-02T04:31:40.130628Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2020-06-02T04:31:40.131912Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2020-06-02T04:31:40.131937Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2020-06-02T04:31:40.133041Z 0 [Note] InnoDB: Waiting for purge to start
2020-06-02T04:31:40.183270Z 0 [Note] InnoDB: 5.7.30 started; log sequence number 1426867487
2020-06-02T04:31:40.184000Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2020-06-02T04:31:40.184345Z 0 [Note] Plugin 'FEDERATED' is disabled.
2020-06-02T04:31:40.184526Z 0 [Note] InnoDB: Buffer pool(s) load completed at 200602 12:31:40
2020-06-02T04:31:40.190222Z 0 [ERROR] unknown variable 'validate_password_policy=LOW'
2020-06-02T04:31:40.190249Z 0 [ERROR] Aborting
通过运行service mysqld stop
命令停止它的云,但是当我尝试重新启动它时,它将再次显示错误:
? mysql service mysqld start
Redirecting to /bin/systemctl start mysqld.service
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
? mysql
? mysql journalctl -xe
Jun 02 14:09:13 node72 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.
Jun 02 14:09:13 node72 systemd[1]: Unit mysqld.service entered failed state.
Jun 02 14:09:13 node72 systemd[1]: mysqld.service failed.
Jun 02 14:09:13 node72 polkitd[1143]: Unregistered Authentication Agent for unix-process:1669:824444 (system bus name :1.431, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (dis
Jun 02 14:09:13 node72 systemd[1]: mysqld.service holdoff time over, scheduling restart.
Jun 02 14:09:13 node72 systemd[1]: Stopped MySQL Server.
-- Subject: Unit mysqld.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysqld.service has finished shutting down.
Jun 02 14:09:13 node72 systemd[1]: Starting MySQL Server...
-- Subject: Unit mysqld.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysqld.service has begun starting up.
Jun 02 14:09:13 node72 mysqld[1777]: Initialization of mysqld failed: 0
Jun 02 14:09:13 node72 systemd[1]: mysqld.service: control process exited, code=exited status=1
Jun 02 14:09:15 node72 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.
Jun 02 14:09:15 node72 systemd[1]: Unit mysqld.service entered failed state.
Jun 02 14:09:15 node72 systemd[1]: mysqld.service failed.
Jun 02 14:09:15 node72 systemd[1]: mysqld.service holdoff time over, scheduling restart.
Jun 02 14:09:15 node72 systemd[1]: Stopped MySQL Server.
-- Subject: Unit mysqld.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysqld.service has finished shutting down.
Jun 02 14:09:15 node72 systemd[1]: Starting MySQL Server...
-- Subject: Unit mysqld.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysqld.service has begun starting up.
Jun 02 14:09:16 node72 mysqld[1835]: Initialization of mysqld failed: 0
Jun 02 14:09:16 node72 systemd[1]: mysqld.service: control process exited, code=exited status=1
这是我第二次遇到此问题,我不知道这是怎么回事。第一次,我做了重新安装以解决这个问题,现在我又遇到了这个问题。我只是一般地使用MySQL,自上次重新安装以来,它运行良好。
以下一些信息可能会有所帮助:
MySQL版本
mysql Ver 14.14 Distrib 5.7.30, for Linux (x86_64) using EditLine wrapper
Linux发行版
Cent OS Linux release 7.6.1810 (Core)
/etc/my.cnf中的MySQL配置
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
explicit_defaults_for_timestamp=true
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
validate_password_policy=LOW
character_set_server=utf8
init_connect='SET NAMES utf8'
sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
[client]
default-character-set=utf8
socket=/var/lib/mysql/mysql.sock
[mysql]
default-character-set=utf8
socket=/var/lib/mysql/mysql.sock
感谢您的宝贵时间,我们将不胜感激。
我检查了问题mysql-validate-password-policy-unknown-system-variable,但这对我没有帮助。 我从https://dev.mysql.com/doc/refman/5.7/en/validate-password-installation.html阅读了MySQL文档。
有一个注释说:
If you installed MySQL 5.7 using the MySQL Yum repository, MySQL SLES Repository, or RPM packages provided by Oracle, validate_password is enabled by default after you start your MySQL Server for the first time.
在我的情况下,我已经使用MySQL Yum存储库安装了Mysql 5.7,并且最后重新安装了此问题,插件运行正常。因此,在安装阶段之前,我将validate_password_policy=LOW
行插入/etc/.cnf
来解决MySQL默认密码策略。