登录|使用QQ帐号登录
论坛首页 > 程序技术
发帖|
看9602|回0|收藏
admin 看全部
2013-1-25 17:37:20
其实手册里有的,只是现在这个年代,似乎大家都不看手册啦,而是在QQ或者群里又或者论坛发问
   为什么不用搜索?

方法一:
(适用于管理员或者有全局权限的用户重设其它用户的密码)
进入命令行模式
mysql -u root mysql
mysql> UPDATE user SET password=PASSWORD("new password") WHERE user='name';
  mysql> FLUSH PRIVILEGES;
  mysql> QUIT
方法二:
(应用同上,只是方法不同)
mysql -u root mysql
  mysql> SET PASSWORD FOR name=PASSWORD('new password');
  mysql> QUIT
(以上两种方法我不常用,如果是管理员,我会用其它如phpmyadmin或者MYSQL-front 等工具来管理用户权限,比较直观又方便)
最后必杀技:
mysqladmin -u root "old password" "new password"
解:以上有name的,请用你的用户名来替代.有new password请输入你想要设置的密码.

提示错误:No Database Selected后如何修改

C:\mysql\bin>mysql
-uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 4.0.15-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> update user set password=password('root') where user='root';
ERROR 1046: No Database Selected
mysql> use mysql
Database changed
mysql> select host,user from user;
+-----------+------+
| host      | user |
+-----------+------+
| %         |      |
| %         | root |
| localhost |      |
| localhost | root |
+-----------+------+
4 rows in set (0.02 sec)

mysql> update user set password=password('root') where user='root';
Query OK, 2 rows affected (0.00 sec)
Rows matched: 2  Changed: 2  Warnings: 0

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.02 sec)

mysql> quit
Bye

C:\mysql\bin>mysql  -uroot
ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)

C:\mysql\bin>mysql  -uroot -proot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6 to server version: 4.0.15-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> quit
Bye

绵阳网站建设

Powered by Discuz! X3.4

首页|标准版|触屏版|电脑版