OperationalError: (2002, “Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)”)

OperationalError: (2002, “Can‘t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock‘ (2)”)

python MySQLdb这个模块是独立的,有自己独立的socket,解决的方法就是找出mysql配置里的socket的地址(比如socket=/tmp/mysql.sock),然后做个软连接

ln -s /tmp/mysql.sock  /var/run/mysqld/mysql.sock 

OperationalError: (2002, “Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)”)

时间: 2024-10-23 17:56:54

OperationalError: (2002, “Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)”)的相关文章

(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/

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, chan

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

Can&#39;t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock‘ (2)解决思路

首先说明一下mysql.sock文件的作用: 连接mysql有两种方式,第一种是TCP/IP,第二种就是直接使用unix domain socket,它比TCP/IP块. mysql.sock是在mysql-server和client在同一服务器上时,发起本地连接时可用,而无需定义-h参数指定具体的IP.mysql.sock是随每次mysql server启动时生成,通常配置参数是将mysql.sock生成在/tmp/目录下.即在/etc/my.cnf文件中指定socket=/tmp/mysql

Can&#39;t connect to local MySQL server through socket &#39;/var/run/mysqld/mysqld.sock&#39; (2)

今天在ubuntu上连接mysql数据库时,遇到一个小问题 Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) 第一次使用时还可以使用的,突然就不好了,不知道是不是没吃药, 先查看数据库状态: [email protected]:~$ sudo /etc/init.d/mysql status (因为我使用的是普通用户,所以要sudo一下) 1.如果出现: [email prot

Can&#39;t connect to local MySQL server through socket &#39;/var/run/mysqld/mysqld.sock&#39;解决

安装上mysql后,报 Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock',试了网上的方法都没有用,于是打开/etc/my.cnf查看. 看到这么一段: # The MySQL server 26 [mysqld] 27 port            = 3306 28 socket          = /tmp/mysql.sock 29 skip-external-locking