很郁闷,MYSQL装完了,PHPMyadmin也装完了,发现不知道密码。

在网上找了些贴子,有很多没用的,不过最后还是弄好了,归纳了一下(去除了不少失败的操作)。

1
2
3
/etc/init.d/mysql stop
mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
mysql -u root mysql

进入mysql命令界面
1
2
3
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> exit;

重启mysql
1
2
/etc/init.d/mysql restart
mysql -uroot -p

Enter password: 新的密码

这种方法比较有效。

还有两个是网上说的,没有用过

方法一:

直接使用/etc/mysql/debian.cnf文件中[client]节提供的用户名和密码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
mysql -udebian-sys-maint -p
 
Enter password: < 输入[client]节的密码>
 
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
 
mysql> FLUSH PRIVILEGES;
 
mysql> quit
 
mysql -uroot -p
 
Enter password: < ;输入新设的密码newpassword>
 
mysql>

方法二:

这种方法我没有进行过测试,因为我的root用户默认密码已经被我修改过了,那位有空测试一下,把结果告诉我,谢谢!!

1
2
3
mysql -uroot -p
 
Enter password: < 输入/etc/mysql/debian.cnf文件中[client]节提供的密码>

相关文章:

  • 2022-12-23
  • 2021-11-07
  • 2021-08-06
  • 2021-06-17
  • 2021-12-03
  • 2022-12-23
  • 2021-05-15
猜你喜欢
  • 2021-12-20
  • 2021-12-01
  • 2021-12-04
  • 2021-10-21
  • 2022-12-23
  • 2021-12-17
相关资源
相似解决方案