How to change MYSQL Root Password on Linux Distributions like CENTOS, REDHAT, FEDORA, UBUNTU, FREEBSD and other Unix – Linux based Operating system.
By default when you install a new Operating System any of the linux variants the best way to install MYSQL would be using yum for RPM based distros or apt-get for debian based distros.
yum install mysql*
apt-get install mysql
After successful installation you would need to start the service if its not running the following command would suffice and start the MYSQLD Daemon
service mysqld start
or
/etc/init.d/mysqld start
Now try to login to mysql to create your first Database, you can do this simply by using the below command on the terminal. You would be Amazed that you really do not require any password to login, just press enter thats it you are in the mysql prompt,
[ashwin@linuxmaza ~]$ mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 404516 Server version: 5.0.85-community MySQL Community Edition (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
But now that sounds unsafe, potential harm to the server, or even security of the application running on the system could be hampered. How to tackle could be big mystery or question but resolving it is a small process and non lengthy, Follow along and in no time you would see mysql not letting you in without password or authentication.
By default when mysql is installed it doesn’t require any password, but you can update it. To change the root password for mysql on the CLI (Terminal Shell)
[ashwin@linuxmaza ~]$ mysqladmin -u root password YOUR_NEW_PASSWORD
Now try login to mysql as you did earlier and see what happens you would be prompted to put the root password (Do not put anything) just press enter as you did it previously it would spit out a error of “Access Denied”.
[ashwin@linuxmaza ~]$ mysql -uroot -p Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Now try the new password instead of simply pressing the Enter which you have changed in the earlier step
[ashwin@linuxmaza ~]$ mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 404518 Server version: 5.0.85-community MySQL Community Edition (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
Now that’s easy right, what if i want to change the root password, as somebody has seen it over your shoulder, how do i change so simple
[ashwin@linuxmaza ~]$ mysqladmin -u root -p'OLDPASSWORD' password NEWPASSWORD
Now just try it out the simple steps to change MYSQL root Password and post comments if you stuck up at any place.
For More tutorials Visit Linux Tutorials
Related posts:
- Checking if MYSQL is 32Bits or 64Bits? Do you know MYSQL installed on your system is MYSQL...
- How to Change System Timezone on Linux Distros – Centos, Ubuntu, Redhat, Fedora Many a times after initial installation of Linux operating system...
- How to sent Message through Terminal to a Login users In Fedora, Centos, RedHat, Ubuntu. You can broadcast a message using WALL — How to...
- Howto Install RED5 Flash Media Server in Fedora 11, Centos 5.4, Redhat Red5 is an Open Source Flash Media Server written in...
- Howto Add New User, New Group and modify Users, Groups in Linux – Centos5.4, Fedora 11 – Part 1 Adding users in Linux helps you from giving all user...



