ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

今天mysql不知道犯啥病,root登录的时候一直报这个错误。

在国内网站找了找,没什么合适的 答案,在stackoverflow和ubuntu的一个社区上找到了答案,搞定了,但是没太看懂,记录一下,以后再翻。

That said, Here is what I did/ found out:

1. You don‘t have to change the tmp directory in the my.cnf file. Even adding a second directory, changing from
tempdir =/tmp to =/tmp:/newdir crashed mysql. In 10.04 using MySQL 5.1 you used to have to add the second path other wise you got an error something like can‘t write temp file.... Of course did change the datadir to /MyDisk/myNewDir

2. Used the wrong permission flags on my file copy from the command line. Should use cp -R -p /var/lib/mysql /MyDisk/myNewDir.
Not sure if that really mattered as trashed old dir and started over with the flags as stated so did not test with old permissions. This did work.

3. Added /MyDisk/myNewDir/ r, and /MyDisk/myNewDir/* rwk, to the bottom of etc/apparmor.d/usr.sbin.mysqld file.
Also changed the var/lib/mysql entries in apparmor as above

4. Left in the var/run... file as created above. Also not sure if that matters but already behind in getting the
server updated so not really caring past having it working properly.

sudo service mysql stop

sudo /etc/init.d/apparmor reload

sudo service mysql start

and this worked.

没看太懂,也没时间翻译了,先欠着吧。。红字是解决方法。

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

时间: 2024-08-03 15:23:35

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'的相关文章

(MYSQL)ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) 方案1. 1.#ps -A|grep mysql 显示类似: 1829 ?        00:00:00 mysqld_safe   1876 ?        00:00:31 mysqld 2.#kill -9 1829 3.#kill -9 1876 4.#/etc/init.d/

mysql start error ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysql.sock’ (2)

When I type mysql, it shows “ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysql.sock’ (2)”. Then I try to start mysql service: $ service mysql start But then I get error “ No directory, logging in with HOME=

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

First make a backup of your /var/lib/mysql/ directory just to be safe. sudo mkdir /home/<your username>/mysql/ cd /var/lib/mysql/ sudo cp * /home/<your username>/mysql/ -R Next purge MySQL (this will remove php5-mysql and phpmyadmin as well as

mysql之ERROR 2002 (HY000): Can&#39;t connect to local MySQL server through socket &#39;/var/run/mysqld/mysqld.sock&#39;解决方法

LAMPP安装完成之后,mysql -u root -p连不上,报这个错误: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' 在mysql的配置文件里,/opt/lampp/etc/my.cnf, 发现了这样的配置: [java] <SPAN style="FONT-SIZE: 24px"># The following

mysql ERROR 2002 (HY000): Can&#39;t connect to local MySQL server through socket &#39;/var/run/mysqld/mysqld.sock&#39; (2 &quot;No such file or directory&quot;)

解决方案如下: mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory") 原文地址:https://www.cnblogs.com/youran-he/p/8182280.html

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var mysql 启动不了

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var mysql 启动不了 ps -A | grep -i mysql kill 列出来的进程 service mysql start 我的问题就解决了 ---------------------------------------------- Fedora8启动mysql 报错:ERROR 2002 (HY000): Can’t connect

安装mysql后ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var mysql 启动不了

ps -A | grep -i mysql kill 列出来的进程 service mysql start 我的问题就解决了 ---------------------------------------------- Fedora8启动mysql 报错:ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2) 1.先查看 /etc/rc.d/ini

ERROR 2002 (HY000): Can&#39;t connect to local MySQL server through socket &#39;/var/lib

今天在linux里安装mysql,运行时遇到这样的错误 ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' 上网查了下: 这种情况大多数是因为你的mysql是使用rpm方式安装的,它会自动寻找 /var/lib/mysql/mysql.sock 这个文件,通过unix socket登录mysql.常见解决办法如下:1.创建/修改文件 /etc/my.c

启动mysql错误ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2) 1.先查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已经启动.另外看看是不是权限问题. 2.确定你的mysql.sock是不是在那个位置,mysql -u 你的mysql用户名 -p -S /var/lib/mysql/mysql.sock 3