For many user that forget or can not access to
mysql root by command can fix problem by step like
golfreeze[at]packetlove.com
1. # Login as root to the Windows or Unix-like (Unix, Linux or BSD) machine with the MySQL server.
2.# Stop the MySQL server by using either of the following command:
Linux: /etc/rc.d/init.d/mysql stop
FreeBSD: /usr/local/etc/rc.d/mysql-server.sh stop
3.# Open the mysql server startup script (i.e. mysql-server.sh - the file executed to start or stop
MySQL server.
4.# Add "skip-grant-tables" to the end of the line that contains the mysqld_safe command as
its parameter.
5.# Start MySQL server with the following command:
Linux: /etc/rc.d/init.d/mysql start
FreeBSD: /usr/local/etc/rc.d/mysql-server.sh start
6.# Alternatively, start the MySQL server directly and skip the editing with the following command:
mysqld_safe --skip-grant-tables &
Depending on your path environment, you may need to point to the correct directory where mysqld_safe
is instead.
7. # Run the following commands to login as the mysql user and connect to mysql user/permission
database:
8. # mysql -u root mysql
9.# Run the update queries to change the MySQL password:
mysql> UPDATE user SET Password=PASSWORD('newrootpassword') WHERE
User='root';
mysql> FLUSH PRIVILEGES;
10. complete try to delete skip-grant-tables from
/usr/local/etc/rc.d/mysqld and then start mysql server and login to check.