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

After CentOS7 uses the source code to install MySQL8.0.31, there is a problem of startup failure! ! !

 Problem statement:

  After the mysql installation is complete, you can generally use the following command to start mysql;

bin/mysqld_safe --user=mysql &

  Under normal circumstances, after entering the startup command, enter the following command and the initial password to enter mysql;

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

  But today, after I execute the mysql startup command, the following prompt appears:

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

Explanation: The above meaning probably means that the mysql service has stopped; so even if you enter: bin/mysql -uroot -p and the initial password later , you cannot enter mysql, and the following error will be prompted!

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

 Ever since! ! !

I checked the mysqld.log in the MySQL installation directory  (my directory is: /usr/local/mysql/data/), the log content is as follows:

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.

 One of the lines reads as follows:

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

Explanation: This line probably means that the current port is already occupied (I specified the port number in the configuration as: 3307; if not specified, the default is: 3306);

 solution:

 Find the process id corresponding to the port number, kill the process, and release the port number!

Execute the following command (3307 is my mysql port number) to check the process id corresponding to the port number;

lsof -i:3307

The execution result is as follows: 

Execute the following command to kill the process: 

kill -9 20155

 

 Release the occupied port number, and the problem mentioned above will be solved accordingly! ! !

After the problem is solved, the MySQL startup result:

 

 

Guess you like

Origin blog.csdn.net/weixin_47156401/article/details/132025194