Home / Tutorials / 20 MySQL Administration Commands – mysqladmin
MySql Administration

20 MySQL Administration Commands – mysqladmin

mysqladmin is a command-line utility that comes with MySQL server and it is used by Database Administrators to perform some basic MySQL tasks easily such as setting root password, changing root password, monitoring mysql processes, reloading privileges, checking server status etc.

Here we’ve compiled some very useful ‘mysqladmin’ commands that are used by system/database administrators in their day-to-day work. You must have MySQL server installed on your system to perform these tasks.

If you don’t have MySQL server installed or you are using older version of MySQL server, then we recommend you all to install or update your version by following our below article.

How to Install MySQL in RHEL/CentOS/Fedora/Ubuntu

1. How to set MySQL Root password?

If you have fresh installation of MySQL server, then it doesn’t required any password to connect it as root user. To set MySQL password for root user, use the following command.

# mysqladmin -u root password YOURNEWPASSWORD

2. How to Change MySQL Root password?

If you would like to change or update MySQL root password, then you need to type the following command. For example, say your old password is 123456 and you want to change it with new password say xyz123.

mysqladmin -u root -p123456 password 'xyz123'

3. How to check MySQL Server is running?

To find out whether MySQL server is up and running, use the following command.

4. How to Check which MySQL version I am running?

The following command shows MySQL version along with the current running status .

5. How to Find out current Status of MySQL server?

To find out current status of MySQL server, use the following command. The mysqladmin command shows the status of uptime with running threads and queries.

6. How to check status of all MySQL Server Variable’s and value’s?

To check all the running status of MySQL server variables and values, type the following command. The output would be similar to below.

7. How to see all MySQL server Variables and Values?

To see all the running variables and values of MySQL server, use the command as follows.

8. How to check all the running Process of MySQL server?

The following command will display all the running process of MySQL database queries.

9. How to create a Database in MySQL server?

To create a new database in MySQL server, use the command as shown below.

10. How to drop a Database in MySQL server?

To drop a Database in MySQL server, use the following command. You will be asked to confirm press ‘y‘.

11. How to reload/refresh MySQL Privileges?

The reload command tells the server to reload the grant tables. The refresh command flushes all tables and reopens the log files.

12. How to shutdown MySQL server Safely?

To shutdown MySQL server safely, type the following command.

You can also use the following commands to start/stop MySQL server.

13. Some useful MySQL Flush commands

Following are some useful flush commands with their description.

  1. flush-hosts: Flush all host information from host cache.
  2. flush-tables: Flush all tables.
  3. flush-threads: Flush all threads cache.
  4. flush-logs: Flush all information logs.
  5. flush-privileges: Reload the grant tables (same as reload).
  6. flush-status: Clear status variables.

14. How to kill Sleeping MySQL Client Process?

Use the following command to identify sleeping MySQL client process.

Now, run the following command with kill and process ID as shown below.

If you like to kill multiple process, then pass the process ID‘s with comma separated as shown below.

15. How to run multiple mysqladmin commands together?

If you would like to execute multiple ‘mysqladmin‘ commands together, then the command would be like this.

16. How to Connect remote mysql server

To connect remote MySQL server, use the -h (host)  with IP Address of remote machine.

17. How to execute command on remote MySQL server

Let’s say you would like to see the status of remote MySQL server, then the command would be.

18. How to start/stop MySQL replication on a slave server?

To start/stop MySQL replication on salve server, use the following commands.

19. How to store MySQL server Debug Information to logs?

It tells the server to write debug information about locks in use, used memory and query usage to the MySQL log file including information about event scheduler.

20. How to view mysqladmin options and usage

To find out more options and usage of myslqadmin command use the help command as shown below. It will display a list of available options.


About cmadmin

Web Developer & Designer | Android App Developer

Check Also

Top 10 MySQL Mistakes Made By PHP Developers

Top 10 MySQL Mistakes Made By PHP Developers – A database is a fundamental component …

MySQL: Replace string from a column value of all records

UPDATE table_name SET column_name = REPLACE (column_name, 'SearchForThis', ReplaceWithThis') WHERE column_name LIKE '%SearchForThis%'; Related


Create an Account!
Forgot Password? (close)

Sign Up

Confirm Password
Want to Login? (close)

Forget Password?

Username or Email
%d bloggers like this:
To get latest new / tutorial / technology / development information subscribe with us.
Lets Get Updated with latest trends & tutorials!
Your Information will never be shared with any third party.
Ready for latest tutorials & tools !