Home >Database >Mysql Tutorial >怎么解决linux mysql 无法登陆的问题

怎么解决linux mysql 无法登陆的问题

WBOY
WBOYOriginal
2016-06-01 13:07:011328browse

今天登陆mysql 提示Can't connect to local MySQL server rhrough socket 的问题,结合两篇帖子解决

我的系统是centos

首先:
cp /usr/share/doc/MySQL-server-5.5.24/my-medium.cnf /etc/my.cnf   
其次:
touch /var/lib/mysql/mysql.scok

查看下数据库运行状态

 /etc/init.d/mysql status
提示
ERROR! MySQL is running but PID file could not be found
先打印MYSQL进程
ps aux | grep mysql
然后KILL进程
kill -9 pid1 pid2 …
再启动MYSQL
/etc/init.d/mysql start
再检查mysql运行状态
/etc/init.d/mysql status

因为一开始/etc下我是找不到my.cnf 这个文件的,/usr/share/doc/MySQL-server-5.5.24/这个下面有个my-default.cnf这个文件,看了看,感觉和my-medium.cnf差不多,就拷贝到etc目录下了,来充当my.cnf吧,

mysql有两种启动方式,一种tcp,一种socket,一般来说tcp启动没问题,只是socket启动才会出现上述问题。

【相关教程推荐】

1. mysql数据库图文教程 

2. MySQL 5.1参考手册下载 

3. bootstrap教程 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn