查看mysql运行状态的命令是什么?

查看mysql运行状态的命令是什么?,第1张

一、用phpMyAdmin进行查看

二、用命令行的SHOW 语句

直接在命令行下登陆MySQL运行SHOW STATUS查询语句

同样的语句还有SHOW VARIABLES,SHOW STATUS是查看MySQL运行情况,和上面那种通过pma查看到的信息基本类似。

SHOW VARIABLES

SHOW VARIABLES是查看MySQL的配置参数,还可以使用类似SHOW VARIABLES LIKE ‘Key%’

SHOW PROCESSLIST

SHOW PROCESSLIST是查看当前正在进行的进程,对于有锁表等情况的排查很有用处。一般情况下,打开MySQL的慢查询记录同样有利于排查。

SHOW OPEN TABLES

SHOW OPEN TABLES是显示当前已经被打开的表列表。

三、用MySQL自带工具mysqladmin 查看

使用MySQL自带的mysqladmin 工具查看status,使用以下命令

mysqladmin -uroot -p密码 status

显示的结果如下:

Uptime: 502963 Threads: 2 Questions: 8561820 Slow queries: 734681 Opens: 553

45 Flush tables: 1 Open tables: 85 Queries per second avg: 17.023

另外可以添加 -i 5 参数,让其每五秒自动刷新之。

mysqladmin -uroot -p密码 status -i 5

mysqladmin extended-status

同样的可以使用mysqladmin -uroot -p密码 extended-status来查看更多的MySQL运行信息,这种方式和第一种查看的信息基本一样。

我也被这个问题困扰了,刚才看了flweb的回答得到启发。感谢flweb!

进入命令行即cmd中,进入到安装了mySql的路径下,我的是

C:\Program Files\MySQL\MySQL Server 5.1\bin>

C:\Program Files\MySQL\MySQL Server 5.1\bin>mysql

ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: N

O)

直接输入mysql得到错误提示,拒绝访问。因为没有输入密码。由此可以知道默认的用户是ODBC。

C:\Program Files\MySQL\MySQL Server 5.1\bin>mysqlshow

mysqlshow: Access denied for user 'ODBC'@'localhost' (using password: NO)

直接输入mysqlshow得到错误提示,拒绝访问。因为没有输入密码。

C:\Program Files\MySQL\MySQL Server 5.1\bin>mysqlshow -u root -p 123456

Enter password: ******

mysqlshow: Unknown database '123456'

mysqlshow的意思是显示该用户下的数据库,-u 后跟用户,-p表示要输入密码,但其后如果

有东西那么表示的是数据库的名称而不是叫我们输入密码,密码输入执行这条指令后会提示

输入密码。

C:\Program Files\MySQL\MySQL Server 5.1\bin>mysqlshow -u root -p

Enter password: ******

+--------------------+

| Databases |

+--------------------+

| information_schema |

| mysql |

| test |

+--------------------+

上面就达到了我们的目的。

C:\Program Files\MySQL\MySQL Server 5.1\bin>mysqlshow -u root -p test

Enter password: ******

Database: test

+--------+

| Tables |

+--------+

+--------+

这条指令的功能是显示test的数据库的内容。

执行下面这条指令后就可以开始我们的mysql之旅了。

C:\Program Files\MySQL\MySQL Server 5.1\bin>mysql -u root -p

Enter password: ******

Welcome to the MySQL monitor. Commands end with or \g.

Your MySQL connection id is 24

Server version: 5.1.50-community MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

This software comes with ABSOLUTELY NO WARRANTY. This is free software,

and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help' or '\h' for help. Type '\c' to clear the current input statement.

mysql>\h 显示帮助

For information about MySQL products and services, visit:

http://www.mysql.com/

For developer information, including the MySQL Reference Manual, visit:

http://dev.mysql.com/

To buy MySQL Enterprise support, training, or other products, visit:

https://shop.mysql.com/

List of all MySQL commands:

Note that all text commands must be first on line and end with ''

? (\?) Synonym for `help'.

clear (\c) Clear the current input statement.

connect (\r) Reconnect to the server. Optional arguments are db and host.

delimiter (\d) Set statement delimiter.

ego (\G) Send command to mysql server, display result vertically.

exit (\q) Exit mysql. Same as quit.

go(\g) Send command to mysql server.

help (\h) Display this help.

notee (\t) Don't write into outfile.

print (\p) Print current command.

prompt(\R) Change your mysql prompt.

quit (\q) Quit mysql.

rehash(\#) Rebuild completion hash.

source(\.) Execute an SQL script file. Takes a file name as an argument.

status(\s) Get status information from the server.

tee (\T) Set outfile [to_outfile]. Append everything into given outfile.

use (\u) Use another database. Takes database name as argument.

charset (\C) Switch to another charset. Might be needed for processing binlog

with multi-byte charsets.

warnings (\W) Show warnings after every statement.

nowarning (\w) Don't show warnings after every statement.

For server side help, type 'help contents'

mysql>\q 退出mysql

Bye


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/7305681.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-04
下一篇 2023-04-04

发表评论

登录后才能评论

评论列表(0条)

保存