MySQL社区

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

搜索
查看: 4447|回复: 1
打印 上一主题 下一主题

用MYSQLADMIN改用户密码

[复制链接]
跳转到指定楼层
1#
发表于 2007-9-4 12:19:23 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
来自博客:骑上帝他老婆做软件
上帝他老婆做软件
新手在这个上往往容易范错误,导致不能进入MYSQL,整得非常郁闷。
我来做几个例子相信很快就明白了

1
、原来的密码是123456
C:\>type mysql5.bat
@echo off
mysql -uroot -p123456 -P3306

正确的修改MYSQL用户密码的格式是:
我们这里用
用户:root(可以换成其他的)
密码:woshiduide
来演示新密码。

C:\>mysqladmin -uroot -p password woshiduide
Enter password: ******

于是修改成功。
注意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.

而这个时候真正的密码是'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>


而新手往往这样:
C:\>mysql -uroot -pwoshiduide
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: Y
ES)

所以非常郁闷,BAIDUGOOGLE的搜了一大堆。
我现在把密码改回去。
C:\>mysqladmin -uroot -p'woshiduide' password 123456

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

mysql> use mysql
Database changed
mysql> update user set PASSWORD = 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)
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
收藏收藏 分享淘帖 顶 踩
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|申请友链|小黑屋|Archiver|手机版|MySQL社区 ( 京ICP备07012489号   
联系人:周生; 联系电话:13911732319

GMT+8, 2024-4-19 19:09 , Processed in 0.065518 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表