dgwade Posted March 8, 2003 Share Posted March 8, 2003 I was setting up mySQL on a server of mine, running Red Hat 8, and when I changed the password for the root user, something freaked. I know exactly what was typed in for the password, because it\'s done on the command-line. Is there some kind of file I can get into to change it like on Windows? Thanks forthe help. dgwade Link to comment https://forums.phpfreaks.com/topic/208-mysql-password-freaked-out/ Share on other sites More sharing options...
shivabharat Posted March 8, 2003 Share Posted March 8, 2003 How to Reset a Forgotten Root Password If you never set a root password for MySQL, then the server will not require a password at all for connecting as root. It is recommended to always set a password for each user. See Security. If you have set a root password, but forgot what it was, you can set a new password with the following procedure: 1.Take down the mysqld server by sending a kill (not kill -9) to the mysqld server. The pid is stored in a .pid file, which is normally in the MySQL database directory: shell> kill `cat /mysql-data-directory/hostname.pid` You must be either the Unix root user or the same user mysqld runs as to do this. 2.Restart mysqld with the --skip-grant-tables option. 3.Set a new password with the mysqladmin password command: shell> mysqladmin -u root password \'mynewpassword\' 4.Now you can either stop mysqld and restart it normally, or just load the privilege tables with: shell> mysqladmin -h hostname flush-privileges 5.After this, you should be able to connect using the new password. Alternatively, you can set the new password using the mysql client: 1.Take down and restart mysqld with the --skip-grant-tables option as described above. 2.Connect to the mysqld server with: shell> mysql -u root mysql 3.Issue the following commands in the mysql client: mysql> UPDATE user SET Password=PASSWORD(\'mynewpassword\') -> WHERE User=\'root\'; mysql> FLUSH PRIVILEGES; 4. After this, you should be able to connect using the new password. 5.You can now stop mysqld and restart it normally. MySQL Reference Manual © 2002 MySQL AB Link to comment https://forums.phpfreaks.com/topic/208-mysql-password-freaked-out/#findComment-626 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.