MySQL Utilities 提供一系列工具,每个工具的选项并不相同,也不是那么容易记住的以及相关联的选项参数。有时候我们需要执行选项几乎相同的多个工具。例如,需要登录到特定服务器上执行多个工具。而不是每次输入连接信息,你可能想相同的选项并重用之。
幸运的是,mysqluc 工具就是干这个活的,命名为MySQL用户控制台,提供完成选项、工具名称和用户自定义变量,不仅如此,还提供获取任何工具帮忙的能力。极大的提供各种方便。很像MySQL客户端的命令行工具。
在下面的例子中,方括号来表示使用键,如[TAB]表示TAB键。同样,尖括号中值替换成你实际环境下的值。如<user>表示登录的用户名。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | shell > mysqluc Launching console . . . Welcome to the MySQL Utilities Client ( mysqluc ) version 1.4.2 Copyright ( c ) 2010 , 2014 Oracle and / or its affiliates . All rights reserved . This is a release of dual licensed MySQL Utilities . For the avoidance of doubt , this particular copy of the software is released under the version 2 of the GNU General Public License . MySQL Utilities is brought to you by Oracle . Type ‘help’ for a list of commands or press TAB twice for list of utilities . mysqluc > help Command Description — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — – help utilities Display list of all utilities supported . help < utility > Display help for a specific utility . show errors Display errors captured during the execution of the utilities . clear errors clear captured errors . show last error Display the last error captured during the execution of the utilities help | help commands Show this list . exit | quit Exit the console . set < variable >= < value > Store a variable for recall in commands . show options Display list of options specified by the user on launch . show variables Display list of variables . < ENTER > Press ENTER to execute command . < ESCAPE > Press ESCAPE to clear the command entry . < DOWN > Press DOWN to retrieve the previous command . < UP > Press UP to retrieve the next command in history . < TAB > Press TAB for type completion of utility , option , or variable names . < TAB > < TAB > Press TAB twice for list of matching type completion ( context sensitive ) . mysqluc > help utilities Utility Description — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — – mysqlauditadmin audit log maintenance utility mysqlauditgrep audit log search utility mysqldbcompare compare databases for consistency mysqldbcopy copy databases from one server to another mysqldbexport export metadata and data from databases mysqldbimport import metadata and data from files mysqldiff compare object definitions among objects where the difference is how db1 . obj1 differs from db2 . obj2 mysqldiskusage show disk usage for databases mysqlfailover automatic replication health monitoring and failover mysqlfrm show CREATE TABLE from . frm files mysqlindexcheck check for duplicate or redundant indexes mysqlmetagrep search metadata mysqlprocgrep search process information mysqlreplicate establish replication with a master mysqlrpladmin administration utility for MySQL replication mysqlrplcheck check replication mysqlrplms establish multi – source replication mysqlrplshow show slaves attached to a master mysqlrplsync replication synchronization checker utility mysqlserverclone start another instance of a running server mysqlserverinfo show server information mysqluserclone clone a MySQL user account to one or more new users mysqluc > help mysqldb [ TAB ] [ TAB ] Utility Description — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — – mysqldbcompare compare databases for consistency mysqldbcopy copy databases from one server to another mysqldbexport export metadata and data from databases mysqldbimport import metadata and data from files mysqluc > mysqlrplshow — m [ TAB ] [ TAB ] Option Description — — — — — — — — — — – — — — — — — — — — — — — — — — — — — — — — — — — — — — master = MASTER connection information for master server in the form : < user > [ : < password > ] @ < host > [ : < port > ] [ : < socket > ] or < login – path > [ : < port > ] [ : < socket > ] . — max – depth = MAX_DEPTH limit the traversal to this depth . Valid only with the — recurse option . Valid values are non – negative integers . mysqluc > mysqlrplshow — mast [ TAB ] er = < user > : < password > @ trustauth.cn : 13001 The console has detected that the utility ‘mysqlrplshow’ ended with an error code . You can get more information about the error by running the console command ‘show last error’ . mysqluc > show last error Execution of utility : mysqlrplshow — master = < user > : < password > @ trustauth.cn : 13001 returned errorcode : 2 with error message : Usage : mysqlrplshow . py — master = root @ trustauth.cn : 3306 mysqlrplshow . py : error : The — discover – slaves – login is required to test slave connectivity . mysqluc > mysqlrplshow — master = < user > : < password > @ trustauth.cn : 13001 \ — discover – slaves – login = < user > : < password > # master on trustauth.cn: … connected. # Finding slaves for master: trustauth.cn:13001 # Replication Topology Graph trustauth.cn : 13001 ( MASTER ) | + — – trustauth.cn : 13002 – ( SLAVE ) | + — – trustauth.cn : 13003 – ( SLAVE ) | + — – trustauth.cn : 13004 – ( SLAVE ) | + — – trustauth.cn : 13005 – ( SLAVE ) mysqluc > |
第一条命令,mysqluc 启动用户控制台。一旦启动,会看到欢迎信息和mysqluc>提示符。可以传递命令到该控制台执行。
下一个命令,是打印出控制台本身的帮助信息。
运行mysqluc无需特殊权限,但是执行那些工具取决于该工具所需的权限。
文章转载来自:trustauth.cn