Change root password for mysqld on Fedora Core.

cms technology web page configuration drupal web site
Setup and configuration of cms and drupal web site

The article below show step by step procedure how to change the current root password for MYSQLd (MYSQL server). This procedure can be done only when you know the current root password for MSQLd server; The step by step command below execute and tested on Fedora Core 6 using Ver 14.12 Distrib 5.0.27.

[root@tenouk ~]# mysql --user=root --pass mysql

Enter password: [Enter your MYSQL root password here, then hit enter key]

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A


Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 1 to server version: 5.0.27


Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

[Use and executet MYSQL command below and put your new password for MYSQL root user]

mysql> update user set Password=PASSWORD('your-new-mysql-password') WHERE User='root';

Query OK, 2 rows affected (0.01 sec)

Rows matched: 2 Changed: 2 Warnings: 0

[To apply changes make sure you execute the command below]

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)


mysql> exit

Bye

[root@tenouk ~]#

Execute the exit command to exit from MYSQL. Now everything should be OK...

To verify you MYSQL root password changes:

 

[root@tenouk ~]# mysql --user=root --pass=your-new-mysql-password

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 2 to server version: 5.0.27


Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> exit

Bye

[root@tenouk ~]#

USING:

MySQL version:

[root@tenouk ~]# mysql --version

mysql Ver 14.12 Distrib 5.0.27, for redhat-linux-gnu (i686) using readline 5.0

Fedora Core 6 version:

[root@tenouk ~]# uname -sir

Linux 2.6.18-1.2869.fc6xen i386



Reset MySQLd root password.

This article show the step by step to reset the mysql root password, the procedure can be use to change the root password of mysql if the root password is forgotten, lost or misplaced. 

1.  Checking MySQLd service status:

[root@fedoracore ~]# service mysqld status

mysqld (pid 12036) is running...

=======================================
2.  STOPING MYSQLD service:

[root@fedoracore ~]# service mysqld stop

STOPPING server from pid file /var/run/mysqld/mysqld.pid

070207 06:51:09  mysqld ended

Stopping MySQL:                                            [  OK  ]

or

[root@fedoracore ~]# /etc/init.d/mysqld stop

Stopping MySQL:                                            [  OK  ]

 ==============================

3.  Verify that MySQLd stoped:

[root@fedoracore ~]# service mysqld stop

Stopping MySQL:                                            [FAILED]

===============================================================

4.  Start MySQL in safe mode and not read the database password:

[root@fedoracore ~]# mysqld_safe --skip-grant-tables &

[1] 14074

[root@fedoracore ~]# Starting mysqld daemon with databases from /var/lib/mysql

OR

[root@fedoracore ~]# /usr/bin/mysqld_safe --skip-grant-tables &

[1] 12360

[root@fedoracore ~]# Starting mysqld daemon with databases from /var/lib/mysql

================================================
5.  Enter MySQL using root user:

[root@fedoracore ~]# mysql --user=root mysql

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1 to server version: 5.0.22

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> update user set Password=PASSWORD('new-password-here') WHERE User='root';

Query OK, 2 rows affected (0.02 sec)

Rows matched: 2  Changed: 2  Warnings: 0

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> exit

Bye

[root@fedoracore ~]#

================================================

6.  Kill (stop) the MySQL server (mysqld_save):

[root@fedoracore ~]# fg

mysqld_safe --skip-grant-tables

[1]+  Stopped                 mysqld_safe --skip-grant-tables

Use Crrl+z key

[root@fedoracore ~]#

and

[root@fedoracore ~]# service mysqld stop

Stopping MySQL:                                            [FAILED]

[root@fedoracore ~]# service mysqld status

mysqld is stopped

[root@fedoracore ~]#

===================================================

7.  Restart the MySQL server:

[root@fedoracore ~]# /etc/rc.d/init.d/mysqld start

Starting MySQL:                                            [  OK  ]

[root@fedoracore ~]#

or

[root@fedoracore ~]# service mysqld start

Starting MySQL:                                            [  OK  ]

[root@fedoracore ~]#

=====================================================

8.  TEsting and verify using the new root password:

[root@fedoracore ~]# mysql -u root -p

Enter password: [Enter Your New Root Password]

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 2 to server version: 5.0.22

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

Wink

Custom Search