你应该弄一份MySql reference manual在手,2.9.3. Securing the Initial MySQL Accounts有详细的介绍,给这位兄弟摘录3种方法: 1)To assign passwords using SET PASSWORD, connect to the server as root and issue two SET PASSWORD statements. Be sure to encrypt the password using the PASSWORD() function. For Windows, do this: shell> mysql -u root mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpwd'); 2)To assign passwords to the root accounts using mysqladmin, execute the following commands: shell> mysqladmin -u root password "newpwd" 3)You can also use UPDATE to modify the user table directly. The following UPDATE statement assigns a password to both root accounts at once: shell> mysql -u root mysql> UPDATE mysql.user SET Password = PASSWORD('newpwd') -> WHERE User = 'root'; mysql> FLUSH PRIVILEGES;
1)To assign passwords using SET PASSWORD, connect to the server as root and issue two SET PASSWORD statements. Be sure to encrypt the password using the PASSWORD() function. For Windows, do this: shell> mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpwd');
2)To assign passwords to the root accounts using mysqladmin, execute the following commands: shell> mysqladmin -u root password "newpwd"
3)You can also use UPDATE to modify the user table directly. The following UPDATE statement assigns a password to both root accounts at once: shell> mysql -u root
mysql> UPDATE mysql.user SET Password = PASSWORD('newpwd')
-> WHERE User = 'root';
mysql> FLUSH PRIVILEGES;