从供应商手中接手一个云平台(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

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)的更多相关文章

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

    有时候,当我们使用"mysql"."mysqladmin"."mysqldump"等命令管理数据库时,服务器抛出类似如下错误: 一.错误现场 ...

  2. ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var mysql 启动不了(转载)

    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var mysql 启动不了   ps -A | gr ...

  3. Mac mySql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)的解决办法

    我的环境:Mac 10.11.6 ,mysql  5.7.14  . mac mySql 报错ERROR 2002 (HY000): Can't connect to local MySQL serv ...

  4. linux云服务器mysql ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’

    一早上过来发现网站打开报错,数据库连接不上.. 有人改密码? putty进去,mysql -uroot -p 输入密码后,报错 ERROR 2002 (HY000): Can't connect to ...

  5. 更换mysql数据目录后出现ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 的解决办法

    服务器上的mysql默认数据目录为/var/lib/mysql/,同时服务器的/空间不是很大,而近期又有大量的日志需要导入进行分析,时常搞得/的空间捉襟见肘,晚上一狠心就想把mysql的数据目录转移到 ...

  6. 启动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’ ( ...

  7. 安装mysql后ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var mysql 启动不了

    ps -A | grep -i mysql kill 列出来的进程 service mysql start 我的问题就解决了 ------------------------------------- ...

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

    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 背景: mys ...

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

    好久不用mysql,今天突然想用的时候, mysql -uroot -p 直接报了下面的错误 ERROR 2002 (HY000): Can't connect to local MySQL serv ...

随机推荐

  1. php代码规范—2

    如何写出好的 PHP 代码? 在本文中,我们将探讨一些良好的编程习惯,这将帮助你避免代码中的缺陷. 1- 编写模块化代码 良好的PHP代码应该是模块化代码.PHP的面向对象的编程功能是一些特别强大的工 ...

  2. Oracle学习线路

    出自huyangg的博客,地址是:oracle学习路线图 1.sql.pl/sql(网上有很多的视频,可以做一个简单的入手,然后看几本书,多做实验)    作为oracle的基本功,需要大家对sql和 ...

  3. VMware Workstation 10.0.4.2249910 CN

    VMware Workstation 10.0.4.2249910.exe Workstation10.0.4修复了微软Windows 8.1和Windows Server 2012操作系统中的内存问 ...

  4. C++系列: 如何将十六机制的字符串转成整数

    bool convertHexStringToInt(char* pstrHex, unsigned long* pResult) { ) return false; else return true ...

  5. 夺命雷公狗-----tp中遇到数据乘积的问题的遇见

    昨晚遇到了一个很神奇的问题, 然后打印出来的结果是 ) LIMIT , 然后dump出来的结果有点无语,他是10*10这样的倍增的,如果数据量大,分分钟直接可以让服务器直接死掉.... 想这问题我想了 ...

  6. DevExpress汉化(WinForm)

    /* *隔壁老王原创,2013-09-21,转载请保留本人信息及本文地址. *本文地址:http://wallimn.iteye.com/blog/1944191 */ 最简单的方式就是使用汉化资源, ...

  7. Odoo 库存管理-库存移动(Stock Move)新玩法

    库存移动(Stock Move)新玩法 Odoo的库存移动不仅仅是存货在两个“存货地点”之间的移动的基本概念了,他们可以被“串联”在一起,可以用来生成或改变其对应的拣货单 (Picking).链式库存 ...

  8. PHP的反射机制(转)

    介绍: PHP5添加了一项新的功能:Reflection.这个功能使得phper可以reverse-engineer class, interface,function,method and exte ...

  9. 查看Oracle SQL执行计划的常用方式

    在查看SQL执行计划的时候有很多方式 我常用的方式有三种 SQL> explain plan for 2 select * from scott.emp where ename='KING'; ...

  10. 让magento的validate验证hidden field

    Object.extend(Validation, { isVisible : function(elm) { return true; }, insertAdvice : function(elm, ...