mysql服务启动,但是连接不上,如何解决?

登陆报错:

  root@localhost:~# mysql -u root -p  Enter password:  ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)  root@localhost:~# service mysqld restart  Shutting down MySQL..                   [ OK ]  Starting MySQL.                      [ OK ]  root@localhost:~# mysql -u root -p  Enter password:  ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

原因不详,知道了补上

解决方案一:

 root@localhost:~# find / -name mysql.sock /tmp/mysql.sock root@localhost:~# mysql -u root -p -S /tmp/mysql.sock Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.15-log Source distribution Copyright (c) 2000, 2011, 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@localhost:~# find / -name mysql.sock /tmp/mysql.sock root@localhost:~# vi /etc/my.cnf[mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockuser=mysql# Default to using old password format for compatibility with mysql 3.x# clients (those using the mysqlclient10 compatibility package).old_passwords=1# Disabling symbolic-links is recommended to prevent assorted security risks;# to do so, uncomment this line:# symbolic-links=0# 加上下面的这段代码即可[mysql]socket=/tmp/mysql.sock[mysqld_safe]log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pidroot@localhost:~# mysql -u root -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 3Server version: 5.6.15-log Source distributionCopyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>

更多相关文章

  1. android中HttpURLConnection调用getResponseCode()时崩溃 解决方
  2. Android空引用问题的解决方法——on a null object reference
  3. android读取assets大于1M文件的解决方法
  4. 几个Android小错误解决方法
  5. CheckBox android:paddingLeft 不兼容问题解决方法
  6. android SDK升级连接不上服务器解决方案
  7. Android(安卓)Studio使用过程中遇到的问题(一)-- "value 2"异常解
  8. Eclipse中编译Android工程时出现的问题解决方法。
  9. Android(安卓)ListView滑动后背景变黑问题解决方法

随机推荐

  1. android studio 加载.proto不能生成xxxDr
  2. Android 使用Handler的PostDelayed方法实
  3. 安卓相关学习
  4. Android:简单的开场界面
  5. android布局控件的用法
  6. 解决:修改安卓system系统文件导致手机一直
  7. android属性动画爬坑之路
  8. Activity的android:launchMode
  9. [Android(安卓)编译(一)] Ubuntu 16.04 L
  10. android测试器