Database Administration

The mysqladmin Utility


The mysqladmin is the primary tool for database administration. Using this utility, you can create, destroy, and monitor your server and the databases it supports. You can issue multiple commands at one time with the mysqladmin utility. Its general format is

mysqladmin options command1 command2 ... commandn

Changing the password


To change the password for the MySQL server, use the following command:

mysqladmin -u username password 'newpassword'
When you have a fresh MySQL installation up and running, the first thing you should do is change the root password.
 

Database Creation


You can create a new database using the following command:

mysqladmin -u username -p create databasename
The -p option tells MySQL that you want to be prompted for the root password.
 

Database destruction


You can delete (drop) a database using the following command:

mysqladmin -u username -p drop databasename

Server shutdown


The following command will perform a clean shutdown of the MySQL database server:

mysqladmin  -u username -p shutdown

Reload


The following command will reload all grant tables:

mysqladmin  -u username -p reload
Note: flush-privileges command does the same.
 

Server version


The following command will display server version information:

mysqladmin -u username -p version


The mysqladmin utility is a rich tool with handful of command line options. Use the following command to get all the a list of all the commands and options it supports.

mysqladmin --help