开发者社区> 潇湘隐者> 正文
阿里云
为了无法计算的价值
打开APP
阿里云APP内打开

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

简介:
+关注继续查看

从供应商手中接手一个云平台(Windwos Azure)上的MySQL数据库,登录数据库时遇到错误:

$mysql -uroot -p

Enter password:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

检查配置文件/etc/my.cnf发现供应商修改了mysql数据库的数据存储目录,另外mysql.sock文件位置也变更为了/dat/data/mysql/mysql.sock

$ more /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
 
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
innodb_buffer_pool_size = 2048M
 
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#datadir=/var/lib/mysql
#socket=/var/lib/mysql/mysql.sock
 
datadir=/dat/data/mysql
socket=/dat/data/mysql/mysql.sock
 
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
 
# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 
 
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

检查发现/var/lib/mysql.sock文件不存在,可以通过建立mysql.sock文件的软连接。然后登录数据库,问题解决。

[root@GETAZLNX005 ~]# ls /var/lib/mysql.sock
 
ls: cannot access /var/lib/mysql.sock: No such file or director
 
[root@GETAZLNX005 ~]# ln -s /dat/data/mysql/mysql.sock /var/lib/mysql/mysql.sock

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
版权声明:本文为 testcs_dn(微wx笑) 原创文章,非商用自由转载-保持署名-注明出处,谢谢。 https://blog.csdn.net/testcs_dn/article/details/51405416 ...
400 0
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
高高兴兴的装完了Mysql,想着执行一下 mysql 测试一下,结果出现以下错误提示:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.
442 0
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (
<p><br></p> <p>mysql启动成功</p> <p>service mysqld start </p> <p>mysql is OK</p> <p><br></p> <p>mysql登录错误 :</p> <p>[root@localhost ~]# mysql -uroot -p123456<br><span style="color:#ff0000">ERROR
1409 0
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
<span style="color:#3333ff">[root@t1 /]#  innobackupex --user=root --password=123456 /mydata/data</span><br><br><br> InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy<br>
1958 0
connection to dat Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
<p><br></p> <p>[root@t1 ~]# tail /tmp/zabbix_server.log <br><span style="color:#3366ff"> 23392:20160303:131022.598 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local My
2956 0
MYSQL错误解决:ERROR 2002 (HY000): 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 '/var/lib/mysql/mysql.sock' (2) 据说这个问题的原因很多,当然,我自己这个问题我是清楚的,就是mysql.sock的位置所致,一个是PHP要求的,一个是MYSQLD定义的,一个是MY.CONF指定的。
1472 0
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
 [root@luozhonghua ~]#   /usr/bin/mysqladmin -u root password 'aaaaaa' /usr/bin/mysqladmin: connect to server at 'localhost' failed error: 'Can't connect to local MySQL server through socket '/v
852 0
+关注
潇湘隐者
网名潇湘隐者/潇湘剑客、英文名Kerry,兴趣广泛,广泛涉猎,个性随意,不善言辞。执意做一名会写代码的DBA,混迹于IT行业
文章
问答
文章排行榜
最热
最新
相关电子书
更多
从花农到MySQL大
立即下载
从华农到MySQL大神
立即下载
MySQL Replication: Latest Developments
立即下载