Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'解决

安装上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

30 log-error=/alidata/log/mysql/error.log

31 key_buffer_size = 16M

32 max_allowed_packet = 1M

33 table_open_cache = 64

34 sort_buffer_size = 512K

35 net_buffer_length = 8K

36 read_buffer_size = 256K

37 read_rnd_buffer_size = 512K

38 myisam_sort_buffer_size = 8M

可知,使用的.sock文件,是/tmp/mysql.sock,而不是/var/run/mysqld/mysqld.sock,于是加个链接

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

解决

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'解决

时间: 2024-10-05 20:27:22

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'解决的相关文章

Can'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

(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

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;的解决

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'的解决 原因是目录 的访问权限问题,ubuntu下用下面的命令(其他发行版用管理员权限,把sudo去掉) sudo chown -R mysql:mysql /var/run/mysqld 然后启动服务器 sudo /etc/init.d/mysql start Can't connect to local MySQL server th

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

OperationalError: (2002, “Can&#39;t connect to local MySQL server through socket &#39;/var/run/mysqld/mysqld.sock&#39; (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/