Home  >  Article  >  Database  >  ubuntu下xampp忘记mysql密码重置

ubuntu下xampp忘记mysql密码重置

WBOY
WBOYOriginal
2016-06-07 16:41:491411browse

之前在ubuntu 12.04里安装了xampp,设置了mysql数据库root密码,今天需要增加个数据库,发现忘记之前设置的密码是什么了。经过一番摸爬滚打,终于搞明白了,注意以下的操作都是以linux的root身份操作的,其它的未测试,目测只要权限允许应该没问题。 先停止m

之前在ubuntu 12.04里安装了xampp,设置了mysql数据库root密码,今天需要增加个数据库,发现忘记之前设置的密码是什么了。经过一番摸爬滚打,终于搞明白了,注意以下的操作都是以linux的root身份操作的,其它的未测试,目测只要权限允许应该没问题。

先停止mysql
/opt/lampp/lampp stopmysql

接着这样启动mysqld
/opt/lampp/sbin/mysqld --skip-grant-tables &

会看到类似这样的输出

2014-04-29 10:54:43 25686 [Note] /opt/lampp/sbin/mysqld: ready for connections.
Version: ‘5.6.16’ socket: ‘/opt/lampp/var/mysql/mysql.sock’ port: 3306 Source distribution on

此时光标可能会停在on后,没有回到提示符状态,那么就先敲一下回车,然后就回到命令提示符状态了。
接下来,就可以空密码root登录到mysql数据库了
/opt/lampp/bin/mysql -u root

赶紧设置为新的root密码吧

mysql> use mysql;
mysql> update user set password=PASSWORD(“123456″) where User=’root';
mysql> flush privileges;
mysql> quit

重启mysql
/opt/lampp/lampp stopmysql<br> /opt/lampp/lampp startmysql

相关文章

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