2016-03-06 12:00:36 31231 [ERROR] /usr/local/mysql/bin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2 - No such file or directory)
2016-03-06 12:00:36 31231 [ERROR] Can't start server: can't create PID file: No such file or directory
160306 12:00:36 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
问题:can't create PID file: No such file or directory,即找不到mysql启动的pid文件
解决方案:mysqld目录不存在,我们创建它就可以了
1 2 3 4 5
[root@leaf mysql]# mkdir /var/run/mysqld [root@leaf mysql]# cd /var/run/mysqld/ [root@leaf mysqld]# touch mysqld.pid #创建mysqld.pid文件 [root@leaf mysqld]# cd .. [root@leaf run]# chown -R mysql mysqld #将mysqld目录的属主设置为mysql
回到mysql目录,我们再启动一次mysql,如下:
1 2 3 4
[root@leaf run]# cd /usr/local/mysql [root@leaf mysql]# bin/mysqld_safe --user=mysql 160306 12:12:45 mysqld_safe Logging to '/var/log/mysqld.log'. 160306 12:12:45 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
可以看到并没有终止运行的提示信息,我们再确认一下mysql服务是不是已经启动了:
1 2 3 4
[root@leaf ~]# netstat -antup Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 31484/mysqld
mysql服务确实已经成功启动了!
(5)测试mysql服务
为了使mysql可以更好地在你的系统上运行,建议进行一定的mysql服务测试,如下:
1 2 3 4
[root@leaf mysql]# bin/mysqladmin version bin/mysqladmin: connect to server at 'localhost' failed error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)' Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!
按照官方文档的操作去测试,但却出现了上面的问题(需要注意的是,我的mysql服务已经开启了!)。
问题:/tmp/mysql.sock不存在