用MYSQLADMIN改用户密码

新手在这个上往往容易范错误,导致不能进入MYSQL,整得非常郁闷。
我来做几个例子相信非常快就明白了 。
1、原来的密码是123456
C:>type mysql5.bat@echo offmysql -uroot -p123456 -P3306
正确的修改MYSQL用户密码的格式是:
我们这里用
用户:root(能换成其他的)
密码:woshiduide
来演示新密码。
C:>mysqladmin -uroot -p password woshiduideEnter 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 commandline 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 18Server 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: YES)
所以非常郁闷,BAIDU、GOOGLE的搜了一大堆。
我目前把密码改回去。
C:>mysqladmin -uroot -p’woshiduide’ password 123456
2、更有就是能直接进入MYSQL,然后修改密码。
mysql> use mysqlDatabase changedmysql> update user set PASSWORD = PASSWORD(’woshiduide’) where USER=’root’ and HOST=’localhost’;Query OK, 1 row affected (0.05 sec)Rows matched: 1  Changed: 1  Warnings: 0mysql> flush privileges;mysql> exitBye
C:>mysql -uroot -pwoshiduideWelcome to the MySQL monitor.  Commands end with ; or g.Your MySQL connection id is 23Server 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)
3、更有一种就是用SET PASSWORD 命令修改:
C:>mysql5.batEnter password: ******Welcome to the MySQL monitor.  Commands end with ; or g.Your MySQL connection id is 8Server 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> exitBye
4、GRANT 也能,不过这里不介绍。因为涉及到权限的问题。

http://www.sudu.cn/info/html/edu/20070101/283551.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值