作者justoncetime (想买xperia TX ~)
看板Database
标题Re: [SQL ] 最高权限下修改其他使用者的密码
时间Sat Mar 23 19:34:49 2013
※ 引述《sunnyboy1030 (桑尼(Sunny))》之铭言:
: 如题,想请问高手,如果我在root的帐号底下,
: 想要修改其他使用者的密码,这样指令应该如何下达?
: use mysql;
: UPDATE user SET password=password('新密码') where user='欲修改的帐号';
: FLUSH PRIVILEGES;
: 我是这样下达指令的,可是却没办法修改成功。
: 请问问题出在哪里呢?
: 错误
: SQL 语法:
: FLUSH PRIVILEGES ;
: MySQL 传回:
: #1064 - You have an error in your SQL syntax; check the manual that
: corresponds to your MySQL server version for the right syntax to
: use near 'FLUSH PRIVILEGES' at line 1
错误讯息指出是FLUSH PRIVILEGES的问题,但看起来OK没打错。
唯一想到的可能性, 是您执行flush的帐号并没有RELOAD权限
(这必须实际看到user table才能确认, 在网路上是猜不出来的)
http://dev.mysql.com/doc/refman/5.0/en/flush.html
The FLUSH statement has several variant forms that clear or reload
various internal caches, flush tables, or acquire locks. To execute
FLUSH, you must have the RELOAD privilege.
承上, 确认的方式可以登入时 SHOW PRIVILEGES ;
| Privilege | Context | Comment
+ (部份内容省略)
| Reload | Server Admin | To reload or refresh tables, logs (略)
或是 USE mysql ;
SELECT Host, User, Reload_priv FROM user ;
如果有RELOAD权限, 则Reload_priv栏为Y
+-------------+------+-------------+
| Host | User | Reload_priv |
+-------------+------+-------------+
| 127.0.0.1 | root | Y |
| 192.168.1.2 | nina | N |
+-------------+------+-------------+
2 rows in set (0.00 sec)
请注意您当时登入的帐号, source IP必须吻合Host栏,帐号符合User栏。
※ 编辑: justoncetime 来自: 122.116.53.137 (03/23 19:43)