ubuntu mysql 修改root密码和权限

it2022-05-05  126

转自:http://blog.chinaunix.net/uid-20718384-id-3322167.html

mysql root用户密码忘记或者是权限不对。1. 先停止mysqlsudo service mysql stop

2. 运行mysqld_safesudo mysqld_safe --user=mysql --skip-grant-tables --skip-networking

3. 命令行下进入数据库mysql -u root mysql

4. 修改user表:root用户密码update user set password=PASSWORD('newpassword') where user='root';

5.修改user表:root权限(Grant_priv),其他权限类似

select * from user where user='root';update user set Grant_priv='Y' where user='root';

6. 停止mysqld_safe,重启mysql(可能不安全)

kill -9 mysqld_safe[_pid,原创中有这个尾巴,但是我用的时候用ps -e查看了下进程没有这个尾巴]pkill mysqlservice mysql start

转载于:https://www.cnblogs.com/MonkeyF/archive/2013/04/02/2996545.html

相关资源:Ubuntu18.0.4安装MySQL并设置ROOT用户密码

最新回复(0)