Can't connect to local MySQL server through socket解决方法_MySQL
程序员文章站
2024-04-06 10:04:31
...
bitsCN.com
Can't connect to local MySQL server through socket解决方法 最近我的ubuntu系统sudo装的数据库出现问题,迫于无奈重装,重装启动后用mysql命令客户端连接,出现如下提示:Ruby代码 [LING mysql]$ mysql -u root -p Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) 我的my.cnf如下:Python代码 [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql # Default to using old password format for compatibility with mysql 3.x # clients (those using the mysqlclient10 compatibility package). old_passwords=1 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid port=3307
进入/var/lib/mysql下,发现mysql.sock存在,但/var/run/mysqld下没有mysqld.sock,灵机一动,可以通过软链接的方式使用/var/lib/mysql/mysql.sock:Shell代码 [ROOT mysqld]$ ln -s /var/lib/mysql/mysql.sock /var/run/mysqld/mysqld.sock [ROOT mysqld]$ mysqld_safe --log-error=/var/lib/mysql/error.log & 做链接并启动mysql,查看error.log,如下:Java代码 [ROOT mysql]$ more error.log InnoDB: The log sequence number in ibdata files does not match InnoDB: the log sequence number in the ib_logfiles! 100313 10:48:12 InnoDB: Database was not shut down normally! InnoDB: Starting crash recovery. InnoDB: Reading tablespace information from the .ibd files... InnoDB: Restoring possible half-written data pages from the doublewrite InnoDB: buffer... 100313 10:48:12 InnoDB: Started; log sequence number 0 43655 100313 10:48:12 [Note] /usr/sbin/mysqld: ready for connections. Version: '5.0.51a-3ubuntu5.5' socket: '/var/lib/mysql/mysql.sock' port: 3307 (Ubuntu) [ROOT mysql]$ 重新链接,成功了!
bitsCN.com
Can't connect to local MySQL server through socket解决方法 最近我的ubuntu系统sudo装的数据库出现问题,迫于无奈重装,重装启动后用mysql命令客户端连接,出现如下提示:Ruby代码 [LING mysql]$ mysql -u root -p Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) 我的my.cnf如下:Python代码 [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql # Default to using old password format for compatibility with mysql 3.x # clients (those using the mysqlclient10 compatibility package). old_passwords=1 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid port=3307
进入/var/lib/mysql下,发现mysql.sock存在,但/var/run/mysqld下没有mysqld.sock,灵机一动,可以通过软链接的方式使用/var/lib/mysql/mysql.sock:Shell代码 [ROOT mysqld]$ ln -s /var/lib/mysql/mysql.sock /var/run/mysqld/mysqld.sock [ROOT mysqld]$ mysqld_safe --log-error=/var/lib/mysql/error.log & 做链接并启动mysql,查看error.log,如下:Java代码 [ROOT mysql]$ more error.log InnoDB: The log sequence number in ibdata files does not match InnoDB: the log sequence number in the ib_logfiles! 100313 10:48:12 InnoDB: Database was not shut down normally! InnoDB: Starting crash recovery. InnoDB: Reading tablespace information from the .ibd files... InnoDB: Restoring possible half-written data pages from the doublewrite InnoDB: buffer... 100313 10:48:12 InnoDB: Started; log sequence number 0 43655 100313 10:48:12 [Note] /usr/sbin/mysqld: ready for connections. Version: '5.0.51a-3ubuntu5.5' socket: '/var/lib/mysql/mysql.sock' port: 3307 (Ubuntu) [ROOT mysql]$ 重新链接,成功了!
bitsCN.com
上一篇: PHP与Mysql连接
推荐阅读
-
Can't connect to local MySQL server through socket解决方法_MySQL
-
装配mysql出错Can't connect to MySQL server on 'localhost' (10061
-
装配mysql出错Can't connect to MySQL server on 'localhost' (10061
-
Can t connect to MySQL server 常见问题解决办法
-
php 不能连接数据库 php error Can't connect to local_MySQL
-
: Can’t connect to local mysql server through socket ‘/tmp/mysql.sock’ 博客分类: linux mysqlsockhostlinux
-
Can't connect to MySQL server on 'localhost' (10061) 博客分类: mysqlwin7 mysqIPv6
-
Python报错-(2003 Can t connect to MySQL server on 127.0.0.1)
-
MySQL错误ERROR 2002 (HY000): Can't connect to local MySQL server through socket
-
SELinux导致PHP连接MySQL异常Can't connect to MySQL server的解决方法