Linux: /etc/rc.d/init.d/mysql stop
FreeBSD: /usr/local/etc/rc.d/mysql-server.sh stop
Linux: /etc/rc.d/init.d/mysql start
FreeBSD: /usr/local/etc/rc.d/mysql-server.sh start
mysqld_safe –skip-grant-tables &
Depending on your path environment, you may need to point to the correct directory where mysqld_safe is instead.
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD(’newrootpassword’) WHERE User=’root’;
mysql> FLUSH PRIVILEGES;
Note: Replace newrootpassword with the new root password for MySQL server. Flush Privileges is needed to making the password change effect immediately.
For Redhat Linux users, use the following instructions as the root user of Redhat Linux machine:
# killall mysqld
# /usr/libexec/mysqld -Sg –user=root &
# mysql
You should see the following message:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1 to server version: 3.xx.xx
Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the buffer.
mysql>
mysql> USE mysql
You should see the following message:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
UPDATE user SET password=password(”newpassword”) WHERE user=”root”;
Replace newpassword with your desired password. You should see the following message:
Query OK, 2 rows affected (0.03 sec)
Rows matched: 2 Changed: 2 Warnings: 0
Rows affected may be different, but the Query OK should be there.
mysql> flush privileges;
You should get the following result:
Query OK, 0 rows affected (0.02 sec)
/etc/init.d/mysqld start