MySQL 启动失败:Can‘t connect to local MySQL server through socket ‘/usr/local/mysql/data/mysql.sock‘

CentOS7 使用源码安装完 MySQL8.0.31 后,出现启动失败问题!!!

 问题说明:

  mysql 安装完成后,一般可使用如下命令启动 mysql;

bin/mysqld_safe --user=mysql &

  正常情况下输入启动命令后,再输入如下命令及初始密码,即可进入mysql;

bin/mysql -uroot -p   #执行该命令后出入初始密码,进入mysql

  但是今天我在执行 mysql 启动命令后,出现如下提示:

2023-07-31T08:17:42.131276Z mysqld_safe mysqld from pid file /usr/local/mysql/data/mysqld.pid ended

说明:上述意思大概是说,mysql 服务已停止;所以后面即使再输入:bin/mysql -uroot -p初始密码也无法进入 mysql ,且会提示如下错误!

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/usr/local/mysql/data/mysql.sock'

 于是乎!!!

我查看了 MySQL 安装目录下的 mysqld.log (我的目录为:/usr/local/mysql/data/)日志,日志内容如下:

2023-07-31T08:06:55.802016Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2023-07-31T08:06:55.802126Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.31) initializing of serv in progress as process 20348
2023-07-31T08:06:55.810198Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-07-31T08:06:56.695475Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-07-31T08:06:58.639754Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: >alonj%-Z4j*
[root@vm10-0-0-236 data]# cat mysqld.log 
2023-07-31T08:06:55.802016Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2023-07-31T08:06:55.802126Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.31) initializing of serv in progress as process 20348
2023-07-31T08:06:55.810198Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-07-31T08:06:56.695475Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-07-31T08:06:58.639754Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: >alonj%-Z4j*
2023-07-31T08:07:23.268585Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2023-07-31T08:07:23.268698Z 0 [System] [MY-010116] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.31) starting as process 584
2023-07-31T08:07:23.276568Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-07-31T08:07:23.343831Z 1 [ERROR] [MY-012562] [InnoDB] We scanned the log up to 19325952. A checkpoint was at 19325996 a the maximum LSN on a database page was 0. It is possible that the database is now corrupt!
2023-07-31T08:07:23.343866Z 1 [Warning] [MY-013412] [InnoDB] The last block of redo had corrupted first_rec_group and becameixed (0 -> 44).
2023-07-31T08:07:23.536217Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-07-31T08:07:24.624559Z 0 [ERROR] [MY-011292] [Server] Plugin mysqlx reported: 'Preparation of I/O interfaces failed, X otocol won't be accessible'
2023-07-31T08:07:24.624590Z 0 [ERROR] [MY-011300] [Server] Plugin mysqlx reported: 'Setup of bind-address: '*' port: 33060 fled, `bind()` failed with error: Address already in use (98). Do you already have another mysqld server running with Mysqlx 
2023-07-31T08:07:24.624597Z 0 [ERROR] [MY-013597] [Server] Plugin mysqlx reported: 'Value '*' set to `Mysqlx_bind_address`, Plugin can't bind to it. Skipping this value.'
2023-07-31T08:07:24.624606Z 0 [ERROR] [MY-011300] [Server] Plugin mysqlx reported: 'Setup of socket: '/tmp/mysqlx.sock' fail, another process with PID 20155 is using UNIX socket file'
2023-07-31T08:07:24.771731Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-07-31T08:07:24.771770Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connectis are now supported for this channel.
2023-07-31T08:07:24.771954Z 0 [ERROR] [MY-010262] [Server] Can't start server: Bind on TCP/IP port: Address already in use
2023-07-31T08:07:24.771961Z 0 [ERROR] [MY-010257] [Server] Do you already have another mysqld server running on port: 3307 ?
2023-07-31T08:07:24.771972Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-07-31T08:07:25.802572Z 0 [System] [MY-010910] [Server] /usr/local/mysql/bin/mysqld: Shutdown complete (mysqld 8.0.31)  urce distribution.
2023-07-31T08:07:47.681777Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2023-07-31T08:07:47.681887Z 0 [System] [MY-010116] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.31) starting as process 816
2023-07-31T08:07:47.688141Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-07-31T08:07:47.847692Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-07-31T08:07:48.938404Z 0 [ERROR] [MY-011292] [Server] Plugin mysqlx reported: 'Preparation of I/O interfaces failed, X otocol won't be accessible'
2023-07-31T08:07:48.938441Z 0 [ERROR] [MY-011300] [Server] Plugin mysqlx reported: 'Setup of bind-address: '*' port: 33060 fled, `bind()` failed with error: Address already in use (98). Do you already have another mysqld server running with Mysqlx 
2023-07-31T08:07:48.938453Z 0 [ERROR] [MY-013597] [Server] Plugin mysqlx reported: 'Value '*' set to `Mysqlx_bind_address`, Plugin can't bind to it. Skipping this value.'
2023-07-31T08:07:48.938471Z 0 [ERROR] [MY-011300] [Server] Plugin mysqlx reported: 'Setup of socket: '/tmp/mysqlx.sock' fail, another process with PID 20155 is using UNIX socket file'
2023-07-31T08:07:49.039721Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-07-31T08:07:49.039752Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connectis are now supported for this channel.
2023-07-31T08:07:49.039916Z 0 [ERROR] [MY-010262] [Server] Can't start server: Bind on TCP/IP port: Address already in use
2023-07-31T08:07:49.039923Z 0 [ERROR] [MY-010257] [Server] Do you already have another mysqld server running on port: 3307 ?
2023-07-31T08:07:49.039935Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-07-31T08:07:50.108334Z 0 [System] [MY-010910] [Server] /usr/local/mysql/bin/mysqld: Shutdown complete (mysqld 8.0.31)  urce distribution.

 其中有一行内容如下:

2023-07-31T08:07:49.039923Z 0 [ERROR] [MY-010257] [Server] Do you already have another mysqld server running on port: 3307 ?

说明:该行大概意思是说,目前的端口已被占用(我在配置用指定端口号为:3307;不指定时,默认为:3306);

 解决方案:

 找到端口号对应的进程 id ,杀死该进程,释放端口号即可!

执行如下命令( 3307 为我的 mysql 端口号),查看端口号对应的进程 id;

lsof -i:3307

执行结果如下所示: 

执行如下命令杀死该进程: 

kill -9 20155

 

 释放被占用的端口号,前面所述问题也将随之解决!!!

问题解决后 MySQL 启动结果:

MySQL 启动失败:Can‘t connect to local MySQL server through socket ‘/usr/local/mysql/data/mysql.sock‘_第1张图片

 

 

你可能感兴趣的:(MySQL,CentOS,mysql,数据库)