liminche
liminche

Reputation: 271

Mysql: how to get the mysql status info just using one command

I have installed mysql-server on ubuntu. If I want to know the status of the mysql, I need to type 'mysql -u root -p' in the command line, and then I need to type the password to enter the mysql interaction mode, finally in the interaction mode I need to type 'show status' and I can see the info. Now my question is, is there any method doesn't need to enter the mysql interaction mode, just type one command in the command line and get the mysql status info?

Upvotes: 1

Views: 821

Answers (1)

taliezin
taliezin

Reputation: 916

You can use:

mysql -p'password' -e "SHOW STATUS"

Where -e flag is:

-e, --execute=name Execute command and quit. (Disables --force and history file.)

If you don't want to use password as of mysql documentation you can store your password in an option file (Note to change permissions respectively):

Store your password in an option file. For example, on Unix, you can list your password in the [client] section of the .my.cnf file in your home directory:

[client]
password=your_pass

So finally you have to run:

mysql -e "SHOW STATUS"

Upvotes: 1

Related Questions