Page Tools:
Wiki Relationships:
Admin Tools:
Mysql legacy and root password access
by Alan Williamson
If you need to use an old client library with MySQL 5, or you need to reset the password, this article discusses both.
Resetting MySQL root password
1. Log on to your system as either the Unix root user or as the same user that the mysqld server runs as.
2. Locate the .pid file that contains the server's process ID. The exact location and name of this file depend 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. You can stop the MySQL server by sending a normal kill (not kill -9) to the mysqld process, using the pathname of the .pid file in the following command:
shell> kill `cat /mysql-data-directory/host_name.pid`
Note the use of backticks rather than forward quotes with the cat command; these cause the output of cat to be substituted into the kill command.
3. Create a text file and place the following command within it on a single line:
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPassword'); Save the file with any name. For this example the file will be ~/mysql-init.
4. Restart the MySQL server with the special --init-file=~/mysql-init option: shell> mysqld_safe --init-file=~/mysql-init &The contents of the init-file are executed at server startup, changing the root password. After the server has started successfully you should delete
~/mysql-init.
5. You should be able to connect using the new password.
Using older mysql client libraries to access versions 5.x
MySQL 5 introduced a new stronger password authentication for connecting clients. However, it may not always be possible to upgrade a client to the latest. To get around this, when creating the client user in MySQL 5 make sure you use OLD_PASSWORD() to save the password.
Most Recent |
Most Popular |
Most Active Categories |
| Back To Top | Add New Article | Printable Page |

Testing
