Datareign

MySQL comes with the root user set up by default but without a password. Hence, with a brand new installation you can do this:

 Unix>mysql -u root
 Welcome to the MySQL monitor.  Commands end with ; or \g.
 Your MySQL connection id is 1
 Server version: 5.0.51b Source distribution
 
 Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
  
 mysql> 
 

Yep, you're into the database manager as the boss user without having to go through any security. As the root user can do anything he wishes in MySQL, this is a bad thing!

Setting the root password for the first time

This requires a single call to the mysqladmin utility:

 mysqladmin -u root password starw78tes

and now, when you try to log in without a password:

 Unix>mysql -u root
 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
 Unix>

…which has to be a lot better.

Changing the root password

Once again, you invoke mysqladmin:

 Unix>mysqladmin -u root -p starw78tes h3r0efr3d

…and the password will now be h3r0efr3d.

Last modified: 2009/01/03 19:16