您的位置:首页 > 数据库 > MySQL

mysql客户端工具使用

2016-04-23 22:43 597 查看
mysqladmin是个客户端的管理工具,使用的方式如下:
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,analyze
FormatDescriptionIntroduced
--all-databasesCheck all tables in all databases 
--all-in-1Execute a single statement for each database that names all the tables from that database 
--analyzeAnalyze the tables 
--auto-repairIf a checked table is corrupted, automatically fix it 
--bind-addressUse specified network interface to connect to MySQL Server5.6.1
--character-sets-dirDirectory where character sets are installed 
--checkCheck the tables for errors 
--check-only-changedCheck only tables that have changed since the last check 
--check-upgradeInvoke CHECK TABLE with the FOR UPGRADE option 
--compressCompress all information sent between client and server 
--databasesInterpret all arguments as database names 
--debugWrite debugging log 
--debug-checkPrint debugging information when program exits 
--debug-infoPrint debugging information, memory, and CPU statistics when program exits 
--default-authAuthentication plugin to use5.6.2
--default-character-setSpecify default character set 
--defaults-extra-fileRead named option file in addition to usual option files 
--defaults-fileRead only named option file 
--defaults-group-suffixOption group suffix value 
--enable-cleartext-pluginEnable cleartext authentication plugin5.6.28
--extendedCheck and repair tables 
--fastCheck only tables that have not been closed properly 
--fix-db-namesConvert database names to 5.1 format 
--fix-table-namesConvert table names to 5.1 format 
--forceContinue even if an SQL error occurs 
--helpDisplay help message and exit 
--hostConnect to MySQL server on given host 
--login-pathRead login path options from .mylogin.cnf5.6.6
--medium-checkDo a check that is faster than an --extended operation 
--no-defaultsRead no option files 
--optimizeOptimize the tables 
--passwordPassword to use when connecting to server 
--pipeOn Windows, connect to server using named pipe 
--plugin-dirDirectory where plugins are installed5.6.2
--portTCP/IP port number to use for connection 
--print-defaultsPrint default options 
--protocolConnection protocol to use 
--quickThe fastest method of checking 
--repairPerform a repair that can fix almost anything except unique keys that are not unique 
--secure-authDo not send passwords to server in old (pre-4.1) format5.6.17
--shared-memory-base-nameThe name of shared memory to use for shared-memory connections 
--silentSilent mode 
--skip-databaseOmit this database from performed operations5.6.11
--socketFor connections to localhost, the Unix socket file to use 
--sslEnable secure connection 
--ssl-caPath of file that contains list of trusted SSL CAs 
--ssl-capathPath of directory that contains trusted SSL CA certificates in PEM format 
--ssl-certPath of file that contains X509 certificate in PEM format 
--ssl-cipherList of permitted ciphers to use for connection encryption 
--ssl-crlPath of file that contains certificate revocation lists5.6.3
--ssl-crlpathPath of directory that contains certificate revocation list files5.6.3
--ssl-keyPath of file that contains X509 key in PEM format 
--ssl-verify-server-certVerify server certificate Common Name value against host name used when connecting to server 
--tablesOverrides the --databases or -B option 
--use-frmFor repair operations on MyISAM tables 
--userMySQL user name to use when connecting to server 
--verboseVerbose mode 
--versionDisplay version information and exit 
--write-binlogLog ANALYZE, OPTIMIZE, REPAIR statements to binary log. --skip-write-binlog adds NO_WRITE_TO_BINLOG to these statements.
不知道这个分析都做了什么动作,分析些什么内容---------------------------------------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 $*
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: