解决linux(centos7)重新安装mysql systemctl start mysqld.service时报错

重新安装mysql时,运行

systemctl status mysqld.service
报错。

[root@test-dcruxue ~]# 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服务状态

[root@test-dcruxue ~]# systemctl 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 Tue 2018-07-17 16:14:22 CST; 8min ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 17451 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=1/FAILURE)
Process: 17376 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 16428 (code=exited, status=1/FAILURE)

Jul 17 16:13:41 test-dcruxue systemd[1]: Starting MySQL Server...
Jul 17 16:14:20 test-dcruxue mysqld[17451]: Initialization of mysqld failed: 0
Jul 17 16:14:20 test-dcruxue systemd[1]: mysqld.service: control process exited, code=exited status=1
Jul 17 16:14:22 test-dcruxue systemd[1]: Failed to start MySQL Server.
Jul 17 16:14:22 test-dcruxue systemd[1]: Unit mysqld.service entered failed state.
Jul 17 16:14:22 test-dcruxue systemd[1]: mysqld.service failed.
无果;

遂想到查看日志:cat /var/log/mysqld.log

2018-07-17T08:23:01.745601Z 0 [ERROR] Can't start server: Bind on TCP/IP port: Address already in use
2018-07-17T08:23:01.745607Z 0 [ERROR] Do you already have another mysqld server running on port: 3306 ?
2018-07-17T08:23:01.745619Z 0 [ERROR] Aborting
发现3306端口被占用

[root@test-dcruxue ~]# ps aux|grep mysql
root 9861 0.0 0.0 113252 1600 ? S 14:52 0:00 /bin/sh /usr/bin/mysqld_safe --skip-grant-table
mysql 10009 0.0 5.6 1585376 457120 ? Sl 14:52 0:03 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --skip-grant-table --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
root 17563 0.0 0.0 112648 956 pts/2 R+ 16:32 0:00 grep --color=auto mysql
然后杀掉进程

[root@test-dcruxue ~]# kill -9 10009
就ok了
————————————————

聚焦技术与人文,分享干货,共同成长更多内容请关注“数据与人”

原文地址:https://www.cnblogs.com/shujuyr/p/13080722.html