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

以下的文章主要介绍的是MySQL修改用户密码的实际操作流程,以及MySQL修改用户密码的解决的过程中新手易出现的错误描述。
首页 新闻资讯 行业资讯 MySQL修改用户密码,新手必看

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

1、原来的密码是123456

复制

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

  • 2.

  • 3.

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

我们这里用

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

密码:woshiduide

来演示新密码。

复制

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

  • 2.

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

复制

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

  • 2.

  • 3.

  • 4.

  • 5.

  • 6.

  • 7.

 

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

 

复制

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

  • 2.

  • 3.

  • 4.

  • 5.

  • 6.

  • 7.

 

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

复制

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

  • 2.

  • 3.

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

我现在把密码改回去。

复制

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

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

 

复制

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

  • 2.

  • 3.

  • 4.

  • 5.

  • 6.

  • 7.

  • 8.

  • 9.

  • 10.

  • 11.

  • 12.

  • 13.

  • 14.

  • 15.

  • 16.

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

 

复制

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

  • 2.

  • 3.

  • 4.

  • 5.

  • 6.

  • 7.

  • 8.

  • 9.

  • 10.

  • 11.

  • 12.

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

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

【编辑推荐】

  1. MySQL创建远程登陆用户并授权实际操作

  2. MySQL数据库存储引擎的概念与用途

  3. MySQL数据库列值比较与逻辑函数IF简介

  4. 解决MySQL中文乱码的方法归纳

  5. MySQL 安装备份在Linux系统中的安装

9    2010-05-17 13:00:56    MySQL修改用户密码