在使用

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. linux搜索jar内容

    linux搜索  spring-beans-2.5.6.jar  内容 1.jar tvf spring-beans-2.5.6.jar -c  创建新的归档文件 -t  列出归档目录 -x  解压缩 ...

  2. HDU 5481 Desiderium 动态规划

    Desiderium Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=548 ...

  3. [每日一题] 11gOCP 1z0-053 :2013-10-12 RESULT_CACHE在哪个池?.............................44

    转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/12657479 正确答案:B   Oracle 11g 新特性:Result Cache , ...

  4. C#操作Excel文件(读取Excel,写入Excel)

    看到论坛里面不断有人提问关于读取excel和导入excel的相关问题.闲暇时间将我所知道的对excel的操作加以总结,如今共享大家,希望给大家可以给大家带了一定的帮助.另外我们还要注意一些简单的问题1 ...

  5. EntityFramework小知识

    Entity Framework 应用程序有以下优点: 1 应用程序可以通过更加以应用程序为中心的概念性模型(包括具有继承性.复杂成员和关系的类型)来工作. 2 应用程序不再对特定的数据引擎或存储架构 ...

  6. PAT 1007

    1007. Maximum Subsequence Sum (25) Given a sequence of K integers { N1, N2, ..., NK }. A continuous ...

  7. QT连接多种数据库f方法及测试

    QT提供了对多种数据库的访问支持,对SQL Server也可以通过ODBC来进行访问.要想顺利访问SQL Server. 首先要保证以下几点:1. QT编译时已经编译了QtSql2. 编译了ODBC插 ...

  8. 深入理解计算机系统第二版习题解答CSAPP 2.15

    只使用位级运算和逻辑运算,编写一个C表达式,它等价于x==y.换句话说,当x和y相等时它将返回1,否则就返回0. !(x ^ y)

  9. 用指令修改DOM

    对于HTML5,input元素有autofocus这个属性,用户在第一次进入界面时就可以和用户交互,对于浏览器来说,可以 把键盘焦点定位在某个元素上,但是对于非input元素,则不可以,我们可以使用指 ...

  10. [转]Best way to sort a DropDownList in MVC3 / Razor using helper method

    本文转自:http://stackoverflow.com/questions/7223185/best-way-to-sort-a-dropdownlist-in-mvc3-razor-using- ...