1. Stop MySQL server
# /usr/local/etc/rc.d/mysql-server stop
2. Start MySQL server with skip grant table mode
# mysqld_safe –skip-grant-tables &
Output:
[1] 5187
# Starting mysqld daemon with databases from /var/db/mysql
3. Login as user root without password
# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
mysql>
4. Set up the new root password
mysql> update user set password=password(’newpassword’) where user=’root’;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
5. Stop MySQL server
# /usr/local/etc/rc.d/mysql-server stop
6. Start MySQL server
# /usr/local/etc/rc.d/mysql-server start
No comments:
Post a Comment