Change or Set the MySQL Root password

For every database, you should set the root or sa passwords to something other than the default, unless you want to get hacked. For mysql, the system administrator user is called root. You will use the mysqladmin utility from a command line to set the new password. Notice that there are two commands to be run.

Syntax:

mysqladmin -u root password “newpassword”

mysqladmin -u root -h host_name password “newpassword”

Example:

mysqladmin -u root password ws8dr8as3

mysqladmin -u root -h localhost password ws8dr8as3

You will also want to restart the database server after running this command

sudo /etc/init.d/mysql restart

Lowell Heddings, better known online as the How-To Geek, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on if you'd like.

  • Published 09/11/06
More Articles You Might Like

Enter Your Email Here to Get Access for Free:

Go check your email!