mysql 中怎么修改root密码

45次阅读
没有评论

共计 1068 个字符,预计需要花费 3 分钟才能阅读完成。

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 密码的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注丸趣 TV 行业资讯频道,感谢各位的阅读!

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-08-03发表,共计1068字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)