在MySQL中修改一个用户(比如叫"username")的密码.
一.方法1
mysql> UPDATE user SET password=PASSWORD("new password") WHERE user='username';
mysql> FLUSH PRIVILEGES;
mysql> REPLACE INTO mysql.user (Host,User,Password) VALUES('%','username',PASSWORD('password'));
mysql> FLUSH PRIVILEGES;
二.方法2
mysql> SET PASSWORD FOR username=PASSWORD('new password');
mysql> SET PASSWORD FOR username@"%" = PASSWORD('password');
三.方法3
使用命令mysqladmin
mysqladmin -u root -p password mypasswd
四.方法4
使用phpmyadmin,这是最简单的了,修改mysql库的user表,必须使用PASSWORD函数
五.增加用户
mysql> GRANT USAGE ON *.* TO username@"%" IDENTIFIED BY 'password';
mysql> GRANT RELOAD,PROCESS ON *.* TO username@localhost;
mysql>GRANT ALL PRIVILEGES ON *.* TO username@"%" IDENTIFIED BY 'something' WITH GRANT OPTION;
mysql>GRANT ALL PRIVILEGES ON *.* TO username@localhost IDENTIFIED BY 'something' WITH GRANT OPTION;