温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

mysql 中怎么修改root密码

发布时间:2021-08-04 17:06:41 来源:亿速云 阅读:130 作者:Leah 栏目:数据库

mysql 中怎么修改root密码,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。

Method 1:
在/usr/local//bin/下:
./mysqladmin -u root password new_password
一般安装时用此方法设置。

Method 2:

在mysql状态下:
mysql>UPDATE user SET password=PASSWORD(new_password) WHERE user=root;
mysql>FLUSH PRIVILEGES;

Method 3:
mysql>SET PASSWORD FOR root=PASSWORD(new_password);

有人会问如果不知道mysql root的密码情况下,是否可以修改密码呢?答案:可以的,想知道方法请继续往下看:

只有在mysqld启动的时候加上 --skip-grant-tables就ok,

例:

[root@server]# /usr/local/mysql/bin/mysqld_safe --skip-grant-tables &

[root@server]# /usr/local/mysql/bin/mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 7
Server version: 5.0.45-log Source distribution

Type help; or h for help. Type c to clear the buffer.

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(******)where user=root;
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

看完上述内容,你们掌握mysql 中怎么修改root密码的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI