The Mysql root password can be set using the following procedure:
1.
Stop the MySQL service:
# service mysqld stop
Example output:
#service mysqld stop
Stopping MySQL: [OK]
2.
Start MySQLwith:
# /usr/bin/safe_mysqld --skip-grant-tables &
On Red Hat Enterprise Linux 4, safe_mysqld has been changed to mysqld_safe.
Note: safe_mysqld is a shell script which invokes mysqld, but additionally traps any forceful
terminations of the MySQL server and avoids any database corruption.
3.
Change the password of the root user:
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('new_password') WHERE user='root'
mysql> FLUSH PRIVILEGES;
mysql> exit;
4.
You could perform Step 1 here and avoid using step 4, but in some cases, the startup script may not
behave as expected since mysqld was started directly, i.e. not using the init script.
# mysqladmin shutdown
5.
Start the MySQL service:
# service mysqld start
Example output:
# service mysqld start
Starting MySQL: [ OK ]
No comments:
Post a Comment