MySQL修改用户密码,新手必看

我们大家都知道MySQL修改用户密码这一问题一直是困扰新手的一个恶魔,在此问题的解决上新手经常会上范错误,而导致最终不能进入MySQL数据库,所以以下就是几个相关例子的介绍,望你能有所收获。

网站建设哪家好,找成都创新互联!专注于网页设计、网站建设、微信开发、小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了绵竹免费建站欢迎大家使用!

1、原来的密码是123456

 
 
 
  1. C:\>type MySQL5.bat
  2. @echo off
  3. MySQL -uroot -p123456 -P3306

正确的修改MySQL用户密码的格式是:

我们这里用

用户:root(可以换成其他的)

密码:woshiduide

来演示新密码。

 
 
 
  1. C:\>MySQLadmin -uroot -p password woshiduide
  2. Enter password: ******

于是修改成功。注意PASSWORD关键字后面的空格有好多人是这样修改的:

 
 
 
  1. C:\>MySQLadmin -uroot -p password ‘woshiduide’
  2. Enter password: ******
  3. C:\>MySQLadmin -uroot -p password ‘woshiduide’
  4. Enter password: *********
  5. Warning: single quotes were not trimmed from the password by your command
  6. line client, as you might have expected.

而这个时候真正的密码是’woshiduide’

 
 
 
  1. C:\>MySQL -uroot -p’woshiduide’
  2. Welcome to the MySQL monitor. Commands end with ; or \g.
  3. Your MySQL connection id is 18
  4. Server version: 5.1.17-beta-community-nt-debug MySQL Community Server (GPL)
  5. Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
  6. MySQL>

MySQL修改用户密码实际操作中而新手往往这样:

 
 
 
  1. C:\>MySQL -uroot -pwoshiduide
  2. ERROR 1045 (28000): Access denied for user ‘root’@'localhost’ (using password: Y
  3. ES)

所以非常郁闷,BAIDU、GOOGLE的搜了一大堆。

我现在把密码改回去。

 
 
 
  1. C:\>MySQLadmin -uroot -p’woshiduide’ password 123456

2、还有就是可以直接进入MySQL,然后修改密码。

 
 
 
  1. MySQL> use MySQL
  2. Database changed
  3. MySQL> update user set PASSWORDPASSWORD = PASSWORD(‘woshiduide’) where USER=’root’ and H
  4. OST=’localhost’;
  5. Query OK, 1 row affected (0.05 sec)
  6. Rows matched: 1 Changed: 1 Warnings: 0
  7. MySQL> flush privileges;
  8. MySQL> exit
  9. Bye
  10. C:\>MySQL -uroot -pwoshiduide
  11. Welcome to the MySQL monitor. Commands end with ; or \g.
  12. Your MySQL connection id is 23
  13. Server version: 5.1.17-beta-community-nt-debug MySQL Community Server (GPL)
  14. Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
  15. MySQL>
  16. Query OK, 0 rows affected (0.02 sec)

3、还有一种就是用SET PASSWORD 命令修改:

 
 
 
  1. C:\>MySQL5.bat
  2. Enter password: ******
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 8
  5. Server version: 5.1.17-beta-community-nt-debug-log MySQL Community Server (GPL)
  6. Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
  7. MySQL> set password for root@’localhost’ = password(‘woshiduide’);
  8. Query OK, 0 rows affected (0.02 sec)
  9. MySQL> flush privileges;
  10. Query OK, 0 rows affected (0.09 sec)
  11. MySQL> exit
  12. Bye

4、GRANT 也可以,不过这里不介绍。因为涉及到权限的问题。

以上的相关内容就是对MySQL修改用户密码的介绍,望你能有所收获。

名称栏目:MySQL修改用户密码,新手必看
标题URL:http://www.hantingmc.com/qtweb/news42/307192.html

网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联