Archive for February 23rd, 2008
Forget mysql root password
Yeah, just now my client contacted me over email, seems there’s a bug on my application
so I need to fix it, it’s Linux + Apache + MySQL + PHP (LAMP). I promised him to fix soon
(because we live in different timezone, he’s in Canada and I’m here at Singapore and I was on bad mood by that time)
Huh, I forget the mysql password…. and he must be sleeping now, so I can’t ask him,
So what’s the solution, because I need to access mysql….
Here what I did (the same with MySQL manual hehehe…):
1. Shutdown mysql first
# /etc/rc.d/init.d/mysqld stop
Stopping MySQL: [ OK ]
2. Run mysql server with option --skip-grant-tables --user=root
(run in background mode please)
# /usr/bin/mysqld_safe --skip-grant-tables --user=root &
Starting mysqld daemon with databases from /var/lib/mysql
3. Connect to mysql using mysql client and execute these SQL statements below:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.20
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';
mysql> FLUSH PRIVILEGES
4. Restart MySQL (this step is optional)
# /etc/rc.d/init.d/mysqld restart
STOPPING server from pid file /var/run/mysqld/mysqld.pid
080223 08:07:23 mysqld ended
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
5. Now our root MySQL server has password 'newpwd'