Home >Database >Mysql Tutorial >Can't connect to local MySQL server 时 修改 root 用户名

Can't connect to local MySQL server 时 修改 root 用户名

WBOY
WBOYOriginal
2016-06-07 15:46:411264browse

1 由于不小心 root用户名和密码忘记了,但是通过网上的一种方式 http://www.cnblogs.com/allenblogs/archive/2010/08/12/1798247.html 出现Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)的错误,奇怪,mysql明明启动

1  由于不小心 root用户名和密码忘记了,但是通过网上的一种方式 

http://www.cnblogs.com/allenblogs/archive/2010/08/12/1798247.html

出现 Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)的错误,奇怪,mysql明明启动了,只好换另外一种方式


2  使用 phpmyadmin

(1) 修改MySQL的登录设置: 
# vi /usr/local/mysql/my.cnf
在[mysqld]的段中加上一句:skip-grant-tables

    (2) 重启 mysqld

/etc/init.d/mysqld restart


      (3) 登录  phpmyadmin

首先用root账号登陆phpmyadmin,然后点击左侧进入mysql数据库,在顶部点击“mysql”进入sql输入界面。输入以下命令:

update user set password=password('123456') where User='root'

其中123456为你希望修改的密码,切记不要在数据库中直接手工修改密码。

   
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn