首页 热点资讯 义务教育 高等教育 出国留学 考研考公

Ubuntu 如何修改mysql的账号密码

发布网友

我来回答

3个回答

热心网友

1.如果您没有忘记密码的情况下,可以通过UPDATE直接编辑user表来修改密码:
进入数据库mysql -u root
mysql> use mysql;
mysql> UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root';
mysql> FLUSH PRIVILEGES;
2.如果您已经忘记密码:
# /etc/init.d/mysql stop 1、结束当前正在运行的mysql进程。
# /usr/bin/mysqld_safe --skip-grant-tables 2、用mysql安全模式运行并跳过权限验证。
# mysql -u root 3、重开一个终端以root身份登录mysql。

mysql> use mysql; 4、修改root用户口令。
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set Password = PASSWORD('root') where User ='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0

mysql> exit

# /etc/init.d/mysql restart 5、结束mysql安全模式,用正常模式运行mysql。
mysql> update mysql.user set password=PASSWORD('新密码') where User='root';
6、试试你新修改的口令
mysql> flush privileges;
mysql> quit

热心网友

解决方法如下:
1、终端中结束当前正在运行的mysql进程。
# sudo /etc/init.d/mysql stop

2、用mysql安全模式运行并跳过权限验证。
# sudo /usr/bin/mysqld_safe --skip-grant-tables

3、ctrl+T重开一个终端以root身份登录mysql。
# mysql -u root

4、修改root用户口令。
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set Password = PASSWORD('root') where User ='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0

mysql> exit
注意:括号里的'root'就是新密码。
5、结束mysql安全模式,用正常模式运行mysql。
# sudo /etc/init.d/mysql restart

6、试试你新修改的口令登陆MySQL
# myslq -u root -p
输入密码 root
mysql> show grants for 'root'@'127.0.0.1';
mysql> flush privileges;
刷新账户后,退出。
mysql> quit;

热心网友

你是忘了密码? 还是没设密码?不知道怎么进去?

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com