error 2001:can't connect to local MySQL server through '/var/run/mysqld/mysql.socket(2)

ubuntu下出现的2002, "Can‘t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock‘ (2)解决方法:

网上有很多种方法。我将mysql卸载重装后解决了此问题。

步骤如下:

1.卸载mysql

 sudo apt-get autoremove --purge mysql-server-5.0
 sudo apt-get remove mysql-server
 sudo apt-get autoremove mysql-server
 sudo apt-get remove mysql-common

2.安装mysql

sudo apt-get install mysql-server

sudo apt-get install mysql-client

3.安装MySQLdb模块:

sudo apt-get install python-mysqldb(安装python-mysqldb 是将python和mysql连接起来)

我开始没有安装此模块因为我编程不用python,运行后依然出错。安装此模块后解决了问题。原因不详。有大神知道的还请不吝赐教。

4.运行mysql

mysql -uroot -p

至此问题解决。

error 2001:can't connect to local MySQL server through '/var/run/mysqld/mysql.socket(2)

时间: 2024-12-17 16:34:34

error 2001:can't connect to local MySQL server through '/var/run/mysqld/mysql.socket(2)的相关文章

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=

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)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

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

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

http://stackoverflow.com/questions/11990708/error-cant-connect-to-local-mysql-server-through-socket-var-run-mysqld-mysq 1. pkill -9 mysqld 2. rm -f /var/run/mysqld/mysqld.pid 3. chmod 777 '/var/run/mysqld/mysqld.sock done error: 'Can't connect to loc

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