最近我的ubuntu系统sudo装的数据库出现问题,迫于无奈重装,重装启动后用mysql命令客户端连接,出现如下提示:
[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如下:
[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:
[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,如下:
[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]$
重新链接,成功了!
分享到:
相关推荐
~$ mysqlERROR 2002 (HY000): 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 '/tmp/mysql.sock'”这样的错误。这个错误提示表明,客户端试图通过Unix域套接字(socket文件)...
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2) 的异常。是用dmg直接安装的以为安装包又出现了奇奇怪怪的错误,正欲卸载该版本时找到了我的问题的关键。 解决...
在安装好了MySQL之后,使用了新的配置文件后,MySQL服务器可以成功启动,但在登陆的时候出现了ERROR 2002 (HY000): Can’t connect to local MySQL server through socket,即无法通过socket连接到mysql服务器,同时...
ERROR 2002: Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (111) 解决办法: /usr/local/mysql/bin/mysqladmin -u root > -S /var/lib/mysql/mysql.sock password 'your.passwd' ...
在使用MySQL时,可能会遇到一个常见的错误:“ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’”。这个错误表明客户端无法通过Unix套接字文件与本地MySQL服务器建立...
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)
?php $link=mysql_connect(‘localhost’,’root’,... 运行后报错 Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ 但在 命令行中能进入mysql [root@localhost local]# mysql -u root -p E
标题中的问题 "Can't connect to local MySQL through socket '/tmp/mysql.sock'" 是一个常见的MySQL连接错误,通常发生在尝试通过套接字文件(socket file)连接到本地MySQL服务器时。该问题通常涉及MySQL服务未...
最近在linux上装Aphace... can't connect to local MySQL server through socket 'var/run/mysqld/mysqld.sock' 这个把我弄得几近崩溃,我在网上查找了很多的解决办法,大概有几种解决方案: 1.权限问题 2.修改/
以上就是对MySQL错误ERROR 2002 (HY000): Can't connect to local MySQL server through socket问题的分析和解决方法。通过理解和应用这些知识点,可以帮助数据库管理员有效解决MySQL连接故障,确保数据库服务的正常...
php 不能连接数据库 php error Can't connect to local MySQL server through socket '/tmp/mysql.sock'
在MySQL的使用过程中,有时会遇到异常错误"ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)"。这个错误通常表示客户端无法通过套接字文件与MySQL服务器...
服务器:unbuntu16.04,阿里云 ... ...第一阶段:此时以为再重启...ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' 怎么办呢,看看这个啥文件先,然而查到是这个文
3、Can’t connect to local MySQL server through socket ‘/Data/mydata/mysql.sock’ socket文件目录不对应导致的问题 4、今天要说的就是 没有打开only_full_group_by Cause:...
linux下以rpm包安装mysql 下载 访问以下地址下载对应操作系统下所需的版本 ...问题一:登录或使用中提示如下报错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 '/tmp/mysql.sock'(2) ``` 解决方法是使用以下命令: ``` sudo chown -R _mysql:mysql /usr/local/var/mysql ``` 然后启动 MySql 服务: `...
问题 2:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 该问题是关于 MySQL 服务无法启动的问题。解决方法是杀死 MySQL 进程,启动 MySQL 服务,并...
如果遇到 `Can't connect to local MySQL server through socket '/tmp/mysql.sock` 问题,可以按照以下步骤解决: 1. 查找 `mysql.sock` 文件: ``` find / -name mysql.sock ``` 2. 创建软连接: ``` ln -s /var/...
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) ``` 这个错误提示表示 MySQL 服务没有启动。可以使用以下命令启动 MySQL 服务: ``` # /etc/init.d/...