mysql客户端工具使用
2016-04-23 22:43
597 查看
mysqladmin是个客户端的管理工具,使用的方式如下:
不知道这个分析都做了什么动作,分析些什么内容---------------------------------------mysqlshow显示表的信息 mysqlshow -h XXXX -P3307 test --status -t 下面是显示数据库中包含一个特定列的所有表信息的shell#!/bin/sh#This scripts returns all the tables in a database that contains some fieldfunction usage{echo "Usage: $0 USER DB COLUMN"}function ExistsColumn{local USER=$1local DB=$2local TABLE=$3local COLUMN=$4SEARCH_RESULT=$(mysqlshow -u ${USER} ${DB} ${TABLE} ${COLUMN} | awk '{ if ( NR == 5) print $2 }')if [ "${COLUMN}" = "${SEARCH_RESULT}" ];thenecho "true";elseecho "false";fi}function main{local USER=$1local DB=$2local COLUMN=$3if [[ "${USER}" = "" || "${DB}" = "" || "${COLUMN}" = "" ]];thenusageexit 1fiall_tables=$(mysqlshow -u ${USER} ${DB} | \awk '{ if (NR >4 ) print $_}' | \sed -e 's/[|+-]//g; /^$/d ' | \xargs )for TABLE in ${all_tables}; doif [ "true" = "$(ExistsColumn $USER $DB $TABLE $COLUMN)" ];thenecho $TABLEfidone}main $*
shell> [code]mysqladmin [options
] command[
command-arg] [
command[
command-arg]] ...[/code]包含的命令如下:create db_name 创建一个新的数据库drop db_name删除数据库extended-status 显示服务器状态变量及对应的值flush-hosts 刷新机器缓存中的所有信息 相当于commit?flush-logs 刷新日志 相当于fulsh logs生成一个新的logflush-privileges 重新加载授权表flush-status 清空状态变量flush-tables刷新表 ??flush-threads 刷新线程缓存kill id,id,....杀掉线程ping 查看服务器是否可用processlist 显示线程的列表,使用--verbose选项,输出就是show full processlistreload 重载授权表refresh 刷新所有的表并关闭在打开日志文件shutdown 关闭服务器start-slave 启动复制status 显示状态信息stop-slave停止复制variables显示系统变量和值version显示版本------------------------------------------------mysqlcheck这个客户端主要是检查,修复,优化,分析表。当使用该工具的时候,表被锁住不可用,对于检查操作,加的事读锁。mysql_upgrade命令也是调用了mysqlcheck,也会锁表。mysqlcheck跟myisamchk很像,但是不同,mysqlcheck主要是mysqld运行的时候使用,myisamchk是在不运行的时候使用,使用mysqlcheck不需要停止服务。mysqlcheck使用sql语句check table,repaire table analyze table 和optimize table,它决定使用哪个语句来操作,mysqlcheck也可以用在在myisam表上。使用方法
shell> [code]mysqlcheck [options
] db_name[
tbl_name...]shell>
mysqlcheck [options
] --databases db_name...shell>
mysqlcheck [options
] --all-databases[/code]下面是指定的选项,主要的也就是check,repaire,analyzeFormat | Description | Introduced |
---|---|---|
--all-databases | Check all tables in all databases | |
--all-in-1 | Execute a single statement for each database that names all the tables from that database | |
--analyze | Analyze the tables | |
--auto-repair | If a checked table is corrupted, automatically fix it | |
--bind-address | Use specified network interface to connect to MySQL Server | 5.6.1 |
--character-sets-dir | Directory where character sets are installed | |
--check | Check the tables for errors | |
--check-only-changed | Check only tables that have changed since the last check | |
--check-upgrade | Invoke CHECK TABLE with the FOR UPGRADE option | |
--compress | Compress all information sent between client and server | |
--databases | Interpret all arguments as database names | |
--debug | Write debugging log | |
--debug-check | Print debugging information when program exits | |
--debug-info | Print debugging information, memory, and CPU statistics when program exits | |
--default-auth | Authentication plugin to use | 5.6.2 |
--default-character-set | Specify default character set | |
--defaults-extra-file | Read named option file in addition to usual option files | |
--defaults-file | Read only named option file | |
--defaults-group-suffix | Option group suffix value | |
--enable-cleartext-plugin | Enable cleartext authentication plugin | 5.6.28 |
--extended | Check and repair tables | |
--fast | Check only tables that have not been closed properly | |
--fix-db-names | Convert database names to 5.1 format | |
--fix-table-names | Convert table names to 5.1 format | |
--force | Continue even if an SQL error occurs | |
--help | Display help message and exit | |
--host | Connect to MySQL server on given host | |
--login-path | Read login path options from .mylogin.cnf | 5.6.6 |
--medium-check | Do a check that is faster than an --extended operation | |
--no-defaults | Read no option files | |
--optimize | Optimize the tables | |
--password | Password to use when connecting to server | |
--pipe | On Windows, connect to server using named pipe | |
--plugin-dir | Directory where plugins are installed | 5.6.2 |
--port | TCP/IP port number to use for connection | |
--print-defaults | Print default options | |
--protocol | Connection protocol to use | |
--quick | The fastest method of checking | |
--repair | Perform a repair that can fix almost anything except unique keys that are not unique | |
--secure-auth | Do not send passwords to server in old (pre-4.1) format | 5.6.17 |
--shared-memory-base-name | The name of shared memory to use for shared-memory connections | |
--silent | Silent mode | |
--skip-database | Omit this database from performed operations | 5.6.11 |
--socket | For connections to localhost, the Unix socket file to use | |
--ssl | Enable secure connection | |
--ssl-ca | Path of file that contains list of trusted SSL CAs | |
--ssl-capath | Path of directory that contains trusted SSL CA certificates in PEM format | |
--ssl-cert | Path of file that contains X509 certificate in PEM format | |
--ssl-cipher | List of permitted ciphers to use for connection encryption | |
--ssl-crl | Path of file that contains certificate revocation lists | 5.6.3 |
--ssl-crlpath | Path of directory that contains certificate revocation list files | 5.6.3 |
--ssl-key | Path of file that contains X509 key in PEM format | |
--ssl-verify-server-cert | Verify server certificate Common Name value against host name used when connecting to server | |
--tables | Overrides the --databases or -B option | |
--use-frm | For repair operations on MyISAM tables | |
--user | MySQL user name to use when connecting to server | |
--verbose | Verbose mode | |
--version | Display version information and exit | |
--write-binlog | Log ANALYZE, OPTIMIZE, REPAIR statements to binary log. --skip-write-binlog adds NO_WRITE_TO_BINLOG to these statements. |
相关文章推荐
- NodeJS mysql2 使用心得
- MYSQL例题合集
- MySQL基本用法
- 配置Mysql数据库支持远程连接等操作的步骤
- mysql自动备份脚本
- mysql修改编码设置
- Mysql简单配置
- Mysql中的查询语句
- MySQL基础2
- MySQL基础1
- mysql练习题
- MYSQL mysql.user表中权限对应的解释
- MySQL查询优化
- MySQL错误:Can't connect to
- mysql高级查询
- mysql 查看优化器重写后的sql
- mysql提示:host xxxx not allowe to connect
- 取消MySQL timestamp列默认ON UPDATE CURRENT_TIMESTAMP
- MySQL中的datetime与timestamp区别比较,以及选择方法
- mysql主从复制汇总