How to use mysqladmin command in Linux

How to use mysqladmin command in Linux
How to use mysqladmin command in Linux

How to use mysqladmin command in Linux Introduction

Mysqladmin command is used for administrating mysql server. With the help of this command you can configure the mysql server, you can create database, drop database, you can also see the current status and processes running in the mysql server. This is a very useful command for administrating mysql.

 


1. How to know the version of your mysql server in Linux

To see the current version of your mysql server use the following command.

# mysqladmin -u root -p version 
Enter password:
How to know the version of mysql server
How to know the version of mysql server

 

2. How to know the status of mysql server

To know the status of the mysql server, like uptime, queries, etc. use the following command.

# mysqladmin -u root -p status

Enter password:
Uptime: 6505 Threads: 1 Questions: 6 Slow queries: 0 Opens: 67 Flush tables: 1 Open tables: 60 Queries per second avg: 0.000

3. How to change mysql server root password in Linux

You can change your mysql server root password with this command given below.

# mysqladmin -u root -p password
Enter password: 
New password: 
Confirm new password:

4. How to find out your mysql server is up or down?

To find out your mysql server up, down or alive use the following command.

# mysqladmin -u root -p ping
Enter password: 
mysqld is alive

5. How to find out current running processes of mysql server

There can be number of processes running in the mysql server. To check how many processes are currently running on your mysql server use the below command.

# mysqladmin -u root -p processlist
How to find out current running processes of mysql server
How to find out current running processes of mysql server

 

6. How to create database in mysql with mysqladmin command

You can create database in mysql server with the following command.

 mysqladmin -u root -p create <database-name>

# mysqladmin -u root -p create database1
Enter password:

 

7. How to drop database in mysql with mysqladmin command

To drop a database use the following command.

 mysqladmin -u root -p <database-name>

# mysqladmin -u root -p drop database1
How to drop database in mysql with mysqladmin command
How to drop database in mysql with mysqladmin command

 

8. How to shutdown mysql server

You can even shutdown your mysql server wit the following command.

# mysqladmin -u root -p shutdown

 

9. How to kill a sleeping process in mysql

Check the process id in mysql server with the 'processlist' command

# mysqladmin -u root -p processlist

To kill the sleeping process use the below command.

# mysqladmin -u root -p kill <process-id>

10. How to connect to a remote mysql server with mysqladmin command

To connect to a remote mysql server use the following command.

# mysqladmin -h 192.168.1.129 -u root -p

11. How to run command on remote mysql server

You can run command on the remote mysql server with the following command.

# mysqladmin -h 192.168.1.129 -u root -p version

12. How to shutdown your mysql server with mysqladmin

With the 'shutdown' command you shutdown the mysql server.

# mysqladmin -u root -p shutdown

13. How to reload mysql server

To reload the mysql server use the below command.

# mysqladmin -u root -p reload

14. How to refresh mysql privileges in mysql server

To refresh mysql privileges use this command.

# mysqladmin -u root -p refresh

15. How to use mysqladmin flush-hosts command

To flush all the information present in the host cache use 'flush-hosts'.

# mysqladmin -u root -p flush-hosts

16. How to use mysqladmin flush-table command

The below command will flush all the tables.

# mysqladmin -u root -p flush-tables

17. How to use mysqladmin flush-logs command

To flush all the logs present in the mysql server use the following command.

# mysqladmin -u root -p flush-logs

18. How to use mysqladmin flush-privileges command

If you want to flush all the assigned privileges and reload the grant tables use the below command.

# mysqladmin -u root -p flush-privileges

19. How to use mysqladmin flush-status command

This below command is used to clear the status variables.

# mysqladmin -u root -p flush-status

20. How to check all the running status of mysql server

With the below command you can see the running status of mysql server variables and values.

# mysqladmin -u root -p extended-status

How to check all the running status of mysql server
How to check all the running status of mysql server

 

21. How to run multiple command in your mysql server

You can also run multiple command in mysql server with mysqladmin command. See the below example.

# mysqladmin -u root -p version ping status

 

How to run multiple command in mysql server
How to run multiple command in mysql server

 


That's all about how to use mysqladmin command in Linux.

 

Download Our Free eBook now

Linux and UNIX Shell scripting ebook

Be the first to comment

Leave a Reply

Your email address will not be published.


*


shares