This is a common problem among programmers who are lazy to remember passwords and finally a reminder machine. but what if the engine suddenly broken and the reminder had no backups. hehehe …. forgotten it. right?
if you forget, reset the root password. easy right? ![]()
problem is how do I reset the root password?
this is the way:
1. we first used to turn off the server, the server did not mean a whole but only mysql service. hehehe …
of course, is how to turn them off from the root linux via the command:
# /etc/init.d/mysql stop
2. then create a sql script to change the password with the command
# vi /root/mysql.reset.sql
or with other commands you like such as pico or nano .
write or fill in the following script:
mysql.user UPDATE SET Password = PASSWORD ( 'my_password') WHERE User = 'root';
GRANT ALL ON *.* TO 'root';
FLUSH PRIVILEGES;
and then save it.
3. sql script is run with the command:
# mysqld_safe --init-file=/root/mysql.reset.sql &
do not forget the “&” in the script terserbut. ok?
then there will be output:
nohup: ignoring input and redirecting stderr to stdout
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[20970]: started
4. restart mysql server
# /etc/init.d/mysql start
ok good luck.
may be useful.

good tutorial