MySQL中常用工具

mysql 

语法

mysql [options] [database]
#连接选项
-u, --user=name 用户名
-p, --password  密码
-h, --host      服务器IP
-p, --port      指定端口

#执行选项
-e, --execute   执行的sql语句

 

 mysqladmin

 mysqladmin是一个执行管理操作的客户端程序。可以用来检查服务器的配置和当前状态,创建并删除数据库等

mysqladmin --help
.......................
  create databasename	  Create a new database
  debug			  Instruct server to write debug information to log
  drop databasename	  Delete a database and all its tables
  extended-status         Gives an extended status message from the server
  flush-all-statistics    Flush all statistics tables
  flush-all-status        Flush status and statistics
  flush-client-statistics Flush client statistics
  flush-hosts             Flush all cached hosts
  flush-index-statistics  Flush index statistics
  flush-logs              Flush all logs
  flush-privileges        Reload grant tables (same as reload)
  flush-binary-log        Flush binary log
  flush-engine-log        Flush engine log(s)
  flush-error-log         Flush error log
  flush-general-log       Flush general log
  flush-relay-log         Flush relay log
  flush-slow-log          Flush slow query log
  flush-status            Clear status variables
  flush-table-statistics  Clear table statistics
  flush-tables            Flush all tables
  flush-threads           Flush the thread cache
  flush-user-statistics   Flush user statistics
  flush-user-resources    Flush user resources
  kill id,id,...	Kill mysql threads
  password [new-password] Change old password to new-password in current format
  old-password [new-password] Change old password to new-password in old format
  ping			Check if mysqld is alive
  processlist		Show list of active threads in server
  reload		Reload grant tables
  refresh		Flush all tables and close and open logfiles
  shutdown		Take server down
  status		Gives a short status message from the server
  start-slave		Start slave
  stop-slave		Stop slave
  variables             Prints variables available
  version		Get version info from server

 示例

mysqladmin -uroot -p123 create "test_date";
mysqladmin -uroot -p123 drop "test_date";

 

mysqlbinlog 

由于服务器生成的二进制日志文件是以二进制格式保存的,使用如果想要检查这些文本的文本格式,就会使用mysqlbinlog日志管理工具

语法

mysqldump [options]  da_name[table]

mysqldump [options]  --database/-B db1 .....

mysqldump [option] --all-databases/-A

 输出内容选项

参数
--add-drop-database 在每个数据库创建语句前加上Drop database语句

--add-drop-table 在每个表创建语句前加上 Drop table 语句,默认开启,不开启(--skip-add-drop-table)

-n, --no-create-db  不包含数据库的创建语句
-t, --no-create-info  不包含数据表的创建语句
-d, --no-data     不包含数据

-T,--tab 自动生成两个文件:一个.sql文件,创建表的语句。一个.txt文件数据文件,相当于select into outfile.

 

 mysqlimport/source 

mysqlimport是客户端数据导入工具,用来导入mysqldump加-T参数后导出的txt文本文件。

 语法

mysqlimport [options] db_name textfile1 ....

 如果想导入.sql则在数据库中使用source

source  /path/*.sql

 

mysqlshow 

mysqlshow客户端对象查找工具,用来很快的查找存在哪些数据库、数据中的表、列或索引等。

语法

mysqlshow [options] [db_name [table_name[col_name]]]

参数
--count 显示数据库及表的统计信息(数据库,表均可不指定)
-i 显示指定数据库或者指定表的状态信息

 

posted @ 2021-05-29 18:50  第七爻  阅读(250)  评论(0编辑  收藏  举报