在使用

deamon@deamon-H55M-S2:/usr/bin$ mysqladmin -u root -p shutdown

关闭MySQL之后试图通过:

deamon@deamon-H55M-S2:/usr/bin$ mysqld_safe &

来重启服务器,发现重启失败,显示权限不够:

/usr/bin/mysqld_safe: 548: /usr/bin/mysqld_safe: cannot create /var/lib/mysql/mysqld_safe.pid: Permission denied

于是加上sudo:

deamon@deamon-H55M-S2:~$ sudo mysqld_safe&
[4] 7998 [4]+ Stopped sudo mysqld_safe
deamon@deamon-H55M-S2:~$ mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

然后就出现了如题所示的错误。

解决方法是将用户切换成root,再重新启动。

deamon@deamon-H55M-S2:~$ su -
Password:
root@deamon-H55M-S2:~# mysqld_safe &
[1] 8155
root@deamon-H55M-S2:~# 2016-11-29T11:50:50.182755Z mysqld_safe Logging to syslog.
2016-11-29T11:50:50.186438Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2016-11-29T11:50:50.209538Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql root@deamon-H55M-S2:~# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.16-0ubuntu0.16.04.1 (Ubuntu) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>

此时将用户切换回原非root用户,mysql还可正常使用。至此该问题解决。

解决:error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'的更多相关文章

  1. error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'

    http://stackoverflow.com/questions/11990708/error-cant-connect-to-local-mysql-server-through-socket- ...

  2. 【error】: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'

    错误描述如下: error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) ...

  3. mysql之ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'解决方法

    LAMPP安装完成之后,mysql -u root -p连不上,报这个错误: ERROR 2002 (HY000): Can't connect to local MySQL server throu ...

  4. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'解决

    用XAMPP装装好mysql之后,mysql -uroot 连不上,报这个错误:   ERROR 2002 (HY000): Can't connect to local MySQL server t ...

  5. 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',试了网上的方法 ...

  6. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)-mysql.sock丢失解决方案

    我们的LAMP是搭建在UBUNTU 12.04 LTS上的. LAMP是通过编译的方式进来安装的. 在一次处理意外挂机时由于未知的原因在重启后发现无法连接数据库了, 在打开网站时出现如下的的提示: E ...

  7. Running MYSQL 5.7 By Bash On Ubuntu On Windows:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

    root@PC-RENGUOQIANG:/usr/sbin# /etc/init.d/mysql start * Starting MySQL database server mysqld [ OK ...

  8. ubuntu 下安装 mysql 启动报错:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

    环境: ubuntu LTS 18.04.1 mysql Ver 14.14 Distrib 5.7.29, for Linux (x86_64) 初探 linux,按照如下安装完mysql sudo ...

  9. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

    今天执行mysql操作的时候出现了错误:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run ...

随机推荐

  1. How to add “Maven Managed Dependencies” library in build path eclipse

    If you have m2e installed and the project already is a maven project but the maven dependencies are ...

  2. JavaScript toFixed() 方法

    定义和用法toFixed() 方法可把 Number 四舍五入为指定小数位数的数字. 语法NumberObject.toFixed(num) 参数 描述num 必需.规定小数的位数,是 0 ~ 20 ...

  3. CircularProgressBar

    https://github.com/semicoder/CircularProgressBar https://github.com/amurani/MeterView

  4. Liunx下Tomcat+MYSQL+Nginx配置

    环境:centos6.4 min #安装编译库及依赖模块 yum -y install gcc gcc-c++ autoconf automake make yum -y install zlib z ...

  5. MySQL如何选择float, double, decimal

    http://yongxiong.leanote.com/post/mysql_float_double_decimal

  6. HTTP 无法注册 URL http://+:12345/HelloWcfService/。进程不具有此命名空间的访问权限

    运行的时候却发现出如下问题:HTTP 无法注册 URLhttp://+:12345/HelloWcfService/.进程不具有此命名空间的访问权限(有关详细信息,请参见http://go.micro ...

  7. /lib /usr/lib /usr/local/lib 区别

    简单说,/lib是内核级的,/usr/lib是系统级的,/usr/local/lib是用户级的. /lib/ — 包含许多被 /bin/ 和 /sbin/ 中的程序使用的库文件.目录 /usr/lib ...

  8. centos vim 中文乱码解决方案

    1.安装中文包:yum -y groupinstall chinese-support   2.修改字符编码配置文件 vi /etc/sysconfig/i18n LANGUAGE="zh_ ...

  9. 轻松学习Ionic (一) 搭建开发环境,并创建工程

    1.准备工作     下载 Node.js(下载包),WebStorm(IDE,编写代码,浏览器调试),JDK(webstorm 运行环境),Android SDK (Android编译)     不 ...

  10. OAuth2集成——《跟我学Shiro》

    http://jinnianshilongnian.iteye.com/blog/2038646 目前很多开放平台如新浪微博开放平台都在使用提供开放API接口供开发者使用,随之带来了第三方应用要到开放 ...