|
|
发表于 2004-4-20 04:47:32
|
显示全部楼层
Log onto your system as either the Unix root user or as the same user that the mysqld server runs as.
Locate the `.pid' file that contains the server's process ID. The exact location and name of this file depends on your distribution, hostname, and configuration. Common locations are: `/var/lib/mysql/', `/var/run/mysqld/' and `/usr/local/mysql/data/'. Generally, the filename has the extension of `.pid' and begins with either `mysqld' or your system's hostname. Now you can stop the MySQL server by sending a normal kill (not kill -9) to the mysqld process, using the name of the `.pid' file in the following command:
shell> kill `cat /mysql-data-directory/hostname.pid`
Note the use of backquotes rather than forward quotes with the cat command; these cause the output of cat to be substituted into the kill command.
Restart the MySQL server with the special --skip-grant-tables option:
shell> mysqld_safe --skip-grant-tables &
Set a new password for the root@localhost MySQL account:
shell> mysqladmin -u root flush-privileges password "newpwd"
Replace ``newpwd'' with the actual root password that you want to use.
You should now be able to connect using the new password.
Alternatively, you can set the new password using the mysql client:
Stop mysqld and restart it with the --skip-grant-tables option as described earlier.
Connect to the mysqld server with this command:
shell> mysql -u root
Issue the following statements in the mysql client:
mysql> UPDATE mysql.user SET Password=PASSWORD('newpwd')
-> WHERE User='root';
mysql> FLUSH PRIVILEGES;
Replace ``newpwd'' with the actual root password that you want to use.
You should now be able to connect using the new password. |
|