Home

PDF (A4) - MySQL Community Downloads

image

Contents

1. STATUS TIMESTAMP NAME CONNECTION_ID SOLTEXT 4 mo 2012 09 27 7133347 Pang 7 None 0 2012 09 2 7 33 33397 Query 7 SELECT FROM INFORMATION_SCHEMA PLUGINS WHE 2O12Z OF 27WISeSSony Ges 7 COMMIT 0 2012 09 27T13534 43 Out None mo 2OLZ O9 27 Wile i OE amp None 4 To display the audit log entries matching a specific SQL L KE pattern use the following command shell gt mysqlauditgrep pattern ___ SERVER data audit log 4 4 4 4 4 STATUS TIMESTAMP NAME SQLTEXT CONNECTION_ID 4 4 4 4 0 e202 09 2 Tis i3ss39 5 Ouery S Sh G sessiton autocommilt ORE sl a 0 P22 09 27 Tis 33395 Ouery SE G sessionautocommiltt ORE ss 0 2012 0 0 gt 2 30 Is 26330 Query chilGsess tony aucocommits Grr I 0 2012 00523 T1216 50 ery I SEr Mlssscion alicocommintcy Gma 10 4 4 4 4 4
2. 4 4 4 4 4 host pore rore state gtid_mode health 4 4 4 4 4 4 localhost 3332 MASTER UP ON OK localhost 3331 SLAVE UP ON OK localhost S3S3 Sioa UP ON OK localhost 3334 SLAVE UP ON OK 4 4 4 4 4 4 done PERMISSIONS REQUIRED The users on the master need the following privileges SELECT and INSERT privileges on mysql database REPLICATION SLAVE REPLICATION CLIENT and GRANT OPTION The slave users need the SUPER privilege The repl user used as the argument for the rp1 user option is either created automatically or if it exists it needs the REPLICATION SLAVE privilege To run the mysqlrpladmin utility with the health command the account used on the master needs an extra SUPER privilege As for the switchover command all the users need the following privileges SUPER GRANT OPTION SELECT RELOAD DROP CREATE and REPLICATION SLAVE 173 mysqlrplcheck Check Replication Prerequisites 5 21 mysqlrplcheck Check Replication Prerequisites This utility checks the prerequisites for replication between a master and a slave These checks called tests are designed to ensure a healthy replication setup The utility performs the following tests 1 Is the binary log enabled on the master 2
3. 0 2OIZ 1O loimlssaigei Onen Sinem caules ale Test 11 4 4 4 4 4 To display the audit log entries of specific event types use the following command shell gt mysqlauditgrep event type Ping Connect SERVER data audit log 4 4 4 4 4 4 4 STATUS NAME TIMESTAMP CONNECTION_ID HOST USER PRIVSUSER IP 4 4 4 4 0 Connect PADI NS Se te L35 395 39 y localhost Foo root 12 0 Ping PADD ENS TI Ses y None None None NC 0 Ping PAU NS Se Vr ee 39 y None None None NC 0 Ping PAGS TE ey y None None None NC 0 Ping PAINS NS 1 ee a y None None None NC 0 Connect 22 Ose bere 8 localhost TOOR TOOR 2 0 Ping PAUSES Se Te 39 8 None None None Nc 0 Ping 2020S bere a 8 None None None Nc 0 Ping 202 05 2 er SS e AT 7 None None None Nc 0 Connect 202 00 gt 2s LI AG S0 9 localhost TOOR tester 2 0 Ping 20 2 05 25 LL A6 S0 9 None None None Ne 0 Ping 202 00 gt 2s leo S0 9 None None None Nc 0 Connect 202 005 257 26 50 0 localnost TOOR TOOR 2 0 Ping 202 Oo 2s eo S0 0 None None None Nc 0 Ping 202 00 2s LL A0 S0 0 None None None Nc 0 Ping 202 0o gt 2s LIL A6 S0 0 None None None Nc 0 Ping 2202 05 25 26 50 0 None None None 0 Ping 202 00 2s LL
4. 4 PERMISSIONS REQUIRED The user must have the SELECT privilege on the mysql database 5 17 mysqlprocgrep Search Server Process Lists This utility scans the process lists for the servers specified using instances of the server option and selects those that match the conditions specified using the age and match xxx options For a process to match all conditions given must match The utility then either prints the selected processes the default or executes certain actions on them If no age or match xxx options are given the utility selects all processes The mat ch xxx options correspond to the columns in the INFORMATION_SCHEMA PROCESSLIST table For example mat ch command specifies a matching condition for PROCESSLIST COMMAND column values There is no mat ch t ime option To specify a condition based on process time use age Processes that can be seen and killed are subject to whether the account used to connect to the server has the PROCESS and SUPER privileges Without PROCESS the account cannot see processes belonging to other accounts Without SUPER the account cannot kill processes belonging to other accounts When the kill query or kill connection option is used the utility will display those rows from the SHOW PROCESSLIST that match the query and are killed This behavior exists as of MySQL Utilities 1 6 0 To specify how to display output use one of the f
5. ccceeeeeeeeeeeeeeeeeeeeeaeeaeeees 216 7 MYSQL Utilities Testing MU T orcsoun aaa aana E a aE a aA 219 7 1 mut MySQL Utilities Testing 2 0 0 0 cece cee eeeee cece cece aa eee eeeeeeeeaeaaaa ae eeeeeeeeaeaaaaneeeeeeees 219 A MYSQL Fabric wees scisectentiyaccssenapecssiuae tes swhausasbtatemes seh aondsatuannes oaa i baaa a Ke aodan nE 223 BADD GOIN ar a eiaseaaa santeatenaveeaeea loess T T N 225 8 1 MySQL Utilities Frequently Asked Questions c ce ccceeeeeeeeeee cece aeaaeeteeeeeeeeeaeaaeaneeeeees 225 8 2 Third Fary LICOnS Sis orea reise ave tisecuns scfeansivatiee tip httcae det dias tieg a 226 8 2 1 Apache LIDOU sesi sceredseseecdeetupereteua yer svndeeereanebve canta ended nawgecanteeeeeanbuneesindeeeectanty 227 8 2 2 Apache License Version 2 0 January 2004 00 eee eeeeeeteeeee eee eeee sean eeeeeeaaeeeeees 230 8 2 3 Doctrine DBAL 2 3 24 uiai inaina iaaa a Madi AEA a EAA EE AA Ea 233 8 2 4 GNU Lesser General Public License Version 2 1 February 1999 0 233 8 2 5 Paramiko LICENSE sercssccctecsndedeectentierdantewercanbiwee sane AE ARARE SER 240 8 2 6 Python Bindings to the OpenStack Neutron API python neutronclient 240 8 2 7 Python bindings to the OpenStack Nova API python novaclient eeeeee 241 8 2 8 Python EICONSO access cect R A 242 8 2 9 Python License Supplement Windows Only ccceeeeeeeeeeeeeeeeeeeeeaeaaeneeeeeeees 251 Preface This is the User Manual for t
6. 0 ecceeeeeeceeeeeeeeeeeeeeaeaaeeeeeeeeeeeeaeaaaaeeeees 226 8 1 3 What is diagnostic mode and why doesn t it produce the same output as the default mode 226 8 1 4 If the diagnostic mode is only a best effort compilation why use it ceceeeeeeeeeeeeeeeeeeeees 226 8 1 5 Why does the default mode require a server 2 22 ceeececeeeeeee ee eeeeeeeeeeeeeeeeaaaaeeeeeeeeeeeeaaaaeeeees 226 8 1 6 Can the frm reader read any frm file eect eeee cece cece eee a eee eeeeee ease aaeeeeeeeeeeeaeaaaaneeeeeees 226 8 1 7 My frm files are tucked away in a restricted folder How do get access to them to run the frm reader without copying or modifying file privileges ccceeeeeeeeeeeeeeeeeeeeeaeeneeeees 226 8 1 8 Will the default mode display a 100 accurate CREATE statement ccccsseeeeeeneeeees 226 8 1 1 Can the frm reader read a frm file without the associated data files 225 Third Party Licenses 8 1 2 Yes The frm reader was designed to read the contents of an frm file without requiring the data files Will the frm reader modify my original frm file No it does not modify the original frm file in either default or diagnostic mode What is diagnostic mode and why doesn t it produce the same output as the default mode The diagnostic mode does not use a spawned server to read the frm file Instead it attempts to read the contents of the file byte by byte and forms a best
7. 4 l host port role state gtid_mode health 4 4 4 Msecsilhost pose MASTER UP ON OK localhost losses SLAVE UP ON OK etic callhost oss4 SLAVE UP ON Oks 4 4 O quit R refresh H health G GTID Lists U UUIDs L log entries Pressing L with the 1 og option specified causes the interface to show the entries in the log file such as MySQL Replication Monitor and Failover Utility Failover Mode auto Next Interval Mon Mar 19 16 06 13 2012 Master Information Binary Log File Position Binlog_Do_De Binlog_ignore_De mysql bin 000001 1117 GTID Executed Set 2A67DE00 2DA1 11E2 A711 00764F2BE90F 1 7 Log File dene eee deen SS SS SSS Date Entry dena SSS SS SS SSS gene SS SS SSS 2012 03 19 ASSSSsSS PM MEO Feilover console sterte TE AVILZ OS 19 15535333 PN INEO Feiloyver moce atita 236 AOILZ OF 19 ASESSESS WIM INFO Cetting Ineellicin tor mester loe eulinos sss AVILZ OF 19 ASESSESS WM TEO Nester scatus lodlmlegs wumysel olim OW 3s dee S SSS SSS SSS SS SSS SS dee SS SS soo Q quit R refresh H health G GTID Lists U UUIDs L log entries Up Down scroll PERMISSIONS REQUIRED The user must have permissions to monitor the servers on the topology and configure replication to successfully perform the fa
8. KEY idx_full_name_dup name surname KEY idx_name name KEY idx_surname surname KEY idx_reverse_name surname name KEY idx_id_name emp_id name KEY idx_id_hdate emp_id hire_date KEY eored ipday ae empl Clin mun pEr Endan 9 ENGINE InnoDB DEFAULT CHARSET utf 8 Example Execution shell gt mysqlindexcheck server test_user localhost 13010 test_db indexcheck_test Source on localhost connected The following indexes are duplicates or redundant for table test_db indexcheck_test CREATE INDEX idx_uemp_id ON test_db indexcheck_test gt emp_id USING BTREE may be redundant or duplicate of ALTER TABLE test_db indexcheck_test ADD PRIMARY KEY emp_id CREATE INDEX idx_fnumber ON test_db indexcheck_test fiscal_number USING BTREE may be redundant or duplicate of CREATE INDEX idx_unifnumber ON test_db indexcheck_test fiscal_number USING BTREE CREATE INDEX idx_full_name_dup ON test_db indexcheck_test name surname USING BTREE may be redundant or duplicate of CREATE INDEX idx_full_name ON test_db indexcheck_test gt name surname USING BTREE CREATE INDEX idx_name ON test_db indexcheck_test name USING BTREE may be redundant or duplicate of CREATE INDEX idx_full_name ON test_db indexcheck_test gt name
9. Variable_name Value 4 4 audit_log_buffer_size 1048576 audit_log_connection_policy ALL audit_log_current_session ON audit_log_exclude_accounts audit_log_file audit log cweit leoc aiius OFF audit_log_format OLD audit_log_include_accounts awelet loe jae ll ew ALL audit_log_rotate_on_size 0 audit_log_statement_policy ALL audit_log_strategy ASYNCHRONOUS 4 4 Executing POLICY command Showing options after command Audit Log Variables and Options 4 4 Variable_name Value 4 4 audit_log_buffer_size 1048576 audit _log_connection_policy NONE audit_log_current_session ON audit_log_exclude_accounts audit_log_file audit loeg cweit loc ie linisih OFF audit_log_format OLD audit_log_include_accounts awene loe iocilaiey ALL audit_log_rotate_on_size 28672 audit_log_statement_policy ALL audit_log_strategy ASYNCHRONOUS 4 4 To perform a copy of a audit log file to another location use the following command shell gt mysqlauditadmin audit log name SERVER data audit log 13486539046497235 copy copy to BACKUP Audit_Logs To copy a audit log file from a remote server location to the current location user password will be prompted use the following
10. To display the audit log entries matching a specific REGEXP pattern use the following command shell gt mysqlauditgrep pattern regexp SERVER data audit log 4 4 4 4 4 STATUS TIMESTAMP NAME SOLTEXT CONNECTION_ID 4 4 4 4 4 0 eZ OZ 092i ils l Oen NN ent ses Ss nom cits Ome a sen 0 2012 09 27T13 33 39 Query SET session autocommit OFF 8 0 e2012 00523 Te 26330 Query cmr MOgcssion jaucocommit Grr I 3 0 2012 09 23T11 26 50 Query SET session autocommit OFF 10 4 4 4 4 4 To display the audit log entries of specific query types use the following command shell gt mysqlauditgrep query type show SET SERVER data audit log eS a ere renee raarent a Sa ch ea E ad a as sans Ws Ns ns ass iss ns Ts a Ns a Ns Ne Ns as as a Na a as Ns ss as Ns is se Mi AA fs ts As ss in es Ns Ss Ne Nes as Ses A Nas is es ie es ns ee eS _ __ STATUS TIMESTAMP NAME SOLTEXT CONNECT ION_ 4 4 4 4 0 A2WLZ 09 2 TIS S333 39 Query SET NAMES latinl COLLATE latinl_swedish_ci
11. new data action store dest new_data type sString help the full path to the location of the data directory for the new instance Port for the new instance parser add_option new port action store dest new_port type string default 3307 help the new port for the new instance default default Server id for the new instance parser add_option new id action store dest new_id type sString default 2 help the server_id for the new instance default default List of databases parser add_option d type string help comma separated list of databases to include in the copy omit for all databases default None databases action store dest dbs_to_copy List of users parser add_option u users action store dest users_to_copy type string help comma separated list of users to include in the copy omit for all users default None Now we process the rest of the arguments opt args parser parse_args Parse source connection values Eterna conn parse_connection opt server except parser error Server connection values invalid or cannot be parsed Get a server class instance print Connecting to server server_options Werema alone E CON troles B Meouieea serverl Server server_options BENS serverl connect except UtilError e print ERROR e errmsg Get list of database
12. shell gt mysqldbcopy source root pass localhost 3310 test123 mysql sock destination root pass localhost 3310 test123 mysql sock util_test util_test_copy locking lock all Source on localhost connected Destination on localhost connected Copying database util_test renamed as util_test_copy Copying TABLE util_test tl Copying table data Copying TABLE util_test t2 Copying table data Copying TABLE util_test t3 Copying table data Copying TABLE util_test t4 Copying table data Copying VIEW util_test vl Copying TRIGGER util test trg Copying PROCEDURE util_test pl Copying FUNCTION util_test fl Copying EVENT util_test el Copying GRANTS from util_test done 100 PERMISSIONS REQUIRED To copy one or more databases from a master to a slave you can use the following command to copy the databases Use the master as the source and the slave as the destination shell gt mysqldbcopy source root localhost 3310 destination root localhost 3311 test123 rpl master rpl user rpl Source on localhost connected Destination on localhost connected Source on localhost connected Stopping slave Copying database test123 Copying TABLE test123 t1l Copying data for TABLE test123 t1l Connecting to the current server as master Starting slave lt CON To copy a database from one slave to another attached to the same master you can use th
13. Slave localhost 3311 is 15 transactions behind Master Slave localhost 3312 is 12 transactions behind Master Checking data consistency Using Master localhost 3310 as base server for comparison Checking test_rplsync_db database Checking t0 table data OK test_rplsync_db t0O checksum for server localhost 3311 OK test_rplsync_do tO checksum for server localhost 3312 necking cl table data OK test_rplsync_do tl checksum for server localhost 3311 OK test_rplsync_do tl checksum for server localhost 33ail2 k Checking test_db database Checking t0 table data OK cest db i CO checksum for server localhost 3311 OK test_db t0 checksum for server localhost 3312 Checking tl table data OK testdb tl checksum for server localhost 3311 OK testdb tl checksum for server localhost 3312 IC OMe SUMMARY No data consistency issue found Discussion The above example illustrates how to start the mysqlrplsync utility to check if all data on the specified replication topology is synchronized To do this we simply need to specify the master s connection with the master 184 option and the list of slaves with the slaves 184 option As an alternative to the slaves 184 option one can use the discover slaves login 183 specifying a user and password or login path to
14. e show lt output_type gt Type of report Options include users user_grants and raw e verbose V Specify how much information to display Use this option multiple times to increase the amount of information For example v verbose vv more verbose vvv debug e version Display version information and exit NOTES To use the users value in the show option you must specify at least one privilege using the privileges option If you specify some privileges on the privileges option that are not valid for all the specified objects any that do not apply are not included in the list For example the SELECT privilege will be ignored for stored routines and the EXECUTE privilege will be ignored for tables but both will be taken into account for databases EXAMPLES Check the grantees and respective privileges over different object types databases tables procedures and functions shell gt mysqlgrants server user pass localhost 3310 show user_grants util_test util_test t3 util_test t2 util _test tl util_test pl util_test fl DATABASE util_test Joe user ALL PRIVILEGES joe_wildcard ALL PRIVILEGES priv_test_user EXECUTE GRANT OPTION SELECT TRIGGER UPDATE priv_test_user2 EXECUTE SELECT UPDATE 139 EXAMPLES TABLE TABLE TABLE ROUTINE ROUTINE ov priv_test_user3 Hes tese m Elk joe user joe_wildca
15. ssl cert The name of the SSL certificate file to use for establishing a secure connection ssl key The name of the SSL key file to use for establishing a secure connection min size lt min size gt Rotate the active binary log file only if the file size exceeds the specified value in bytes verbose v Specify how much information to display Use this option multiple times to increase the amount of information For example v verbose vv more verbose vvv debug NOTES By default the utility rotates only the active binary log file but for MySQL Server versions prior to 5 5 3 other log files i e error log relay log slow log are also rotated The path to the MySQL client tools should be included in the PATH environment variable in order to use the authentication mechanism with login paths This will allow the utility to use the my_print_defaults tools which is required to read the login path values from the login configuration file mylogin cnf EXAMPLES Rotate the active binary log file and display new file name shell gt mysqlbinlogrotate server root root localhost 3310 v Checking user permission to rotate binary logs Active binlog file mysql bin 000002 size 32054 bytes The binlog file has been rotated New active binlog file mysql bin 000003 Rotate the active binary log file only if his size exceeds 1GB 1073741824 bytes and display new file name shell gt
16. done Q Show only the users that have all privileges over a set of specified objects and the respective SQL grant statements Notice that while some grantees do not explicitly have the ALL PRIVILEGES grant over a given object they are still shown as a result of having the set of privileges that is equivalent to ALL PRIVILEGES for the given object type shell gt mysqlgrants server user pass localhost 3310 show raw privileges ALL util_test util_test t3 util_test t2 util _test tl util_test pl util_test f1l 141 EXAMPLES DATABASE util_test For joe user GRANT ALL PRIVILEGES ON util_test gt TO joe user For joe_wildcard s GRANT ALL PRIVILEGES ON util test TO joe_wildcard TABLE WEsil tese ti For joe user GRANT ALL PRIVILEGES ON util_test gt TO joe user For joe_wildcard 3 GRANT ALL PRIVILEGES ON util_test TO joe_wildcard Por priv _test_user2 0 s GRANT INSERT DELETE CREATE DROP REFERENCES INDEX ALTER CREATE VIEW SHOW VIEW TRIGGER ON util_test GRANT SELECT UPDATE SHUTDOWN EXECUTE ON TO priv_test_user2 TABLE Util Etes 2 t2 For joe user GRANT ALL PRIVILEGES ON util_test gt TO joe user For joe_wildcard s GRANT ALL PRIVILEGES ON util_test gt TO joe_wildcard TABLE WEti test 2 tos For joe
17. 4 4 4 localhost 3333 MASTER UP ON OK localhost 3332 SLAVE UP ON OK localhost 3334 SLAVE UP ON OK 4 4 4 done To view a detailed replication health report but with all of the replication health checks revealed use the verbose option as shown below In this example we use vertical format to make viewing easier shell gt mysqlrpladmin master root localhost 3331 slaves root localhost 3332 root localhost 3333 root localhost 3334 verbose health Getting health for master localhost 3331 Attempting to contact localhost Success Attempting to contact localhost Success Attempting to contact localhost Success Attempting to contact localhost Success Replication Topology Health KREKKKKKKKK KKK KKK KKK KKKKKK als row KREKKKKKKKKKKKKKKKKKKKKKEEKEK hoste loO callie sits pares SJSN role MASTER state UP gtid_mode ON health OK version 5 6 5 m8 debug log master_log_file mysql bin 000001 master_log_pos 571 IQ _Thread SOL Thread Secs_Behind Remaining_Delay TO Error Num O BET POF KREKKKKKKKKKK KKK KKK KKKKKKK 2 row KREKEKKKKKKKKKKKKKKKKKKKKEKEK HO Sites lOCallehno sits jawes S9932 role SLAVE state UP gtid_mode ON health OK version 5 6 5 m8 debug log master_log_file mysql bin 000001 master_log_pos 571 I0 Thread Yes SQL_Thread Yes Secs_Behind
18. NOTES e verbose v Specify how much information to display Use this option multiple times to increase the amount of information For example v verbose vv more verbose vvv debug e version Display version information and exit e width lt number gt Change the display width of the test report The default is 75 characters NOTES The login user must have the appropriate permissions to execute SHOW SLAVE STATUS SHOW MASTER STATUS and SHOW VARIABLES on the appropriate servers Mixing IP and hostnames is not recommended The replication specific utilities will attempt to compare hostnames and IP addresses as aliases for checking slave connectivity to the master However if your installation does not support reverse name lookup the comparison could fail Without the ability to do a reverse name lookup the replication utilities could report a false negative that the slave is not connected to the master For example if you setup replication using MASTER_HOST ubuntu net on the slave and later connect to the slave with mysqlrplcheck and have the master specified as master 192 168 0 6 using the valid IP address for ubuntu net you must have the ability to do a reverse name lookup to compare the IP 192 168 0 6 and the hostname ubuntu net to determine if they are the same machine The path to the MySQL client tools should be included in the PATH environment variable in order to use the authentication mechani
19. Start replication from specific event coordinates specific binary log file and position To do this use the master log file and master log pos options OPTIONS mysqlreplicate accepts the following command line options e help Display a help message and exit e license Display license information and exit e master lt master gt Connection information for the master server To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure 155 OPTIONS e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt e Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt e login path mylogin cnf lt ogin path gt lt port gt lt socket gt Configuration file lt configuration file path gt lt section gt Command line lt users lt passwa gt lt host
20. e ssl Specifies if the server connection requires SSL If an encrypted connection cannot be established the connection attempt fails By default set to 0 indicating that SSL is not required ssl ca The path to a file that contains a list of trusted SSL certificate authorities ssl cert 82 OPTIONS The name of the SSL certificate file to use for establishing a secure connection ssl key The name of the SSL key file to use for establishing a secure connection binlog lt binlog gt Binary log file name to not to purge All the binary log files prior to the specified file are removed dry run Run mysqlbinlogpurge without purging any binary log files instead displaying a list of the unused binary log files which would be purged discover slaves login lt slave login gt Supply a user name and password in the form lt user gt lt passwd gt or lt login path gt used for discovering slaves and relay slaves in the replication topology For example discover joe secret uses joe as the user name and secret as the password for attempting to log in to each discovered slave slaves lt slave connections gt Connection information for slave servers List multiple slaves in a comma separated list The list is evaluated literally where each server is considered a slave of the master listed regardless of whether they are a slave of the master To connect to a server it is necessary to specify connect
21. log log txt rpl user rpl rpl NOTE Log file log txt does not exist Will be created Checking privileges MySQL Replication Failover Utility Failover Mode auto Next Interval Fri Jul 26 10r17 52 2013 Master Information Binary Log File Position Binilog_Do_DB Binlog_Iignore_DB 36 Setup Automatic Failover master bin 000001 151 GTID Executed Set None Replication Health Status 4 4 4 4 host port role state gtid_mode health 4 4 serverl SStal al MASTER UP ON OK server2 13312 SLAVE UP ON OK server3 3313 SLAVE UP ON OR server4 S34 SLAVE UP ON OK server5 3315 SLAVE UP ON OK 4 4 4 4 4 4 Q emie R rerrssa khhdeselltim CCID bistre U WUIDS bos eme ies Now imagine that the master crashed or is no longer reachable then after a predefined time interval by default 15 seconds we can observe that the failover process will start automatically Failover starting in auto mode Candidate slave server2 3312 will become the new master Checking slaves status before failover Preparing candidate for failover Creating replication user if it does not exist Stopping slaves Performing STOP on all slaves Switching slaves to new master Disconnec
22. 0 ce cece cece ee neee cette tere eee cece te ener ee ee ead teense esse ae aaeaneeeeeeeeeaeaae 61 4 5 Server Operations i025 usidhuciids Gh eRe ee elie ede 62 4 6 Specialized Operations ccccecccccecceeeeee eee e eee ete ee nese ee ee aaa nese sees sede aaa eeeeeeeeeeaaaaaaneeeeeeeeeaea 62 This chapter presents an brief overview of each of the available utilities The utilities are grouped into sections based on the type of administrative function that they perform 4 1 Binary Log Operations These utilities are designed to perform operations on binary log files mysqlbinlogmove e Rellocate binary log files e Move files based on their sequence number or modified date mysqlbinlogpurge e Purge binary logs mysqlbinlogrotate e Rotate binary logs 4 2 Database Operations These utilities are those designed to work at the database level They include utilities that can used to adminster databases on one or more servers e mysqldbcompare Compare databases on two servers or the same server Compare definitions and data e Generate a difference report e Generate SQL transformation statements mysqldbcopy Copy databases between servers e Clone databases on the same server e Supports rename mysqldbexport e Export metadata and or data from one or more databases 59 General Operations e Formats SQL CSV TAB Grid Vertical mysqldbimport Import metadata and data from one or more files e Reads all fo
23. ON OK tecalhost 3308 MASTER UB ON Oks 4 4 4 4 4 4 GTID Status Transactions executed on the servers 4 4 4 host joerc wolle aeie 4 4 4 localhost 3307 MASTER 00a4e027 a83a lle3 8bd6 280244017 26 1 2 Tecalhost 3306 SLAVE 00a4e027 a83a 1le3 8bd6 28d244017f26 1 2 Tecalhost 3306 SLAVE faf0874f a839 1le3 8bd6 28d244017f26 1 4 4 4 4 UUED Status 4 4 4 4 host joerc welle uuid 4 4 4 4 localhost 3307 MASTER 00a4e027 a83a 1le3 8bd6 28d244017f 26 Tecalhost 3306 SLAVE faf0874f a839 1lle3 8bd6 28d244017f26 4 4 4 Start multi source replication running as a daemon POSIX only shell gt mysqlrplms slave root root localhost 3306 masters root root localhost 3307 root root localhost 3308 log rplms_daemon log pidfile rplms_daemon pid daemon start Restart multi source replication running as a daemon shell gt mysqlrplms
24. OPTIONS mysqlrplicheck accepts the following command line options e help Display a help message and exit license Display license information and exit master lt source gt Connection information for the master server To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure 174 OPTIONS e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt e Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt e Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt master info file lt file gt The name of the master information file on the slave The default is master info read from the data directory Note This option requires that you run the utility on the slave and that you have appropriate read access for the file quiet q Turn off all messages for quiet execution Note Errors and warnings are not suppressed
25. Slave localhost 3312 is 12 transactions behind Master Checking data consistency Using Master localhost 3310 as base server for comparison Checking test_db database Checking t0O table data OK testidb tQ checksum for server localhost 3311 OK test_db t0 checksum for server localhost 3312 done 187 EXAMPLES SUMMARY No data consistency issue found The following is an example of a replication check that has data inconsistencies shell gt mysqlrplsync master user pass localhost 3310 slaves rpl pass localhost 3311 rpl pass localhost 3312 GTID differences between Master and Slaves Slave localhost 2311 as up to date Slave localhost 2312 ts up to date Checking data consistency Using Master localhost 3310 as base server for comparison DIFF Database NOT on base server but found on localhost 3311 only_on_slave_db Checking test_rplsync_db database DIFF Table NOT on base server but found on localhost 3311 t3 DIFF Table NOT on base server but found on localhost 3312 t3 DIFF Table test_rplsync_db t0 NOT on server localhost 32311 Checking t0O table data DIFK Cesti rpl sync dbi 0 checksum for server localhost 3312 Checking tl table data WARNING Slave not active localhost 3311 Sync skipped DIFF test rpl sync adb ti checksum for server localhost 3311 OK test rplsync db m
26. cccceeeeeeeeeeeeeeeaneneeeees 114 5 11 mysqidiskusage Show Database Disk Usage ccccccccseeeeceaeeeeeeeaaeeeeeeaeeeeeeaaeaees 120 5 12 mysqlfailover Automatic replication health monitoring and failover cceee 123 5 13 mysqlfrm File reader for frm files eccccceeeeeccceeeeececeeeeeceeeeeeeeeaaegeeeessaeeeeesaeeeeeeaaageees 133 5 14 mysqlgrants Display grants by object 2 2 0 cecee cece eee ceeeeeeeeeeeeeeeaeaaeeeeeeeeeeeeaeaaaaneeeeeees 137 5 15 mysqlindexcheck Identify Potentially Redundant Table Indexes n 143 5 16 mysqlmetagrep Search Database Object Definitions ccccceeccecenneeeeeeaeeeeeeeaaeeeees 146 5 17 mysqlprocgrep Search Server Process Lists ccccccssseececeeeeeeeeeeseeeeceeeeeeeseaeseeseaes 151 5 18 mysqlreplicate Set Up and Start Replication Between Two Servers 0cceeceeees 155 5 19 mysql rpims Set Up and Start Replication Among a Slave and Multiple Masters 159 5 20 mysqirpladmin Administration utility for MySQL replication ccceeeeeeeeeeeee nenene 164 5 21 mysqlrplcheck Check Replication Prerequisites cccceeccccesseeeeeeeeeseeeeaaeeeeeeaaeneees 174 5 22 mysqlrplshow Show Slaves for Master Server ccccceeeececeeeeeeeeeeeeeeeeeeeeseeseeneeeeasaaes 178 5 23 mysqlrplsync Replication synchronization checker csccceceaeeeeeeeeeeeeeeeaaeeeeeeaaeeeees
27. example TAB indicates the tab key was pressed Similarly portions in the commands specific with angle brackets are values you would replace with actual values For example lt user gt indicates you would place the user s login Note R In the example below keystrokes are represented using square brackets For name here shell gt 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 gt help Command Description help utilities Display list of all utilities supported help lt utility gt Display helpi or specific utility show errors Display errors captured during the execution of the ELIE Les clear errors clear captured errors show last error Display the last error captured during the 25 What Options Are Used With Each Utility help help commands exit quit set lt variable gt lt value gt execution of the utilities Slaw ielaakey JLE e Exit the console Store a variable for recall in commands show options Display list of options specified by the user on launch show
28. print ERROR e errmsg sys exit Build Gictionary of options options overwrite True quiet True globals True print Cloning the users for user in user_list CEN res userclone clone_user conn dest_values user user options except UtilError e PEINE TERROR mee cam SG sys exit print Ye done Y 6 3 Specialized Operations 6 3 1 mysql utilities command grep Search Databases for Objects This module provides utilities to search for objects on a server The module defines a set of object types that can be searched by searching the fields of each object The notion of an object field is very loosely defined and means any names occurring as part of the object definition For example the fields of a table include the table name the column names and the partition names if it is a partitioned table 213 mysql utilities command proc Search Processes on Servers Constants The following constants denote the object types that can be searched mysql utilities command grep ROUTINE mysql utilities command grep EVENT mysql utilities command grep TRIGGER q m e mysql utilities command grep TABLE mysql utilities command grep DATABASE e mysql utilities command grep VIEW e mysql utilities command grep USER The following constant is a sequence of all the object types that are available It can be used to generate a version independen
29. user GRANT ALL PRIVILEGES ON util_test gt TO joe user For joe_wildcard s GRANT ALL PRIVILEGES ON util_test gt TO joe_wildcard ROUEN ERs Ue Mate SE A e For joe user GRANT ALL PRIVILEGES ON util_test gt TO joe user For joe_wildcard 3 GRANT ALL PRIVILEGES ON util_test TO joe_wildcard For priv_test_user2 GRANT ALTER ROUTINE ON FUNCTION util_test gt f1 TO priv_test_user2 WITH GRANT OPTION GRANT SELECT UPDATE SHUTDOWN EXECUTE ON TO priv_test_user2 ioe NPr jeesie sires G5 GRANT DROP EXECUTE TRIGGER ON TO priv_test_user3 GRANT UPDATE DELETE ALTER ROUTINE ON util_test gt TO priv_test_user3 ROUTINE Ue Mme ste piik For joe user GRANT ALL PRIVILEGES ON util_test gt TO joe user For joe_wildcard 3 GRANT ALL PRIVILEGES ON util test TO joe_wildcard For priv test usero iz GRANT ALTER ROUTINE ON PROCEDURE util test pih TO priv_test_user3 WITH GRANT OPTION RANT DROP EXHCUIH TRIGGER ON TOMpriv test users 3 GRANT UPDATE DELETE ALTER ROUTINE ON util_test gt TO priv_test_user3 doner Q Show just the list of users with some specific privileges over a set of objects shell gt mysqlgrants server user pass localhost 3310 show users privileges SELECT INSERT EXECUTE util_tes
30. 0 Remaining_Delay No IO_Error_Num 0 O_ Error KREKKKKKKKKKKK KKK KK KKKKKEEKEK 3 row KREKKKKKKKKKKKKKKKKKKKKKEEKK HO Sites loOCallehnoi sits ponc 33553 171 EXAMPLES role SLAVE state UE gtid_mode ON health OK version 5 6 5 m8 debug log master log file mysql bin 000001 master_log_pos 571 IO_Thread Yes SQL_Thread Yes Secs_Behind 0 Remaining_Delay No IO_Error_Num 0 TO Error kkkkkkxkkkkxkxkxkkkkkkkkkkkxxk xx a row KKEKKKEKKKEKKKKKKKKKAKKKK KKK NO Sie aloe eiloisits Owes BIsu role SLAVE state UP gtid_mode ON health OK version 5 6 5 m8 debug log master_log_file mysql bin 000001 master_log_pos 571 IO_Thread Yes SQL_Thread Yes Secs_Behind 0 Remaining_Delay No TOL roraNum 0 TO Error 4 rows done To run the same failover command above but specify a log file use the following command shell gt mysqlrpladmin slaves root localhost 3332 root localhost 3333 root localhost 3334 candidates root localhost 3333 root localhost 3334 log test_log txt failover Performing failover Candidate slave localhost 3333 will become the new master Preparing candidate for failover Creating replication user if it does not exist Stopping slaves Performing STOP on all slaves Switching slaves to new master Starting slaves Performing START on all slaves Checking slaves for errors Failover complete done After this command the log file
31. 120 Master binlog file with last event executed by the SQL thread mysql bin 000021 O thread running Yes SQL thread running Yes Checking slave localhost 3312 O thread is currently reading mysql bin 000021 File position of the I O thread 120 Master binlog file with last event executed by the SQL thread mysql bin 000021 O thread running Yes SQL thread running Yes Checking slave localhost 3313 O thread is currently reading mysql bin 000021 File position of the I O thread 120 Master binlog file with last event executed by the SQL thread mysql bin 000021 O thread running Yes SQL thread running Yes Range of binlog files available from mysql bin 000016 to mysql bin 000021 Latest binlog file replicated by all slaves mysql bin 000020 Latest not active binlog file mysql bin 000020 Executing query PURGE BINARY LOGS TO mysql bin 000021 Binlog file available mysql bin 000021 Range of binlog files purged from mysql bin 000016 to mysql bin 000020 Purge all binary log files not in use prior to a specific binary log file shell gt mysqlbinlogpurge master root root localhost 3310 slaves root root localhost 3311 root root localhost 3312 root root localhost 3313 binlog mysql bin 000027 v Checking user permission to purge binary logs Master active binlog file mysql bin 000031 Checking slave localhost 3311 I O thread is currently reading mysql
32. The name of the SSL certificate file to use for establishing a secure connection 121 NOTES e ssl cert The name of the SSL key file to use for establishing a secure connection e ssl Specifies if the server connection requires use of SSL If an encrypted connection cannot be established the connection attempt fails Default setting is 0 SSL not required verbose v Specify how much information to display Use this option multiple times to increase the amount of information For example v verbose vv more verbose vvv debug e version Display version information and exit For the format option the permitted values are not case sensitive In addition values may be specified as any unambiguous prefix of a valid value For example format g specifies the grid format An error occurs if a prefix matches more than one valid value NOTES You must provide connection parameters user host password and so forth for an account that has the appropriate privileges for all objects accessed during the operation The path to the MySQL client tools should be included in the PATH environment variable in order to use the authentication mechanism with login paths This will allow the utility to use the my_print_defaults tools which is required to read the login path values from the login configuration file mylogin cnf EXAMPLES To show only the disk space usage for the employees and test databases
33. WINdOWS eire aes see teeta eee a neti alec the eee Niele Anodic A KENEAN 2 TOOS X rn ad eee eee ee eee ee ne Se AA E 2 2 ATHOGUCU ON cheers icici teeta tend cist ase E A ated aioe ede eta eee dine eth EA E E E 5 2 1 Introduction to MySQL Utilities 20 0 eee ceee teeter eter ee aa ee teee sree esse aaeaeeeeeeeeeaeaaaaneneeeees 5 2 2 Connecting to MySQL Servers cccececececeeeeeeee eee ee ee eee eee eeee sees aaaaeeteeeeeeeeeaeaaaaeeeeeeeeeaeaae 6 2 2 1 Connection Parameters cccceceeceeeee cece ae ecte eens esse ee aa aaa eeeeeeeeseaaaeaaeeeeeeeeseaaaaenees 6 2 2 2 Specifying Connections in Python Library ccccceceeeeeeeee cease eeeeeeeeeeeeaeaaenneeeeeees 9 3 MySQL Utilities Administrative Tasks cccccccceeeeeeeeeeeee eee ee eeteeeeeee ee aeaaeeneeeeeeeeeaeaaeaeeeeeeeeeeeeaaa 11 3 1 Binary Log Operations anerian onadan eaaa ea ee ae iak AEE eres ee a kentida taaria taap Aa eT E we 11 3 1 1 How To Change The Location For Binary Log Files eneeeeeeeenerrnreee 12 3 1 2 How do you purge obsolete binary log files safely ceceeeeeeeeeeeeeeeeeeeeeeeeeaaes 13 3 2 Database Operations 20 0 0 ce cece cece alaa a aa a nese ee ae ae A A 14 3 2 1 How Do Provision a Slave ccccceceeeeeeeeeaceeeeeeeeeeeeeaaaaeeeeeeeeeeeaaaaeeeeeseeeeeeaaa 14 3 2 2 How Do Make a Copy of a Database on the Same Server ccccccseeeeeeeeeees 16 3 2 3 How Can Make a Copy of a Database and Change the Sto
34. With this option you must specify exactly one test to run e Server lt server gt Connection information for the server to use in the tests Use this option multiple times to specify multiple servers To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt e Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt 219 OPTIONS e Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt skip long Exclude tests that require greater resources or take a long time to run skip suite lt name gt Exclude the named test suite Use this option multiple times to specify multiple suites skip test lt name gt Exclude the named test Use this option multiple times to specify multiple tests skip tests lt prefix gt Exclude all tests that begin with prefix sort Execute
35. You may obtain a copy of the License at http www apache org licenses LICENSE 2 0 241 Python License A copy of the associated Apache License can also be viewed here Section 8 2 2 Apache License Version 2 0 January 2004 8 2 8 Python License The following software may be included in this product Python Programming Language This is the official license for the Python 2 7 release A HISTORY OF THE SOFTWARE Python was created in the early 1990s by Guido van Rossum at Stichting Mathematisch Centrum CWI see http www cwi nl in the Netherlands as a successor of a language called ABC Guido remains Python s principal author although it includes many contributions from others In 1995 Guido continued his work on Python at the Corporation for National Research Initiatives CNRI see http www cnri reston va us in Reston Virginia where he released several versions of the software In May 2000 Guido and the Python core development team moved to BeOpen com to form the BeOpen PythonLabs team In October of the same year the PythonLabs team moved to Digital Creations now Zope Corporation see http www zope com In 2001 the Python Software Foundation PSF see http www python org psf was formed a non profit organization created specifically to own Python related Intellectual Property Zope Corporation is a sponsoring member of the PSF All Python releases are Open Source see http www opensource org for
36. are permitted on the slave other than those produced by events read from the master Use the pedantic and vv options for setting up replication on production servers to avoid possible problems with differing storage engines PERMISSIONS REQUIRED The users on the master need the following privileges SELECT and INSERT privileges on mysql database REPLICATION SLAVE REPLICATION CLIENT and GRANT OPTION The slave users need the SUPER privilege The repl user used as the argument for the rpl user option is either created automatically or if it exists it needs the REPLICATION SLAVE privilege 5 19 mysqlrplms Set Up and Start Replication Among a Slave and Multiple Masters This utility permits a user to start replication from multiple master servers also called sources to a single slave The user provides login information for the slave and each of the masters The utility reports conditions where the storage engines on the masters and the slave differ It also reports a warning if the InnoDB storage engine differs on the master and slave For InnoDB to be the same both servers must be running the same type of InnoDB built in or the InnoDB Plugin and InnoDB on both servers must have the same major and minor version numbers and enabled state By default the utility issues warnings for mismatches between the sets of storage engines the default storage engine and the InnoDB storage engine The vv option displays any discrepa
37. death WALES ILO Yenc VAomecte Vickoe Vail V2OiIG 10 20 20120701 p INSERT INTO menagerie pet pet_num name owner species sex birth death WAS IL Cinvareilaie Anne EE e Yicloe Viel VAOIO 10 20 iINWiiit 5 Discussion In the example above we connected to two servers and compare the database named menagerie We enabled the transformation statements using a combination of options as follows The difftype SQL option instructs the utility to generate the SQL statements The show reverse option instructs the utility to generate the differences in both direction That is from the perspective of server as compared to server2 and server2 as compared to server1 By convention the second set is commented out should you wish to pipe the output to a consumer Lastly the quiet option simply turns off the verbosity of print statements that normally occur for communicating progress Permissions Required The user must have the SELECT privilege for the databases on both servers 20 General Operations Tips and Tricks You can change the direction using the changes for option For example changes for server1 is the default direction and changes for server2 is the reverse In the second case the show reverse displays the perspective of serveri commented out 3 3 General Operations The tasks described in this section include gen
38. discover slaves login option is not allowed because it might not provide the expected result excluding slaves with the IO thread stopped Optionally the master option can also be used and in this case the utility will perform an additional check to verify if the specified slaves are associated replication is configured to the given master stop Execute the STOP SLAVE command on all slaves This command requires the slaves option The discover slaves login option is not allowed because it might not provide the expected result excluding slaves with the IO thread stopped Optionally the master option can also be used and in this case the utility will perform an additional check to verify if the specified slaves are associated replication is configured to the given master switchover Perform slave promotion to a specified candidate slave as designated by the new master option This command is available for both gtid enabled servers and non gtid enabled scenarios This command requires one of the following combinations master new master and slaves master new master and discover slaves login Detection of a downed master is performed as follows If the connection to the master is lost wait ping seconds and check again If the master connection is lost and the master cannot be pinged or reconnected the failover event occurs For all commands that require specifying multiple servers the options require a c
39. it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket e Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt report values lt report_values gt Report values used in mysqIrplms It can be health gtid or uuid Multiple values can be used separated by commas e health Display the replication health of the topology e gtid Display the master s list of executed GTIDs contents of the GTID variables GLOBAL GTID_EXECUTED GLOBAL GTID_PURGED and GLOBAL GTID_OWNED e uuid Display universally unique identifiers UUIDs for all servers Default health rpl user lt replication_user gt The user and password for the replication user in the format lt user gt lt passwora gt or lt login path gt 160 NOTES e
40. log_error_file_size slow_query_log OFF slow_query_log_file slow_query_log_file_size 1 row done As of MySQL Utilities 1 4 4 this deprecated connection method issues a warning if you use this connection method 2 2 2 Specifying Connections in Python Library If you build your own utilities using the MySQL Utilities library you will encounter various methods for connecting to MySQL servers Methods that deal with connecting to servers can accept the following mechanisms for supplying the data Asa Python dictionary containing the connection parameters e As a connection specification string containing the connection parameters e As a Server instance The dictionary lists the values by name as described above For example you would create code like the following Set connection values dest_values Unser te sae RTO Otel passwd secret HOSE eM Ibeyerstahiareysie4 Mexoncie G8 SOs onix socket s None The connection specification is a string the form lt user gt lt passwd gt lt host gt lt port gt lt socket gt where the passwd port and socket are optional This string is parsed using the options parse_connection function You can also specify an existing instance of the Server class In this case the new class will copy the connection information 10 Chapter 3 MySQL Utilities Administrative Tasks Table of Contents 3 1 Binary Log Operations i4 ete ete Aviat
41. lt host gt lt port gt lt socket gt Start from beginning b Start replication at the beginning of events logged in the master binary log This option is not valid unless both master log file and master log pos are given ssl ca The path to a file that contains a list of trusted SSL CAs ssl cert 156 NOTES The name of the SSL certificate file to use for establishing a secure connection e ssl cert The name of the SSL key file to use for establishing a secure connection e ssl Specifies if the server connection requires use of SSL If an encrypted connection cannot be established the connection attempt fails Default setting is 0 SSL not required test db lt test_database gt The database name to use for testing the replication setup If this option is not given no testing is done only error checking e verbose vV Specify how much information to display Use this option multiple times to increase the amount of information For example v verbose vv more verbose vvv debug e version Display version information and exit NOTES The login user for the master server must have the appropriate permissions to grant access to all databases and have the ability to create user accounts For example the user account used to connect to the master must have the WITH GRANT OPTION privilege The server IDs on the master and slave must be nonzero and unique The utility rep
42. modified before lt modified_before gt Specify the datetime or number of days to move binary log files with a modified date prior to the specified value Accepts a datetime in the format yyyy mm ddThh mmiss or yyyy mm dd or an non negative integer indicating the number of elapsed days relay log basename lt relay_log_basename gt Basename for the relay log files If not available it is assumed to be any name ended with relay bin relay log index lt relay_log_index gt Location full path of the relay log index file If not specified it is assumed to be located in the binary log directory sequence lt sequence_number_list gt Comma separated list of non negative sequence integers or intervals to move binary files with a matching sequence number Specified sequence number intervals are closed i e include both endpoints and defined simply using a dash between its endpoints For Example 3 5 12 16 21 Server lt server_connection gt Connection information for the server To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure Use login paths from your my login cnf fil
43. mysqlreplicate master m_account 192 168 1 1 13001 slave slave_acc2 192 168 1 3 3306 rpl user repl slavepass b master on 192 16s 1 1 2 connected slave on 192 168 1 3 connected Checking for binary logging on master Setting up replication done shell gt mysqlrpladmin master m_account 192 168 1 1 13001 slaves slave_acc1 192 168 1 2 13001 slave_acc2 192 168 1 3 3306 health Checking privileges Replication Topology Health 4 4 4 4 4 host port role state gtid_mode health 4 4 4 4 A Sena I ESO MASTER UP ON OK WIZ 5 AL I 2 Soil SLAVE UP ON Slave delay is NNN seconds Ie Alea Ss asie SLAVE wie ON Slave delay is NNN seconds 4 4 4 4 done shell gt mysqlrpladmin master m_account 192 168 1 1 13001 slaves slave_acc1 192 168 1 2 13001 slave_acc2 192 168 1 3 3306 health Checking privileges Replication Topology Health 4 4 4 4 34 How Do Add New Servers to My Topology and Change Master Role l host port role state gtid_mode health 4 4 4
44. show slave status s Display the values from SHOW SLAVE STATUS on the master slave lt source gt Connection information for the slave server To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure Use login paths from your my login cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt suppress Suppress warning messages ssl ca The path to a file that contains a list of trusted SSL CAs ssl cert The name of the SSL certificate file to use for establishing a secure connection ssl cert The name of the SSL key file to use for establishing a secure connection SSl Specifies if the server connection requires use of SSL If an encrypted connection cannot be established the connection attempt fails Default setting is 0 SSL not required 175
45. slave root root localhost 3306 masters root root localhost 3307 root root localhost 3308 log rplms_daemon log pidfile rplms_daemon pid daemon restart Stop multi source replication running as a daemon shell gt mysqlrplms slave root root localhost 3306 masters root root localhost 3307 root root localhost 3308 log rplms_daemon log pidfile rplms_daemon pid daemon stop RECOMMENDATIONS You should set read_only 1 in the my cnf file for the slave to ensure that no accidental data changes such as INSERT DELETE UPDATE and so forth are permitted on the slave other than those produced by events read from the master PERMISSIONS REQUIRED The users on the masters need the following privileges SELECT and INSERT privileges on mysql database REPLICATION SLAVE REPLICATION CLIENT and GRANT OPTION The slave users need the SUPER privilege The rpl user used as the argument for the rp1 user 160 option is either created automatically or if it exists it needs the REPLICATION SLAVE privilege 163 mysql rpladmin Administration utility for MySQL replication 5 20 mysqlrpladmin Administration utility for MySQL replication This utility permits users to perform administrative actions on a replication topology consisting of a master and its slaves The utility is designed to make it easy to recover from planned maintenance of the master or from an event that takes the master offline unexp
46. surname USING BTREE CREATE INDEX idx_surname ON test_db indexcheck_test surname USING BTREE may be redundant or duplicate of CREATE INDEX idx_reverse_name ON test_db indexcheck_test surname name USING BTREE ALTER TABLE test_db indexcheck_test ADD PRIMARY KEY emp_id may be redundant or duplicate of 28 Need to Find an Object on My Server But All Have is a Partial Name How Do Find All Objects with That Name Prefix CREATE INDEX idx_id_name ON test_db indexcheck_test emp_id name USING BTREE CREATE INDEX idx_id_hdate ON test_db indexcheck_test emp_id hire_date USING BTREE may be redundant or duplicate of CREATE INDEX idx_id_name ON test_db indexcheck_test emp_id name USING BTREE CREATE INDEX idx id bday ON test _ db indexcheck test emp id birthday USING BTREE may be redundant or duplicate of CREATE INDEX dx_id_name ON test_db indexcheck_test emp_id name USING BTREE The following indexes for table test_db indexcheck_test contain the clustered index and might be redundant CREATE INDEX idx_uemp_id gt ON test_db indexcheck_test emp_id USING BTREE CREATE INDEX dx_id_name ON test_db indexcheck_test emp_id name USING BTREE CREATE INDEX idx_id_hdate ON test_db indexcheck_test emp_id hire_date USING BTREE CREATE INDEX id
47. the Open Source Definition Historically most but not all Python releases have also been GPL compatible the table below summarizes the various releases Release Derived Year Owner GPL from compatible 1 O 9 0 tclrmew i 2 IS 11 S S 5 CWI yes es eiat ieSe ile 1965 1996 CNRI yes I W52 2000 CNRI no AO eG 2000 BeOpen com no A IG 200 CNRI yes 2 2 A Pe lla sera 200 PSF no AeWed 2a Op ll Sie il 200 PSF yes Real ee Be Meee 0 il 200 PSF yes ee Qualls 200 PSF yes Pacelli 21I 2002 PSF yes 2S 2m2 2002 PSE yes Dili 2m2 2002 PSF yes 22A Dee 2002 PSF yes Delis Behe 2003 PSF yes 2m eee 2002 2003 PSF yes eee oe 23 2002 2003 PSF yes 2 ree ieee 2002 2003 PSF yes Cee a Qe Sie 2002 2003 PSF yes 273 4 hn Sh 8 2004 PSF yes Rene es Qe Sin 2005 PSF yes 2 4 nS 2004 PSF yes 2 4 1 2 4 2005 PSF yes Zee 2 4 2005 PSF yes Dede Bethe 2006 PSF yes Be 2 4 2006 PSF yes ae heal 25 2007 PSF yes aerate Bide 2008 PSF yes DOS Behn 2 2008 PSF yes Ba 23 2008 PSF yes Bead 2B 2008 PSF yes Bee 2 ove 2009 PSF yes 242 Python License Levies Oe 2009 PSF yes 2 6 4 Cae 2010 PSH yes Ze 2 2010 PSE yes HOOEMOLeS 1 GPL compatible doesn t mean that we re distributing Python under the GPL All Python licenses unlike the GPL let you distribute a modified version without making your changes open source The GPL compatible licenses make it possible to combine Python with other software that is released under the GPL
48. use the Note R The repository does not work for Debian 7 because MySQL Utilities requires source code repository to install MySQL Utilities After you download the file install it using the following command or similar depending on your specific release or version of Debian shell gt sudo dpkg i mysql utilities 1 6 3 debian6 0_all deb Note R MySQL Utilities requires Connector Python to be installed For additional information see Section 1 1 Prerequisites 1 5 Microsoft Windows Either install MySQL Utilities using the MySQL Installer for Windows a system that manages installations and updates for all MySQL products on Windows or download and execute the standalone file The download links are as follows e MySQL Installer Download and execute the MySQL Installer MSI file Select the MySQL Utilities product and then proceed with the installation This is the recommended approach and it will also automatically select and install the required prerequisites See the MySQL Installer manual for additional details e Standalone Download and execute the MySQL Utilities standalone MSI file Note R MySQL Utilities requires Connector Python to be installed For additional information see Section 1 1 Prerequisites 1 6 OS X The dmg file available for OS X is built for x84 64 bit platforms and supports OS X version 10 7 Lion and newer After you download the dmg file install MySQL Utilities by opening it an
49. 000007 lave relay bin 000008 lave relay bin 000009 lave relay bin 000010 lave relay bin 000011 lave relay bin 000012 lave relay bin 000013 lave relay bin 000014 lave relay bin 000015 lave relay bin 000016 DADNDAAARAR NHN NH done Move available binary log files from a running slave matching the specified sequence numbers shell gt mysqlbinlogmove server user pass localhost 3311 log type all sequence 2 4 7 11 13 archive slave binlog_dir Applying sequence filter to bin log files Moving bin log files slave bin 000002 slave bin 000004 slave bin 000005 slave bin 000006 Hilnishanigebanasye looser Applying sequence filter to relay log files Moving relay log files lave relay bin 000002 lave relay bin 000004 lave relay bin 000005 lave relay bin 000006 lave relay bin 000007 lave relay bin 000011 lave relay bin 000013 ANH HDHD YN Flushing relay logs done Move available binary log files modified two days ago from a running slave shell gt mysqlbinlogmove server user pass localhost 3311 log type all modified before 2 archive slave binlog_dir Applying modified date filter to pin log files Moving bin log filles slave bin 000001 slave bin 000002 slave bin 000003 Hius mingr pinan Ilex o 5 Applying modified date filter to relay log files Moving relay log files slave relay bin 0
50. 182 5 24 mysqlserverclone Clone Existing Server to Create New Server cccccseeeceeeeneeeeeees 189 5 25 mysqlserverinfo Display Common Diagnostic Information from a Servet n 191 5 26 mysqislavetrx Slave transaction skip Utility 0 0 0 0 ccc ce eeeeeeeeee esac ae eeeeeeeeeeeeaeaaeaneeeeeees 195 5 27 mysqluc Command line client for running MySQL Utilities 2 2 0 0 eee eeeeeeee teen eeeeees 198 5 28 mysqluserclone Clone Existing User to Create New USE ceccceceeeeeeeeeeeeeeeeeees 202 This chapter includes the manual pages for each of the utilities Each manual page is formatted similar to a typical Unix man page 5 1 mysqlauditadmin Allows users to perform maintenance action on the audit log This utility allow you to maintain the audit log allowing you to monitor the audit log file growth and control its rotation Rotation refers to the action of replacing the current audit log file by a new one for continuous use renaming with a timestamp extension and copying the previously used audit log file to a defined location This utility allows you to view and modify a subset of audit log control variables display the audit log file status perform on demand rotation of the log file and copy files to other locations These features enable you to easily monitor the audit log file growth and control its rotation automatically based on the defined file size threshold or manually by a on demand co
51. 26 S0 0 None None None c 0 Connect 201 2 0 07 Boe 50 55 i localhost tester Poon 12 0 Connect 2012 10 01 EI S AA 2 localhost tester Soon 12 4 4 4 4 4 4 4 To display the audit log entries with a specific status use the following command shell gt mysqlauditgrep status 1100 1199 1046 SERVER data audit log 4 4 4 4 STATUS TIMESTAMP NAME SOLTEXT 4 4 4 4 1046 P20 SOS Omi Sis 2cen Ouery ue Nshowmcaolesmtestu 1046 2012 10 10T15 57 36 Query show tables test LAG 2012 10 10T17 44 55 Query select from teste employees where salary gt 500 and sala 1046 20A2 i101 Oily 3479 a7 Query select from test_encoding where value esegi 4 4 4 4 Note R You can view all successful commands with status 0 and all unsuccessful commands with status 1 9999 To display the audit log entries matching several search criteria use the following command shell gt mysqlauditgrep users root start date 0 end date 2012 10 10 event type Query query type SET status 0
52. 4 STATUS SERVER_ID NAME TIMESTAMP CONNECTION_ID HOST USER F 4 4 4 4 4 4 0 Connect 2012 09 Z2eTlls26 50 9 localhost root t 0 Query ZOLA 2 fey il iL BAS 3 y0 9 None root t 0 Ping 2012 09 Zellle26 50 9 None POOE t 0 Query Z2OVI2Z 09 Z ew il le 26 3 S10 9 None root t 0 Query ZOU2ZOI Z ew il ik 26 3 S10 9 None root t 0 Ping 2012 09 2er bls 26250 9 None DOOL t 0 Query ZOU VOR SMEAG 9 None root t 0 Out 2012 09 2e1 bis 26250 9 None Foot t 0 Connect 2012 10 07 TS 355755 1L Igcalnost tester2 r 0 Query AQI2 LO 10 wil ss 55 355 1 None tester2 r 0 Query Z2OI2 LO LOWS 356 30 il None tester2 r 1046 Query AQVI2 LO LOW s5 7 326 i None tester2 r 1046 Query 20i o LOW 535 7 336 i None tester2 r 0 Query AQVI2 LO LOT Ss 7 3 Sil i None tester2 r Orie 20pm O ES 1 None tester2 r 0 Connect 2012 10 LOTL 7235342 2 localhost tester2 r 0 Query AQI2 LO LOWiL 335342 2 None tester2 r 0 Quit 202m O EO 22 2 None tester2 r 4 4 4 4 4 4 4 73 EXAMPLES To display the audit log entries for a specific date time range use the following command shell gt mysqlauditgrep start date 2012 09 27T13 33 47 end date 2012 09 28 SERVER data audit log
53. 4 4 4 192 168 i il 13001 MASTER WE ON OK 192 168 1 2 13001 SLAVE We ON OK Do226el1 3 SSE SLAVE we ON OK 4 4 4 4 4 4 done shell gt mysqlrpladmin master m_account 192 168 1 1 13001 slaves slave_acc1 192 168 1 2 13001 slave_acc2 192 168 1 3 3306 new master slave_accl localhost 13002 demote master switchover Checking privileges Performing switchover from master at 192 168 1 1313001 to slave at 192 168 1 2213001 Checking candidate slave prerequisites Checking slaves configuration to master Waiting for slaves to catch up to old master Stopping slaves Performing STOP on all slaves Demoting old master to be a slave to the new master Switching slaves to new master Starting all slaves Performing START on all slaves Checking slaves for errors Switchover complete Replication Topology Health 4 4 4 4 4 4 host Pore role state gtid_mode health 4 4 4 4 4 LIZ 68 1 2 at SOO iL MASTER Ue ON OK LIZ MGE ie i it SO iL SLAVE WE ON OK 192 6 1 3 S306 SLAVE We ON OK 4 4 4 4 4 4 Discussion As with our previous s
54. 6 x86_64 plugin_dir usr local mysqli 5 1 50 osxi0 6 x86_64 lib plugin Conplquerilcr Clec mymeme binary_log my_log 000286 pinary alog posk 23 relay_log None relay_log_pos None l rov done Discussion The mysqlserverinfo utility is normally used to find information about a particular server We can see such results in the example above However the utility also has an option show servers that displays a list of all of the MySQL server process ids that are executing on the host This quick glance can help diagnose problems with multiple instances on the same machine 48 How Can I Use a secure encrypted connection between Utilities and a MySQL Server Permissions Required The permissions required include the ability to read the mysql database and to have read access to the data directory Tips and Tricks Notice the output shows the data directory for each server You can use this information to examine the files in that folder to discern more information such as what databases exist and find and examine the binary log etc On POSIX systems you can discover the command line arguments such as the port number the server is using with the ps f PID command For example to discover the complete information for PID 2487 you can do the following shell gt ps f 2487 UID iD PPID C STIME EEY TIME CMD SOL 2487 I O 10 58AM ttys001 0 00 41 source mysql 5 6 sql mysqld no defaults datadir source t
55. Are there binary logging exceptions such as _do_db or _ignore_db settings If so display them 3 Does the replication user exist on the master with the correct privileges 4 Are there server_idconflicts 5 Is the slave connected to this master If not display the master host and port 6 Are there conflicts between the master info file on the slave and the values shown in SHOW SLAVE STATUS on the master 7 Are the InnoDB configurations compatible plugin vs native 8 Are the storage engines compatible have same on slave as master 9 Are the lower_case_tables_names settings compatible Warn if there are settings for lowercase uppercase table names that can cause problems See Bug 59240 10 Is the slave behind the master The utility runs each test in turn unless there is a fatal error preventing further testing such as a loss of connection to the servers Each test can complete with one of the following states pass the prerequisites are met fail the prerequisites were met but one or more errors occurred or there are exceptions to consider or warn the test found some unusual settings that should be examined further but may not be in error Use the verbose option to see additional information such as server IDs lower_case_table_name settings and the contents of the master information file on the slave To see the values from the SHOW SLAVE STATUS statement use the show slave status option
56. But All Have is a Partial Name How Do Find All Objects with That Name Prefix 00cccccceeeeeeaceeeeeeeeeeeeeaeaaeeeeeeeeeeeeaeaaeaneeeeeeeeeaeaaaaeenees 29 3 3 7 How Can Run a Process Every Night To Kill Certain Connections s 30 3 4 High Availability Operations 0 cece eee eeee cece eeneeeeee eee e ee ead tect ee esse ae aaeeteeeeeeeeeaeaaeaeeeeeeeeeaeaaes 31 3 4 1 How Can Use Replication crnini ase cece ae eee ee eeee a e i aa Ea aaa aaa ae Eiei 32 3 4 2 How Do Add New Servers to My Topology and Change Master Role ceeeee 34 34 3 Setup Automatic Failover sc csfes vteesecvsncinteyehevad onde da ieaiaia aiar aaan 36 3 4 4 Restore the Previous Master After Failover cccceeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaaes 38 3 4 5 How Can Find All of the Slaves Attached to My Master Server escenes 41 3 4 6 How To Check If Data Is Correctly Replicated cccccceeeeeeeeeeeeeeeeeeeeeaeeaeeeeeeeeeeeeaaa 42 3 4 7 How To Fix Errant Transactions on the Replication Topology seseeeeeeeeeeeeneeees 44 3 5 SOVE OPSratlONS zen a Aaaa detea ccchen ve lavadenntodaceotanesg oes aeaedeaedaeigdeaneantshaaeisatuancatcet cade 46 3 5 1 How Do Make A Temporary Copy of My Server For Testing c ccccsseseeseeeeeeeeeaes 46 3 5 2 How Can Find What MySQL Servers Are RUNNING ccceeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaee 48 3 5 3 How Can Use a secure encrypted connecti
57. It does not copy data However mysql dbcopy makes a copy of the data and mysqluserclone clones the users You could run each of these utilities in sequence and that would work but we are lazy at heart and want something that not only copies everything but also finds it for us That is we want a one command solution The good news is that this is indeed possible and very easy to do Let us start by breaking the problem down into its smaller components In a nutshell we must perform these tasks e Connect to the original server 207 Example Find all of the databases Find all of the users e Make a clone of the original server Copy all of the databases Copy all of the users If you look at the utilities and the modules just listed you see that we have solutions and primitives for each of these operations So you need not even call the MySQL utilities directly although you could Now let us dive into the code for this example The first task is to connect to the original server We use the same connection mechanism as the other MySQL utilities by specifying a server option like this parser add_option server action store dest server type sString default root localhost 3306 help connection information for original server in the form lt user gt lt password gt lt host gt lt port gt lt socket gt Once we process the options and arguments connecting to the server is easy Use the parse_c
58. NOT apply to the OpenSSL libraries it is 251 Python License Supplement Windows Only licensed under the following license E N T ct S O c eceive If you do not ersion of Python pen Source licenses wish to install he OpenSSL toolkit stays under a dual he OpenSSL License and the original SSLeay license apply to the toolkit In case of any 1 separately from the Oracle programs you L this program you may Uninstall this 1 license i e both the conditions of ee below for the actual license texts Actually both licenses are BSD style license issues related to OpenSSL please ontact openssl core openssl org penSSL License Copyright c 1998 2011 The OpenSSL Project All rights reserved Redistribution and use in source and binary forms with or without modification are permitted provided that the following conditions i eles MECE 1 Redistributions of source code must retain the above copyright notice this list of conditions and the following disclaimer 2 Redistributions in binary form must reproduce the above copyright 28 notice this list of conditions and the following disclaimer in ja the documentation and or other materials provided with the X distribution 3 All advertising materials mentioning features or use of this ia software must display the following acknowledgment ia This product includes software deve
59. ON util_test EXAMPLES Q RANT DROP EXECUTE TRIGGER ON TO priv_test_user3 s GRANT UPDATE DELETE ALTER ROUTINE ON util_test TO priv_test_user3 TABTE mE NECESE 6 CAE For joe user GRANT ALL PRIVILEGES ON util_test TO joe user For joe_wildeard s GRANT ALL PRIVILEGES ON util_test TO joe_wildcard For ipriv test user Gik GRANT EXECUTE TRIGGER ON util_test TO priv_test_user WITH GRANT OPTION GRANT SELECT UPDATE ON TO priv_test_user ROn priv test UsSer21 0 GRANT SELECT UPDATE SHUTDOWN EXECUTE ON TO priv_test_user2 For priv_test_usera s GRANT DROP EXECUTE TRIGGER ON TO priv_test_user3 GRANT UPDATE DELETE ALTER ROUTINE ON util_test TO priv_test_user3 TABERE teal Sse o ies 3 For joe user GRANT ALL PRIVILEGES ON util_test gt TO joe user For joe_wildcard s GRANT ALL PRIVILEGES ON util test TO joe_wildcard s For priv_test_user s GRANT EXECUTE TRIGGER ON util_test TO priv_test_user WITH GRANT OPTION GRANT SELECT UPDATE ON TO priv_test_user HOG Pisivinee Simson Za Gas GRANT SELECT UPDATE SHUTDOWN EXECUTE ON TO priv_test_user2 For priv test usero Cisi GRANT DROP EXECUTE TRIGGER ON TO priv_test_user3 RAN SHU CM ON UeiibtSst ES TOpriv tost USers Gils GRANT UPDATE DELETE ALTER ROUTIN
60. Ping Prepare Processlist Query Quit Refresh Register Slave Reset stmt Set option Shutdown Sleep Statistics Table Dump Time In terms of output formats the following are supported beside CSV GRID used by default TAB VERTICAL and RAW corresponding to the original XML format of the audit log file Permissions Required The user must have permissions to read the audit log on disk Tips and Tricks The values for the vent type and format options are case insensitive therefore lower and upper cases can be mixed to specify these values as long as a supported event type name or format is used Unlike them the value specified for the users option is case sensitive so be careful not to mix upper and lower cases here It is possible to find some event type values with a space in the middle for example like Binlog Dump or Init DB If one of such values needs to be specified for the event t ype option then it must be surrounded by double or single quotes depending on the operating system 57 58 Chapter 4 Overview of MySQL Utilities Table of Contents 4 1 Binary Log Operations sav iscccdeehs dies Sedieeeecd eeeedincedieed Sait Geen ie eae eielieed ant adie 59 4 2 Database Operations cc ccec cece eee ee cece ect ee teeter ee ee eee teen tees ee eae ete aea ea aeaea nia 59 4 3 General Operations siioni keane an area nd rds Sela aan Aa a RREA 60 4 4 High Availability Operations 2 0 2 2
61. RESET MASTER command on the destination prior to executing the copy Cloning databases that contain foreign key constraints does not change the constraint in the cloned table For example if table do1 t1 has a foreign key constraint on table db1 t2 when db1 is cloned to db2 table db2 t1 will have a foreign key constraint on db1 t2 The path to the MySQL client tools should be included in the PATH environment variable in order to use the authentication mechanism with login paths This will allow the utility to use the my_print_defaults tools which is required to read the login path values from the login configuration file mylogin cnf If any database identifier specified as an argument contains special characters or is a reserved word then it must be appropriately quoted with backticks In turn names quoted with backticks must also be quoted with single or double quotes depending on the operating system i e in 99 EXAMPLES Windows or in non Windows systems in order for the utilities to read backtick quoted identifiers as a single argument For example to copy a database with the name weird db name with other weird db name the database pair must be specified using the following syntax in non Windows weird db name other weird db name Keep in mind that you can only take advantage of multiprocessing if your system has multiple CPUs available for concurrent execution Also note that multiprocessing is app
62. RPL_FILE replication file RPL_FILE The path and file name where the generated replication information should be written Valid only with the rp1 option rpl user lt replication_user gt The user and password for the replication user requirement in the format lt users lt password gt or lt login path gt For example rp1 passwd The default is None server lt server gt Connection information for the server To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure Use login paths from your my login cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt ssl ca The path to a file that contains a list of trusted SSL CAs ssl cert The name of the SSL certificate file to use for establishing a secure connection ssl cert The name of the S
63. Reading the books frm file CREATE statement for usr local mysql data kindle books frm CREATE TABLE welford_kindle books ISBN char 32 NOT NULL PRIMARY KEY title char 128 DEFAULT NULL purchase_date date DEFAULT NULL cost float 10 2 DEFAULT NULL ENGINE MyISAM DEFAULT CHARSET latinl done Discussion For this example we used three required parameters the base directory for the offline server basedir a new port to use for the spawned server port and a user name to use to run the spawned server port The later is necessary since we must launch the mysql frm utility as root sudo in order to be able to read copy files from the protected data directory of the host server The port option is always required for running the utility in default mode it is not needed for diagnostic mode You must supply a valid unused port The utility will check to see if the port is in use and if so will produce an error We use the basedir option instead of the server option because we were faced with a situation where the original server was offline down Note that you can use the basedir option for a running server if you do not want the utility to connect to the original server in any way Permissions Required The permissions for using mysql frm will vary and depend entirely on how you use it If you use the utility to read frm files in a protected folder like the example above in either mode
64. Role 34 3 4 3 Setup Automatic Failover 0 ccccceccccceceeeeeeeeeeeeeaeaeeeeeeeeeeeeeaeaaaaneeeeeeeesaeaaaaneeeeeees 36 3 4 4 Restore the Previous Master After Failover ccceeeeeeenneeeeeeaaeeeeeeaaeeeeeeaaeeees 38 3 4 5 How Can Find All of the Slaves Attached to My Master Server 0 cceeeee 41 3 4 6 How To Check If Data Is Correctly Replicated ccc ceeeeeeeeeeeeeeeaetneeeeeeeeeeeeaee 42 3 4 7 How To Fix Errant Transactions on the Replication Topology cceeeeeeee 44 3 5 Server Operations medrent eet isn Meee deh shea ade ea e a uke E Oe aAa aed Tate Ge 46 3 5 1 How Do Make A Temporary Copy of My Server For Testing sseseeeeeeees 46 3 5 2 How Can Find What MySQL Servers Are Running ceeeeeeeeeeeeeeeeeeeeeeeaee 48 3 5 3 How Can Use a secure encrypted connection between Utilities and a MySQL SEIVEM AE AEE O E E TA E T A N at waeeti E ASET 49 3 6 Specialized Operations semiari ii ea ia iid ii ia iiaa iaa 53 3 6 1 How Do Record Only Login Events 0 cccccceceeeeeeeeeeeeeeeeeeeaaeaeeeeeeeeeeeeaaaaeeees 53 3 6 2 How Do Copy Move The Audit Log cccceeeeeeeeeeeeeeeaeeeeeeeeeeeeeeeaeaaeeneeeeeeeeeaaa 54 3 6 3 How Do Show All INSERT and UPDATE Queries That Failed eee 55 3 6 4 How Do Display Connections by the User root and Show the Result in CSV PONMALS Ss ntetaress 1 E T eee ree E tei memset tat nat h
65. The manual concludes with a look at extending the MySQL Utilities library a look at the developer testing environment and a list of frequently asked questions Legal Notices Copyright 2006 2015 Oracle and or its affiliates All rights reserved This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws Except as expressly permitted in your license agreement or allowed by law you may not use copy reproduce translate broadcast modify license transmit distribute exhibit perform publish or display any part in any form or by any means Reverse engineering disassembly or decompilation of this software unless required by law for interoperability is prohibited The information contained herein is subject to change without notice and is not warranted to be error free If you find any errors please report them to us in writing If this is software or related documentation that is delivered to the U S Government or anyone licensing it on behalf of the U S Government then the following notice is applicable U S GOVERNMENT END USERS Oracle programs including any operating system integrated software any programs installed on the hardware and or documentation delivered to U S Government end users are commercial computer software pursuant to the applicable Federal Acquisition Regulation and agency specific
66. To exclude specific objects by name use the exclude option with a name in db obj format or you can supply a search pattern For example exclude db1 trigi excludes the single trigger and exclude t rig_ excludes all objects from all databases having a name that begins with trig and has a following character To skip objects by type use the skip option with a list of the objects to skip This enables you to extract a particular set of objects say for exporting only events by excluding all other types Similarly to skip creation of UPDATE statements for BLOB data specify the skip blobs option To specify how to display output use one of the following values with the format option 101 mysqldbexport Export Object Definitions or Data from a Database sql default Display output using SQL statements For definitions this consists of the appropriate CREATE and GRANT statements For data this is an INSERT statement or bulk insert if the bulk insert option is specified grid Display output in grid or table format like that of the mysql client command line tool e CSV Display output in comma separated values format tab Display output in tab separated format vertical Display output in single column format like that of the G command for the mysq1 client command line tool To specify how much data to display use one of the following values with the display option brief Display
67. a false negative that the slave is not connected to the master The path to the MySQL client tools should be included in the PATH environment variable in order to use the authentication mechanism with login paths This will allow the utility to use the my_print_defaults tools which is required to read the login path values from the login configuration file mylogin cnf Due to a known server issue there are some limitations with the use of temporary tables with multi source replication In order to avoid problems we recommend the execution of all statements for a temporary table in a single transaction See Replication and Temporary Tables for more information EXAMPLES To set up multi source replication among two masters and a slave running on different ports of the same host using the default settings use this command shell gt mysqlrplms slave root root localhost 3306 masters root root localhost 3307 root root localhost 3308 Starting multi source replication Prec me DRl Catiomciulciitan Switching Eo master localhost 2307 master on localhost connected slave on localhost connected Current Master Information 4 4 Binary Log File Position E Ss we aa St clone bin 000001 pf Ra a ae GTID Executed Set 00a4e027 a83a 1le3 8bd6 28d244017 26 1 2 Health Status 4 4 4 4 4 4 host
68. a process It is needed to identify and control the process forked by mysqlfailover ping lt number gt Number of ping attempts for detecting a downed server Default is 3 seconds Note R On some platforms this is the same as number of seconds to wait for ping to return report values lt report_values gt Report values used in mysqlfailover running as a daemon It can be health gtid or uuid Multiple values can be used separated by commas e health Display the replication health of the topology gtid Display the master s list of executed GTIDs contents of the GTID variables GLOBAL GTID_EXECUTED GLOBAL GTID_PURGED and GLOBAL GTID_OWNED e uuid Display universally unique identifiers UUIDs for all servers Default health rpl user lt replication_user gt The user and password for the replication user requirement in the form lt user gt lt passwora gt or lt login path gt E g rpl passwd Default None script threshold lt return_code gt Value for external scripts to trigger aborting the operation if result is greater than or equal to the threshold Default None no threshold checking seconds behind lt seconds gt Used to detect slave delay only for health reporting purposes The maximum number of seconds behind the master permitted before slave is considered behind the master in the health report state Default 0 slaves lt slave connections gt
69. apply the Apache License to your work attach the following boilerplate notice with the fields enclosed by brackets replaced with your own identifying information Don t include the brackets The text should be enclosed in the appropriate comment syntax for the file format We also recommend that a file or class name and description of purpose be included on the same printed page as the copyright notice for easier identification within third party archives Copyright yyyy name of copyright owner 229 Apache License Version 2 0 January 2004 Licensed under the Apache License Version 2 0 the License you may not use this file except in compliance with the License You may obtain a copy of the License at http www apache org licenses LICENSE 2 0 Unless required by applicable law or agreed to in writing software distributed under the License is distributed on an AS IS BASIS WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied See the License for the specific language governing permissions and limitations under the License 8 2 2 Apache License Version 2 0 January 2004 The following applies to all products licensed under the Apache 2 0 License You may not use the identified files except in compliance with the Apache License Version 2 0 the License You may obtain a copy of the License at http www apache org licenses LICENSE 2 0 A copy of the license is also reproduced below Unless
70. binary forms with or without modification are permitted provided that the following conditions are meti 1 Redistributions of source code must retain the copyright notice this list of conditions and the following disclaimer 2 Redistributions in binary form must reproduce the above copyright notice this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution 3 All advertising materials mentioning features or use of this software must display the following acknowledgement This product includes cryptographic software written by Eric Young eay cryptsoft com The word cryptographic can be left out if the rouines from the library being used are not cryptographic related 4 If you include any Windows specific code or a derivative thereof from the apps directory application code you must include an acknowledgement This product includes software written by Tim Hudson tjh cryptsoft com HIS SOFTWARE IS PROVIDED BY ERIC YOUNG AS IS AND NY EXPRESS OR IMPLIED WARRANTIES INCLUDING BUT NOT LIMITED TO THE MPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE RE DISCLAIMED IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE OR ANY DIRECT INDIRECT INCIDENTAL SPECIAL EXEMPLARY OR CONSEQUENTIAL DAMAGES INCLUDING BUT NOT LIMITED TO PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES LOSS OF USE DATA OR PROFITS OR BUSINESS INTERRUPTION HOW
71. command is used to perform an on demand audit log rotation and only requires the server option to be passed Note this command has no effect if the audit log file size is smaller than 4096 which is the minimum value allowed that is greater than 0 for the audit_log_rotate_on_size variable OPTIONS mysqlauditadmin accepts the following command line options audit log name lt AUDIT_LOG_FILE gt Full path and file name for the audit log file Used by the file stats option and the copy command copy to lt COPY_DESTINATION gt The location to copy the specified audit log file The path must be locally accessible for the current user file stats Display the audit log file statistics help Display a help message and exit license 64 OPTIONS Display license information and exit remote login lt REMOTE_LOGIN gt User name and host to be used for the remote login for copying log files It is defined using the following format lt user gt lt host or IP gt Usage will prompt for the password server lt SERVER gt Connection information for the server To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include
72. consequence of a court judgment or allegation of patent infringement or for any other reason not limited to patent issues conditions are imposed on you whether by court order agreement or otherwise that contradict the conditions of this License they do not excuse you from the conditions of this License If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations then as a consequence you may not distribute the Library at all For example if a patent license would not permit royalty free redistribution of the Library by all those who receive copies directly or indirectly through you then 238 GNU Lesser General Public License Version 2 1 February 1999 the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library If any portion of this section is held invalid or unenforceable under any particular circumstance the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices Many people have made generous contributions to the wide range of software distribu
73. corresponding objects on server1 The default direction is server1 For the sql difference format you can also see the reverse transformation by specifying the show reverse option The utility stops at the first occurrence of missing objects or when an object does not match To override this behavior specify the force option to cause the utility to attempt to compare all objects listed as arguments OPTIONS mysqldiff accepts the following command line options e help Display a help message and exit e license Display license information and exit e changes for lt direction gt Specify the server to show transformations to match the other server For example to see the transformation for transforming object definitions on server1 to match the corresponding definitions on server2 use changes for server1 Permitted values are server1 and server2 The default is server a B OPTIONS character set lt charset gt Sets the client character set The default is retrieved from the server variable character_set_client difftype lt difftype gt d lt difftype gt Specify the difference display format Permitted format values are unified default context differ and sql compact Compacts the output by reducing the control lines that are displayed in the diff results This option should be used together with one of the following difference types unified or context force Do not halt at
74. data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt server2 lt source gt Connection information for the second server To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt e Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt show reverse Produce a transformation report containing the SQL statements to conform the object definitions specified in reverse For example if changes for is set to server1 also generate the transformation for server2 Note The reverse changes are annotated and marked as comments skip checksum table Skip the CHECKSUM TABLE step in the data consistency check Added in release 1 4 3 skip data check Skip
75. display gt d lt display gt Control the number of columns shown Permitted display values are brief minimal columns for object creation full all columns and names only object names not valid for format sql1 The default is brief exclude lt exclude gt x lt exclude gt Exclude one or more objects from the operation using either a specific name such as db1 tlora search pattern Use this option multiple times to specify multiple exclusions By default patterns use LIKE matching With the regexp option patterns use REGEXP matching This option does not apply to grants export lt export gt e lt export gt Specify the export format Permitted format values are definitions export only the definitions metadata for the objects in the database list data export only the table data for the tables in the database list and both export the definitions and the data The default is definitions file per table Write table data to separate files This is Valid only if the export output includes data that is if export data or export both are given This option produces files named db_name tb _name format For example a csv export of two tables named t1 and t2 in database d1 results in files named db1 t1 csv and db1 t2 csv If table definitions are included in the export they are written to stdout as usual format lt format gt f lt format gt Specify the output display format Permitted fo
76. effort approximation of the CREATE statement Due to the many complexities of the server code the diagnostic mode does not currently process all features of a table Future revisions will improve the accuracy of the diagnostic mode If the diagnostic mode is only a best effort compilation why use it The diagnostic mode is used to attempt to read corrupt or otherwise damaged frm files You would also use it if you had no access to a server installation on the local machine Why does the default mode require a server The default mode uses a server to create a temporary working copy of the server instance It does not access the donor server in any way other than to execute the mysqld exe process Can the frm reader read any frm file Although it can read most frm files there are known limits to which storage engines it can process correctly Currently tables with storage engines partition and performance_schema cannot be read However these frm files can be read by the diagnostic mode My frm files are tucked away in a restricted folder How do get access to them to run the frm reader without copying or modifying file privileges You can use elevated privileges such as su or sudo to execute the frm reader You must use the user option to specify a user to launch the spawned server however This will permit the frm reader to read the original frm file and copy it to the spawned server and access the copy witho
77. establish multi source replication slaves attached to a master replication synchronization checker utility start another instance of a running server server information clone a MySQL user account to one or more new users mysqluc gt help mysqldb TAB TAB Utility mysqldbcompare mysqldbcopy mysqldbexport mysqldbimport export import Description compare databases for consistency copy databases from one server to another metadata and data from databases metadata and data from files mysqluc gt mysqlrplshow m TAB TAB master MASTER max depth MAX_DEPTH Description connection information for master server in the form lt user gt lt password gt lt host gt lt port gt lt socket gt One lOcgmnSOciehe pOmeN Sockets limit the traversal to this depth Valid only with the recurse option Valid values are non negative integers mysqluc gt mysqlrplshow mast TAB er lt user gt lt password gt localhost 13001 The console has detected that the utility You can get more information about the error by running the console command ended with an error code show last mysqlrplshow mysqluc gt show last error Execution of utility mysqlrplshow master lt user gt lt password gt localhost 13001 returned errorcode 2 with error message 26 Sugiaeyell s What Options Are Used With Each Utility Usage mysqlrplshow py master root localhost 3306 mys
78. example of how to build a customized utility using the MySQL Utilities scripts and libraries import optparse impor os import sys from mysql utilities import VERSION_FRM from mysql utilities command import dbcopy from mysql utilities command import serverclone from mysql utilities command import userclone from mysql utilities common server import Server from mysql utilities common options import parse_connection from mysql utilities exception import UtilError Constants NAME example copy_server DESCRIPTION copy_server copy an existing server USAGE Sprog server user pass host port socket new dir lt path gt new id lt server_id gt new port lt port gt databases lt db list gt users lt user list gt Setup the command parser parser optparse OptionParser version VERSION_FRM format program os path basename sys argv 0 description DESCRIPTION usage USAGE add_help_option False parser add_option help action help Setup utility specific options Connection information for the source server parser add_option server action store dest server type string default root localhost 3306 help connection information for original server in the form lt user gt lt password gt lt host gt lt port gt lt socket gt Data directory for new instance 211 MySQL Utilities copy_server py sample parser add_option
79. exists and is located in the directory MySQL SERVER data The below example show how easy it is to perform the desired search with the mysqlauditgrep utility Example Execution shell gt mysqlauditgrep query type INSERT UPDATE status 1 9999 MySOQL SERVER data audit log e E STATUS TIMESTAMP NAME SOLTEXT CONNECTION e Ee 1046 2OLS O OlwiIss2oeas Clery TNS ERTEN TOTE pinot resistia O C VAUS iL 2 3 l 37 1146 Eoia EOE ea eO Oey NS EREN Om T e p Enot kenis Ea D C VArUES PA eSa 37 1054 2OLS O8 OlwiIss2seie Chery INSERM INGO Tesic teil Aplopincie_e oll WAUINS il 2 3 37 1146 2013 08 O1T18 26 14 Query UPDATE tbhil_not exist SET a 1 37 1054 2OLS O Oise 2ecs Clery WPA icesic ceil Siw mer col il 37 a Discussion As expected the use of the mysqlauditgrep utility requires the specification of the target audit log file to search and a few options corresponding to the needed search criteria In this case the query type option was used to restrict the displayed results to specific types of queries i e only INSERT and UPDATE and the status option was used to specify the considered MySQL error codes i e all ranging from 1 to 9999 The query type option allows the specification of a comma separated list of different SQL statements Apart from INSERT and UPDATE the list of supp
80. export from a server that has GTIDs enabled will by default include the GTIDs of all transactions even those that changed suppressed parts of the database If you don t want to generate the GTID statement use the skip gtid option To export all databases use the all and export both options done Discussion There are several operations listed here The first one we see is the execution of the mysqldbexport utility to create a file that includes an export of all databases as designated with the a11 option We add the export both option to ensure we include the definitions as well as the data We also add the rpl1 master option which instructs mysqli dbexport to generate the replication commands with respect to the source server being the master Lastly we include the replication user and password to be included in the CHANGE MASTER command Next we see an attempt to run the import using mysqidbimport but we see there is an error The reason for the error is the mysqidbimport utility detected a possible problem on the slave whereby there were global transaction identifiers GTIDs recorded from the master You can see this situation if you setup replication prior to running the import The way to resolve the problem is to run the RESET MASTER command on the slave as shown in the next operation The next operation is a rerun of the import and in this case it succeeds We see a warning that is issued any time there are r
81. following code could be generated to kill all idle connections for user www data shell gt mysqlprocgrep kill connection sql body match user www data match state sleep DECLARE kill_done INT DECLARE kill_cursor CURSOR FOR SELECT Iid User Host Db Command lame States Info FROM INFORMATION_SCHEMA PROCESSLIST WHERE user LIKE www data AND State LIKE sleep OPEN kill cursor BEGIN DECLARE id BIGINT DECLARE EXIT HANDLER FOR NOT FOUND SET kill_done 1 ki logss TOO 153 NOTES FETCH kill cursor TINTO 1d KILL CONNECTION id END LOOP kill_loop END CLOSE kill euirseies ssl ca The path to a file that contains a list of trusted SSL CAs ssl cert The name of the SSL certificate file to use for establishing a secure connection ssl cert The name of the SSL key file to use for establishing a secure connection e ssl Specifies if the server connection requires use of SSL If an encrypted connection cannot be established the connection attempt fails Default setting is 0 SSL not required verbose v Specify how much information to display Use this option multiple times to increase the amount of information For example v verbose vv more verbose vvv debug version Display version information and exit NOTES For the format option the permitted values are not case sensitive In addition values may be specified as any unambiguous prefix of a valid value For ex
82. gt lt ports lt socket gt master log file lt master_log_file gt Begin replication from the beginning of this master log file master log pos lt master_log_pos gt Begin replication from this position in the master log file This option is not valid unless master log file is given pedantic p Fail if both servers do not have the same set of storage engines the same default storage engine and the same InnoDB storage engine rpl user lt replication_user gt The user and password for the replication user in the format lt user gt lt passworad gt or lt login path gt slave lt slave gt Connection information for the slave server To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket e Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt
83. master and either slaves or discover slaves login failover This command is available to only those servers supporting GTIDs Conduct failover to the best slave The command will test each candidate slave listed for the prerequisites Once a candidate slave is elected it is made a slave of each of the other slaves thereby collecting any transactions executed on other slaves but not the candidate In this way the candidate becomes the most up to date slave This command requires the slaves option The discover slaves login option is not allowed because for failover the master is presumed to be offline or otherwise unreachable so there is no way to discover the slaves The master option is ignored for this command gtid This command is available to only those servers supporting GTIDs It displays the contents of the GTID variables GLOBAL GTID_EXECUTED GLOBAL GTID_PURGED and GLOBAL GTID_OWNED The command also displays universally unique identifiers UUIDs for all servers This command requires one of the following combinations master and slaves or master and discover slaves login health Display the replication health of the topology By default this includes the host name port role MASTER or SLAVE of the server state of the server UP is connected WARN not connected but can ping DOWN not connected and cannot ping the GTID_MODE and health state This command can be run with the following comb
84. mean any form resulting from mechanical transformation or translation of a Source form including but not limited to compiled object code generated documentation and conversions to other media types Work shall mean the work of authorship whether in Source or Object form made available under the License as indicated by a copyright notice that is included in or attached to the work an example is provided in the Appendix below Derivative Works shall mean any work whether in Source or Object form that is based on or derived from the Work and for which the editorial revisions annotations elaborations or other modifications represent as a whole an original work of authorship For the purposes of this License Derivative Works shall not include works that remain separable from or merely link or bind by name to the interfaces of the Work and Derivative Works thereof Contribution shall mean any work of authorship including the 230 Apache License Version 2 0 January 2004 original version of the Work and any modifications or additions to that Work or Derivative Works thereof that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner For the purposes of this definition submitted means any form of electronic verbal or written communication sent to the Licensor or its representatives includ
85. multiple slaves in comma separated list To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such 166 OPTIONS as server master slave etc The methods include the following in order of most secure to least secure Use login paths from your my login cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt demote master Make master a slave after switchover discover slaves login lt slave_login gt At startup query master for all registered slaves and use the user name and password specified to connect Supply the user and password in the form lt user gt lt passwa gt or lt ogin path gt For example discover joe secret will use joe as the user and secret as the password for each discovered slave exec after lt script gt Name of script to execute after failover or switchover Script name may include the path exec before lt script g
86. mysql utilities parser Parse MySQL Log Files socket Returns Full path of the MySQL server Unix socket Return type str start_datetime Returns Date and time of the first read log entry Return type datetime datetime lastseen_datetime Returns Date and time of the last read log entry Return type datetime datetime class mysql utilities parser SlowQueryLog stream This class parses the MySQL Slow Query Log Instances are iterable but the class does not provide multiple independent iterators For example to read the log and print the entries gt gt gt slow_log open var lib mysql mysql slow log gt gt gt log SlowQueryLog slow_log eee SOF encry in logs print entry Parameters stream file type a valid file type for example the result of the built in Python function open version Returns Version of the MySQL server that produced the log Return type tuple program Returns Full path of the MySQL server executable Return type str port Returns TCP IP port on which the MySQL server was listening Return type int socket Returns Full path of the MySQL server Unix socket Return type str start_datetime Returns Date and time of the first read log entry Return type datetime datetime lastseen_datetime 217 mysql u
87. new master because the switchover command can only be performed with slaves This step will also allows the old master to catch up with the new master If many transaction have been performed on the new master it is recommended to wait a while here to let the old master catch up before switchover otherwise the switchover command might take too much time As expected the execution of the switchover command requires the specification of the current and new master with the master and new master options as well as the list of slaves in the topology using the slaves option without need to list the new master The replication user is specified with the rpl user option In this specific example the use of the option demote master is important because without it the current master Server2 3312 will not be demoted and set as a slave of the new master server1 3311 The mysgirpladmin utility will execute and display information about all required action to perform switchover After completing the switchover process an health report is displayed where it is possible to confirm the successful execution of the command and verify that the topology has changed as expected After completing these simple steps the replication topology is back to its initial structure before failover with its old master Therefore mysql failover is ready to be executed again to monitor the topology and enable automatic failover Note that in this particular
88. of script to execute after failover or switchover Script name may include the path exec before lt script gt Name of script to execute before failover or switchover Script name may include the path exec fail check lt script gt 126 OPTIONS Name of script to execute on each interval to invoke failover exec post failover lt script gt Name of script to execute after failover is complete and the utility has refreshed the health report failover mode lt mode gt f lt mode gt Action to take when the master fails auto automatically fail to best slave elect fail to candidate list or if no candidate meets criteria fail fail take no action and stop when master fails Default auto force Override the registration check on master for multiple instances of the console monitoring the same master See notes interval lt seconds gt i lt seconds gt Interval in seconds for polling the master for failure and reporting health Default 15 seconds Minimum is 5 seconds log lt log_file gt Specify a log file to use for logging messages log age lt days gt Specify maximum age of log entries in days Entries older than this will be purged on startup Default 7 days master lt connection gt Connection information for the master server To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port o
89. of the show slave status command This can be useful for instance to check what might be causing the Is slave connected test to fail We can also use the master log file option to specify the name of the master information file to read Lastly we can use the verbose option in order to get more information about what is happening under the hood 3 4 2 How Do Add New Servers to My Topology and Change Master Role We will examine a scenario similar to the previous one where we want to make one of the two new servers added the master server perhaps because it has better specs and is faster Objectives Our goal in this example it create replication configuration with 3 servers two new ones and an existing one and we want to replicate all the information but make one of the new servers the master server Like the previous example lets assume that the existing server Server1 is running on port 13001 on the local machine with IP 192 168 1 1 that the two new machines with mysql server instances are Server2 running on 192 168 1 2 13001 and Server3 running on 192 168 1 3 3306 We want to make Server2 the new master Example Execution shell gt mysqlreplicate master m_account 192 168 1 1 13001 slave slave_acc1 192 168 1 2 13001 rpl user repl slavepass b master on 192 168 Ilk connected slave on 192 168 12 connected Checking for binary logging on master Setting up replication done shell gt
90. only the minimal columns for recreating the objects e full Display the complete column list for recreating the objects names Display only the object names Note R The display option is ignored when combined with the SQL format output type To turn off the headers for csv or tab display format specify the no headers option To turn off all feedback information specify the quiet option To write the data for individual tables to separate files use the file per table option The name of each file is composed of the database and table names followed by the file format For example the following command produces files named db1 table_name csv mysqldbexport server root serverl 3306 format csv dbl export data By default the operation uses a consistent snapshot to read the source databases To change the locking mode use the locking option with a locking type value Use a value of no locks to turn off locking altogether or lock all to use only table locks The default value is snapshot Additionally the utility uses WRITE locks to lock the destination tables during the copy You can include replication statements for exporting data among a master and slave or between slaves The rp1 option permits you to select from the following replication statements to include in the export master Include the CHANGE MASTER statement to make the destination server a slave of the server specified in the server opt
91. passwa gt lt host gt lt port gt lt socket gt ssl ca The path to a file that contains a list of trusted SSL CAs ssl cert The name of the SSL certificate file to use for establishing a secure connection ssl cert The name of the SSL key file to use for establishing a secure connection Ss 203 NOTES Specifies if the server connection requires use of SSL If an encrypted connection cannot be established the connection attempt fails Default setting is 0 SSL not required e verbose v Specify how much information to display Use this option multiple times to increase the amount of information For example v verbose vv more verbose vvv debug e version Display version information and exit NOTES You must provide connection parameters user host password and so forth for an account that has the appropriate privileges to access all objects in the operation The account used to connect to the source server must have privileges to read the mysql database The account used to connect to the destination server must have privileges to execute CREATE USER and DROP USER if the force option is given and privileges to execute GRANT for all privileges to be granted to the new accounts For the format option the permitted values are not case sensitive In addition values may be specified as any unambiguous prefix of a valid value For example format g specifies the grid format
92. path to a file that contains a list of trusted SSL CAs ssl cert The name of the SSL certificate file to use for establishing a secure connection ssl cert The name of the SSL key file to use for establishing a secure connection e Ssl Specifies if the server connection requires use of SSL If an encrypted connection cannot be established the connection attempt fails Default setting is 0 SSL not required Start S Start the server in read only mode if it is offline With this option you must also give the basedir and datadir options Start timeout Number of seconds to wait for the server to be online when started in read only mode using the start option The default value is 10 seconds The start timeout option is available as of MySQL Utilities 1 2 4 1 3 3 verbose v Specify how much information to display Use this option multiple times to increase the amount of information For example v verbose vv more verbose vvv debug version Display version information and exit For the format option the permitted values are not case sensitive In addition values may be specified as any unambiguous prefix of a valid value For example format g specifies the grid format An error occurs if a prefix matches more than one valid value The path to the MySQL client tools should be included in the PATH environment variable in order to use the authentication mechanism with login pat
93. regardless of whether it is legally a derivative work Executables containing this object code plus portions of the Library will still fall under Section 6 Otherwise if the work is a derivative of the Library you may distribute the object code for the work under the terms of Section 6 Any executables containing that work also fall under Section 6 whether or not they are linked directly with the Library itself 6 As an exception to the Sections above you may also combine or link a work that uses the Library with the Library to produce a work containing portions of the Library and distribute that work under terms of your choice provided that the terms permit modification of the work for the customer s own use and reverse engineering for debugging such modifications You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License You must supply a copy of this License If the work during execution displays copyright notices you must include the copyright notice for the Library among them as well as a reference directing the user to the copy of this License Also you must do one of these things a Accompany the work with the complete corresponding machine readable source code for the Library including whatever changes were used in the work which must be distributed under Sections 1 and 2 above and if the work is an executable linked with
94. report similar to the following The first page shown is the master s executed GTID set MySQL Replication Monitor and Failover Utility Failover Mode auto Next Interval Mon Mar 19 15 59 33 2012 Master Information Binary Log File Position Binlog_Do_DB Binlog_Ignore_DB mysql bin 000001 571 GTID Executed Set 2A67DE00 2DA1 11E2 A711 00764F2BE90F 1 7 Master GTID Executed Set 131 EXAMPLES 2A67DE00 2DA1 11E2 A711 00764F2BE90F 1 7 SoOSwS n DETE 2A LO 7 DAIS E ils Q quit R refresh H health G GTID Lists U UUIDs L log entries Up Down scroll Continuing to press G key cycles through the three GTID lists If the list is longer than the screen permits as shown in the example above the scroll up and down help is also shown In this case press the down arrow key to scroll down Press U to view the list of UUIDs used in the topology for example MySQL Replication Monitor and Failover Utility Failover Mode auto Next Interval Mon Mar 19 16 02 34 2012 Master Information Binary Log File Poeton Binlog lo De Binlog ignore De nsen s OOOOCOU S CED REXCCuiEc diss Sie 2A67DE00 2DA1 11E2 A711 00764F2BE90F 1 7 UUIDs beeen assesses ess ja ES la ere port role uuid eee SSS SSeS S t tes Feee e silinose S951 MASTER S5oc65a00 71ltd 1lel 9fe0 ac64ers5c961 ekOCallthies tam oss 2 SLAVE 5dd30888 71fd 1le1 9f80 dce242138b7ec le ailinose S393 SLAVE 65ccbb38 71fd 1l
95. required by applicable law or agreed to in writing software distributed under the License is distributed on an AS IS BASIS WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied See the License for the specific language governing permissions and limitations under the License Apache License Version 2 0 January 2004 http www apache org licenses TERMS AND CONDITIONS FOR USE REPRODUCTION AND DISTRIBUTION Definitions License shall mean the terms and conditions for use reproduction and distribution as defined by Sections 1 through 9 of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control means i the power direct or indirect to cause the direction or management of such entity whether by contract or otherwise or ii ownership of fifty percent 50 or more of the outstanding shares or iii beneficial ownership of such entity You or Your shall mean an individual or Legal Entity exercising permissions granted by this License Source form shall mean the preferred form for making modifications including but not limited to software source code documentation source and configuration files Object form shall
96. requires the use of Python version 2 6 or higher but does not support Python 3 Single or double quote characters respectively or can be used around option values In fact quotes are required to set some options values correctly such as values with whitespace For example to specify the event types Create DB and Drop DB for the event type option the following syntax must be used vent type Create DB Drop DB or event type Create DB Drop DB EXAMPLES To display the audit log file statistics and output the results in CSV format run the following command shell gt mysqlauditgrep file stats format CSV SERVER data audit log Audit Log File Statistics File Size Created Last Modified auielilic lec S101 wie Seo 27 isssseili 202 Mow Coe dil yg4osss Zz Audit Log Startup Entries SERVER_ID STARTUP_OPTIONS NAME TIMESTAMP MYSOL_VERSION OS_VERSION VERSION To display the audit log entries of specific users use the following command shell gt mysqlauditgrep users testerl tester2 SERVER data audit log To display the audit log file statistics run the following command shell gt mysqlauditgrep users testerl tester2 SERVER data audit log SERVER sql mysqld defaults file SERVER my cnf Audit 2012 09 277T13 33 11 5 5 29 log x86_64 Linux 4 4 4 4 4
97. rpl user and the user has specified the switchover or failover command the utility will check to see if the slaves are using master info repository TABLI If they are not the utility will stop with an error EJ All the commands require either the slaves or discover slaves login option but both cannot be used at the same time In fact some commands only allow the use of the s laves option which is safer to specify the list slaves because discover slaves login might not provide an up to date list of available slaves The path to the MySQL client tools should be included in the PATH environment variable in order to use the authentication mechanism with login paths This will allow the utility to use the my_print_defaults tools which is required to read the login path values from the login configuration file mylogin cnf EXAMPLES To perform best slave election for a topology with GTID_ MODE ON server version 5 6 5 or higher where all slaves are specified with the slaves option run the following command shell gt mysqlrpladmin master root localhost 3331 slaves root localhost 3332 root localhost 3333 root localhost 3334 elect Electing candidate slave from known slaves Best slave found is located on localhost 3332 tao done To perform best slave election supplying a candidate list use the following command shell gt mysqlrpladmin master root localhost 3331 slaves root lo
98. sending it to the server Instead of performing the search the module can return the SQL code that performs the query This can be useful if you want to execute the query later or feed it to some other program that processes SQL queries further 214 mysql utilities command proc Search Processes on Servers Constants The following constants correspond to columns in the INFORMATION_SCHEMA PROCESSLIST table They indicate which columns to examine when searching for processes matching the search conditions mysql utilities command proc ID mysql utilities command proc USER mysql utilities command proc HOST mysql utilities command proc DB mysql utilities command proc COMMAND mysql utilities command proc TIME mysql utilities command proc STATE mysql utilities command proc INFO The following constants indicate actions to perform on processes that match the search conditions mysql utilities command proc KILL_QUERY Kill the process query mysql utilities command proc KILL_CONNECTION Kill the process connection mysql utilities command proc PRINT_PROCESS Print the processes Classes class mysql utilities command proc ProcessGrep matches actions use_regexp False This class searches the INFORMATION_SCHEMA PROCESSLIST table for processes on MySQL servers and optionally kills them It can both be used to actually perform the search or kill operation or to generate
99. server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt e Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt e Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt 190 EXAMPLES e ssl ca The path to a file that contains a list of trusted SSL CAs e ssl cert The name of the SSL certificate file to use for establishing a secure connection e ssl cert The name of the SSL key file to use for establishing a secure connection e ssl Specifies if the server connection requires use of SSL If an encrypted connection cannot be established the connection attempt fails Default setting is 0 SSL not required Start timeout lt timeout_in_seconds gt Number of seconds to wait for server to start Default 10 seconds e verbose V Specify how much information to display Use this op
100. situation the use of the force option might be required because it is likely that some registration data from the previous failover instance execution might have be left on the recovered master due to its previous crash 40 How Can Find All of the Slaves Attached to My Master Server The mysqlfailover utility registers its execution on the servers in order to avoid concurrent executions of the utility which will likely lead to errors and inconsistent state during failover If the utility detects that another instance might be running it will be started in fail mode not taking any action when it detects that the master failed The mysql failover instance registration is cleared when the utility exits and it is expected that unregistration fails on crashed or not accessible servers The force option overwrite the instance execution check allowing to surpass unregistration failure on crashed old masters allowing the mysql failover utility to start in auto mode Permissions Required The user have permissions to configure replication Tips and Tricks It is important to wait for the old master to catch up with the new master in order to guaranty that no transactions are lost Depending on the time the old master was down or not accessible it might take a considerable time for the old master to execute all missing transactions MySQL Utilities provide tools that allow the visualizations of the slaves status namely the heal
101. slave lt slave gt Connection information for the slave server To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt e Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt e ssl ca The path to a file that contains a list of trusted SSL CAs e ssl cert The name of the SSL certificate file to use for establishing a secure connection e ssl cert The name of the SSL key file to use for establishing a secure connection e ssl Specifies if the server connection requires use of SSL If an encrypted connection cannot be established the connection attempt fails Default setting is 0 SSL not required e Start from beginning b Start replication at the beginning of events logged in the master binary log e switchover int
102. slaves using the user name and password provided for the master By default if the connection attempt fails the utility throws an error and stops To change this behavior use the prompt option which permits the utility to prompt for the user name and password for each slave that fails to connect You can also use the num retries n option to reattempt a failed connection n times before the utility fails An example graph for a typical topology with relay slaves is shown here Replication Topology Graph localhost 3311 MASTER r localhost S310 SLAVIL localhost S312 SLAVE sp MASTER I ecallnosies SSIS Siva MASTER SLAVE and SLAVE MASTER indicate that a server is a master only slave only and both slave and master respectively A circular replication topology is shown like this where lt gt indicates circularity Replication Topology Graph localhost 3311 MASTER localhost 3312 SLAVE MASTER localhost 3213 SLAVE MASTER 178 OPTIONS t le calinosics 3S lt STAVE To produce a column list in addition to the graph specify the show 1ist option In this case to specify how to display the list use one of the following values with the format option grid default Display output in grid or table format like that of the mysql client command line tool csv Display output in comma separated values format tab Displ
103. such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt e Specify the data on the command line unencrypted visible Example lt user gt lt passwd gt lt host gt lt port gt lt socket 2 2 1 1 Use login paths mylogin cnf The best way to specify server connection information is with your mylogin cnf file Not only is this file encrypted but any logging of the utility execution will not expose the connection information Thus no user names passwords ports etc are visible in the log This is the preferred method for using MySQL Utilities to connect to servers Utilities support the use of login paths in the connection string provided they use the following format login path name port socket where the port and socket parameters are optional If used these optional parameters override the respective options from the specified login path When using login paths there a
104. tests sorted by suite name either ascending asc or descending desc Default is ascending asc Start port lt port gt The first port to use for spawned servers If you run the entire test suite you may see up to 12 new instances created The default is to use ports 3310 to 3321 start test lt prefix gt Start executing tests that begin with prefix stop test lt prefix gt Stop executing tests at the first test that begins with prefix suite lt name gt Execute the named test suite Use this option multiple times to specify multiple suites testdir lt path gt The path to the test directory utildir lt path gt The location of the utilities verbose v Specify how much information to display Use this option multiple times to increase the amount of information For example v verbose vv more verbose vvv debug To diagnose test execution problems use vvv to display the actual results of test cases and ignore result processing version Display version information and exit width lt number gt Specify the display width The default is 75 characters 220 NOTES NOTES The connection specifier must name a valid account for the server Any test named _template py is skipped This enables the developer to create a base class to import for a collection of tests based on a common code base EXAMPLES The following example demonstrates how to invoke mut to execute a subset of
105. the SQL statement for doing the job To kill all queries with user mats the following code can be used eer Leon Mysql uci lites conmand proc import gt gt gt grep ProcessGrep matches USER mats actions KILL_QUERY gt gt gt grep execute root server l example com root server 2 example com Parameters matches List of var pat pairs Sequence of field comparison conditions In each condition varis one of the constants listed earlier that specify PROCESSLIST table fields and patis a pattern For a process to match all field conditions must match sql only_body False Return the SQL code for executing the search and optionally the kill If only_body is True only the body of the function is shown This is useful if the SQL code is to be used with other utilities that generate the routine declaration If only_body is False a complete procedure will be generated if there is any kill action supplied and just a select statement if it is a plain search 215 Parsers Parameters only_body boolean Show only the body of the procedure If this is False a complete procedure is returned Returns SQL code for executing the operation specified by the options Return type string execute connections output sys stdout connector mysql connector Execute the search on each of the connections supplied If outout is not None the value is treated as a file o
106. the data consistency check skip diff Skip the object definition difference check Skip object compare Skip the object comparison check skip row count Skip the row count check Span key size lt number of bytes to use for key gt 91 NOTES Change the size of the key used for compare table contents A higher value can help to get more accurate results comparing large databases but may slow the algorithm Default value is 8 e ssl ca The path to a file that contains a list of trusted SSL CAs e ssl cert The name of the SSL certificate file to use for establishing a secure connection e ssl cert The name of the SSL key file to use for establishing a secure connection e Ssl Specifies if the server connection requires use of SSL If an encrypted connection cannot be established the connection attempt fails Default setting is 0 SSL not required verbose V Specify how much information to display Use this option multiple times to increase the amount of information For example v verbose vv more verbose vvv debug e version Display version information and exit e use indexes List the index to use Use this option to select the index to use if the table has no primary key or it has more than one unique index without null columns Use this option in the format use indexes lt table1 gt lt indexA gt lt table2 gt lt indexB gt width lt number gt Change the d
107. the following in order of most secure to least secure Use login paths from your my login cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt show options Display the audit log system variables ssl ca The path to a file that contains a list of trusted SSL CAs ssl cert The name of the SSL certificate file to use for establishing a secure connection ssl cert The name of the SSL key file to use for establishing a secure connection Ssl Specifies if the server connection requires use of SSL If an encrypted connection cannot be established the connection attempt fails Default setting is 0 SSL not required value lt VALUE gt Value used to set variables based on the specified commands such as policy and rotate_on_size verbose v Specify how much information to display Use this option multiple times to increase the amount of information For example v verbose vv more verbose vvv debug version Display version information and exit 65 NOTES NOTES This utility can only be applied to servers with the audit log plugin enabled And the audit log
108. the mysqlbinlogpurge utility can help us to perform this task in an easy and safe manner by determining all the unnecessary files automatically on each slave and purging them on the master 13 Database Operations Let s assume that a master server is currently running on port 13001 and a few slaves are connected Example Execution 1 Run the mysqlbinlogpurge utility specifying the master connection string using the master option and either the slaves to indicate each slave connection string or the discover slaves login to query the master for all registered slaves and use the user name and password specified to connect and determine the binlog files that can be purge shell gt mysqlbinlogpurge master root root localhost 13001 discover slaves login rpl rpl Discovering slaves for master at localhost 13001 Discovering slave at localhost 13002 Found slave localhost 13002 Discovering slave at localhost 13003 Found slave localhost 13003 Discovering slave at localhost 13004 Found slave localhost 13004 Latest binlog file replicated by all slaves mysql bin 000005 Purging binary logs prior to mysql bin 000006 Discussion The previous example illustrates how to purge the binlog files from a master in a replication scenario We used the master option for the master server but for the slaves we provided the option discover slaves login and the utility used the specified information to determi
109. the server s partition In this case the server 77 option should be used instead of the binlog dir 76 option like in the above example The utility will ensure that the binary files that might be in use by the server those with the higher sequence number will not be moved The utility also provides options to filter the files to relocate based on their sequence number using the sequence 77 option or their last modification date using the modified before 77 option 3 1 2 How do you purge obsolete binary log files safely At some point MySQL servers may generate a significant number of binary log files that may consume considerable hard drive space and being a good reason a user might want to delete them But in a replication scenario is necessary to know which binary log files can be deleted without breaking replication since replication relies on the binary log Users need to check each slave to determine the latest position or GTID read This information is then used to determine which of the binary logs on the master may be removed That is which files have been read by all of the slaves Objectives The goal is to purge all unnecessary binlog files on the MySQL server in a replication topology Another important goal is to automate the operation Executing this task manually can be tedious and error prone since it requires verifying each slave The more slaves the more complicated this becomes Fortunately
110. the tests using an existing server which is cloned The example displays the test name status and relative time shell gt mut server root localhost do tests clone_user width 70 MySQL Utilities Testing MUT Parameters used Display Width 70 Sorted True Force False Test directory Sis Wellies directory seeds SEGUE WiNG JOSE 3310 Test wildcard clone_user Servers Connecting to localhost as user root on port 3306 CONNECTED TEST NAME STATUS TIME main clone_user pass 54 main clone_user_errors pass ey main clone_user_parameters pass iy Testing completed Friday 03 December 2010 09 50 06 All 3 tests passed PERMISSIONS REQUIRED There are no special permissions required to run mysqluc however you must have the necessary privileges to execute the desired utilities in the tests Generally MUT is run with a root user 221 222 Appendix A MySQL Fabric MySQL Fabric is a framework for managing groups of MySQL servers and using those servers to provide services It is designed to be extensible so that over time many different services can be added In the current version the services provided are high availability built on top of MySQL replication and scale out by sharding the data Fabric is implemented as a Fabric node process which performs management functions and Fabric aware connectors that are able to route queries and transactions directly to the most appropriate MyS
111. tl Ve et Tien Ga ie er ia SiG coed 11 3 1 1 How To Change The Location For Binary Log Files ccccceeeeeeeeeeeeeeeeeeeeeeaaeaeeeees 12 3 1 2 How do you purge obsolete binary log files Safely ccccceeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaes 13 3 2 Database Operations uns h oin cece ee ence ee ee a etter anes ee seeded aa aaa SEAE aiii 14 3 2 1 How Do Provision a Slave oee enera aa aaar a aa a aa EE A a AE eaaa aiea 14 3 2 2 How Do Make a Copy of a Database on the Same Server cccccecceeeeeeeeeeeeeeeeees 16 3 2 3 How Can I Make a Copy of a Database and Change the Storage Engine 008 17 3 2 4 How Can Tell If a Table on Server X has the same Structure as the Same Table on AEI AAT E E E E A E A A E N E E ES E EE be 19 3 2 5 How Can Synchronize a Table on Two Servers Where Neither is Up to date 20 3 3 General OPSrationS srren a aa a aaa TA r araa a aaae aaa sieaa tar AA 21 3 3 1 How Can Find Out How Much Space My Data Uses eesseeeeesererrrrereessrsrrrrren 21 3 3 2 My Server Crashed Need to Know the Structure of a Table How Can Do That 22 3 3 3 Creating a New User With The Same Privileges as Another User a nns 24 3 3 4 What Options Are Used With Each Utility 2 0 2 ce cece cece neeteeeeeeeeeeeeaeaa ee eeeeeeeeeeaeaaea 25 3 3 5 I ve Got Too Many Indexes How Do Know Which Ones to Drop eeeeeee eee 28 3 3 6 Need to Find an Object on My Server
112. to find the accompanying uncombined form of the same work 8 You may not copy modify sublicense link with or distribute the Library except as expressly provided under this License Any attempt otherwise to copy modify sublicense link with or distribute the Library is void and will automatically terminate your rights under this License However parties who have received copies or rights from you under this License will not have their licenses terminated so long as such parties remain in full compliance 9 You are not required to accept this License since you have not signed it However nothing else grants you permission to modify or distribute the Library or its derivative works These actions are prohibited by law if you do not accept this License Therefore by modifying or distributing the Library or any work based on the Library you indicate your acceptance of this License to do so and all its terms and conditions for copying distributing or modifying the Library or works based on it 10 Each time you redistribute the Library or any work based on the Library the recipient automatically receives a license from the original licensor to copy distribute link with or modify the Library subject to these terms and conditions You may not impose any further restrictions on the recipients exercise of the rights granted herein You are not responsible for enforcing compliance by third parties with this License 11 If as a
113. to it Tips and Tricks If you want to copy all of the users and their permissions check out the mysqluserclone utility 3 5 2 How Can I Find What MySQL Servers Are Running One of the challenges for a database administrator or database developer when working with a development server that has multiple instances of MySQL running is knowing exactly how many are running In some cases this may have come about by accident but mostly having multiple instances of MySQL running is intentional Whichever the case it would be nice to be able to use a single command to find all of the MySQL processes Objectives Use the mysqlserverinfo utility to locate all of the MySQL processes running on a host Example Execution shell gt mysqlserverinfo show servers server root root localhost format vertical The following MySQL servers are active on this host Process id 3007 Data path usr local mysql data Process id 8191 Data path Volumes Source source temp_13001 Process id 8196 Data path Volumes Source source temp_13002 Process id 8201 Data path Volumes Source source temp_13003 Process id 8207 Data path Volumes Source source temp_13004 Process id 8212 Data path Volumes Source source temp_13005 Source on localhost connected KREKEKKKKKKKKKKKKKKKKKKKKEEKEK ils row KREKKKKKKKKKKKKKKKKKKKKEEKEK server localhost 3306 verston orl OR loc datadir usr local mysql data basedir usr local mysql 5 1 50 osx10
114. use the my_print_defaults tools which is required to read the login path values from the login configuration file mylogin cnf LIMITATIONS This utility is designed to work exclusively for servers that support global transaction identifiers GTIDs and have gt id_mode oN Due to known server issues with some operations required for the synchronization process only MySQL Server versions 5 6 14 and higher are supported by this utility Some replication filtering options are not supported by this utility due to known issues on the server side namely replicate_do_db replicate_ignore_db and replicate_wild_do_table In case a non supported replication filtering option is detected on a server the utility issues an appropriate error and exits This check is performed at the beginning when the utility starts EXAMPLES To check the data consistency on an active replication system explicitly specifying the master and slaves 185 EXAMPLES shell gt mysqlrplsync master user pass localhost 3310 slaves rpl1 pass localhost 3311 rpl pass localhost 3312 GTID differences between Master and Slaves Slave localhost 3311 is 15 transactions behind Master Slave localhost 3312 is 12 transactions behind Master Checking data consistency Using Master localhost 3310 as base server for comparison Checking test_rplsync_db database Checking t0 table data OB eese Faleye elo o t0 checksum for server loca
115. user has you grant a privilege you do not have yourself Tips and Tricks You can use dest ination option to specify a different server to copy a user account to another server Use the dump option with only the source option to see all user accounts Use the include global privileges option to include GRANT statements that the user host combination matches This is useful for copying user accounts from one server to another where there are global privileges in effect 3 3 4 What Options Are Used With Each Utility There are many utilities and it is not always easy to remember all of the options and parameters associated with each Sometimes we need to run several utilities using nearly the same options For example you may want to run several utilities logging into a particular server Rather than retype the connection information each time you would like to save the option value some way and reuse it Fortunately the mysqluc utility does this and more It is named the MySQL Users Console and provides type completion for options utility names and even user defined variables for working with common option values Not only that it also provides the ability to get help for any utility supported Objectives Discover what utilities exist and find the options for certain utilities Run several utilities with the same server using the type completion feature to make using the suite of utilities easier Example Execution
116. utility searches for objects matching a given pattern on all the servers specified using instances of the server option It produces output that displays the matching objects By default the first non option argument is taken to be the pattern unless the pattern option is given If the pattern option is given then all non option arguments are treated as connection specifications 146 SQL Simple Patterns Internally the utility generates an SQL statement for searching the necessary tables in the INFORMATION_SCHEMA database on the designated servers and then executes it before collecting the result and printing it as a table Use the sq1 option to have mysqimetagrep display the statement rather than execute it This can be useful if you want to feed the output of the statement to another application such as the mysq1 client command line tool The MySQL server supports two forms of patterns when matching strings SQL Simple Patterns used with the LIKE operator and POSIX Regular Expressions used with the REGEXP operator By default the utility uses the LIKE operator to match the name and optionally the body of objects To use the REGEXP operator instead use the regexp option anchor the expression to the beginning of the string if you want to match the beginning of the string Note R Because the REGEXP operator does substring searching it is necessary to To specify how to display output use one of the following
117. values with the format option e grid default Display output in grid or table format like that of the mysql client command line tool e csv Display output in comma separated values format e tab Display output in tab separated format vertical Display output in single column format like that of the G command for the mysq1 client command line tool SQL Simple Patterns The simple patterns defined by the SQL standard consist of a string of characters with two characters that have special meaning percent matches zero or more characters and _ underscore matches exactly one character For example johns Match any string that starts with john Match any string consisting of one or more characters POSIX Regular Expressions POSIX regular expressions are more powerful than the simple patterns defined in the SQL standard A regular expression is a string of characters optionally containing characters with special meaning Documenting these regular expressions goes beyond the scope of this manual but the full syntax is described in the MySQL manual and other locations such as executing man regex in your terminal 147 OPTIONS Match any character A Match the beginning of a string Match the end of a string axy Match a x or y a f Match any character in the range a to f that is a b c d e or f axy Match any character except a x or y at Match a sequence of
118. variables Display list of variables lt ENTER gt Press ENTER to execute command lt ESCAPE gt Press ESCAPE to clear the command entry lt DOWN gt Press DOWN to retrieve the previous command lt UP gt Press UP to retrieve the next command in history lt TAB gt Press TAB for type completion of utility option or variable names lt TAB gt lt TAB gt Press TAB twice for list of matching type completion context sensitive mysqluc gt help utilities Uerbity Description mysqlauditadmin mysqlauditgrep mysqldbcompare mysqldbcopy mysqldbexport mysqldbimport mysqldiff copy mysqldiskusage show mysqlfailover mysqlfrm mysqlindexcheck mysqilmetagrep mysqlprocgrep mysqlreplicate mysqlrpladmin mysqlrplcheck mysqlrplms mysqlrplshow mysqlrplsync mysqlserverclone mysqlserverinfo mysqluserclone show show show audit log maintenance utility audit log search utility compare databases for consistency databases from one server to another export metadata and data from databases import metadata and data from files compare object definitions among objects where the difference is how dbl objl differs from db2 obj2 disk usage for databases automatic replication health monitoring and failover CREATE TABLE from frm files check for duplicate or redundant indexes search metadata search process information establish replication with a master administration utility for MySQL replication check replication
119. verbose vvv debug e version Show program s version number and exit NOTES Tables with certain storage engines cannot be read in the default mode These include PARTITION PERFORMANCE SCHEMA You must read these with the diagnostic mode Use the diagnostic mode for tables that fail to open correctly in the default mode or if there is no server installed on the host To change the storage engine in the CREATE statement generated for all frm files read use the new storage engine option 135 EXAMPLES To turn off all messages except the CREATE statement and warnings or errors use the quiet option Use the show stats option to see file statistics for each frm file If you need to run the utility with elevated privileges use the user option to execute the spawned server using a normal user account If you encounter connection or similar errors when running in default mode re run the command with the verbose option and view the output from the spawned server and repair any errors in launching the server If mysql frm fails in the middle you may need to manually shutdown the server on the port specified with port EXAMPLES The following example will read a single frm file in the default mode from the current working directory using the server installed in usr local bin mysql and port 3333 for the spawned server Notice the use of the db table frm format for specifying the database name for the tab
120. will contain entries like the following 2012 03 19 14 44 17 PM INFO Executing failover command 2012 03 19 14 44 17 PM INFO Performing failover 2012 03 19 14 44 17 PM INFO Candidate slave localhost 3333 will become the new master 2012 03 19 14 44 17 PM INFO Preparing candidate for failover 2012 03 19 14 44 19 PM INFO Creating replication user if it does not exist 2012 03 19 14 44 19 PM INFO Stopping slaves 2012 03 19 14 44 19 PM INFO Performing STOP on all slaves 2012 03 19 14 44 19 PM INFO Switching slaves to new master 2012 03 19 14 44 20 PM INFO Starting slaves 2012 03 19 14 44 20 PM INFO Performing START on all slaves 2012 03 19 14 44 20 PM INFO Checking slaves for errors 2012 03 19 14 44 21 PM INFO Failover complete ZOU ASOS3 1S i Ae 2 IPM WING 5 onen To perform switchover and demote the current master to a slave use the following command 172 PERMISSIONS REQUIRED shell gt mysqlrpladmin master root localhost 3331 slaves root localhost 3332 root localhost 3333 root localhost 3334 new master root localhost 3332 demote master switchover Performing switchover from master at localhost 3331 to slave at localhost 3322 Checking candidate slave prerequisites Waiting for slaves Eo catch wp to old master Stopping slaves Performing STOP on all slaves Demoting old master to be a slave to the new master Switching slaves to new master Starcing el
121. 0 2014 The Apache Software Foundation ad his product includes software developed at The Apache Software Foundation http www apache org H his product includes software developed by Cloudkick http www cloudkick com N Include the following License ONLY ONCE in the documentation even if here are multiple products licensed under the license ct 3 J he following applies to all products licensed under the Apache 2 0 License You may not use the identified files except in compliance with the Apache License Version 2 0 the License You may obtain a copy of the License at http www apache org licenses LICENSE 2 0 A copy of the license is also reproduced below Unless required by applicable law or agreed to in writing software distributed under the License is distributed on an AS IS BASIS WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied See the License for the specific language governing permissions and limitations under the License Apache License Version 2 0 January 2004 http www apache org licenses TERMS AND CONDITIONS FOR USE REPRODUCTION AND DISTRIBUTION DSE ONSE License shall mean the terms and conditions for use reproduction and distribution as defined by Sections 1 through 9 of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union
122. 0 osxi0 6 x86_64 lib plugin config_file etc my cnf binary_log my_lloeg 000287 binary_log_pos 106 relay_log None relay_log_pos None 46 How Do Make A Temporary Copy of My Server For Testing 1 row edonne shell gt my_print_defaults mysqld etc my cnf pore 2306 basedir usr local mysql datadir usr local mysql data server_id 5 iog bin my log general_log slow_query_log innodb_data_file_path ibdatal 778M ibdata2 50M autoextend shell gt ps 2377 UID PID PPETITD C STIME EA TIME CMD 74 2377 2300 0 10 56AM 0 02 04 usr local mysql bin mysqld basedir usr local mysql datadir usr local mysql data user mysql log error logs me local err pid file logs me local port 3306 Notice we now have all of the options from the configuration file as well as the startup options We can now construct the proper options for creating a clone of this server using the mysqlserverclone utility Specifically we can set the following options using the mysqla option e log bin my_log e general_log e slow_query_log e user mysaq e log error lt path gt Using these options and choosing a new data directory we can create a new instance of the host server using the following command shell gt mysqlserverclone server root root localhost new data source temp_clone new port 3307 root root delete new id 123 mysqld log bin my_log gener
123. 00001 slave relay bin 000002 slave relay bin 000003 80 PERMISSIONS REQUIRED slave relay bin 000004 slave relay bin 000005 slave relay bin 000006 slave relay bin 000007 slave relay bin 000008 slave relay bin 000009 slave relay bin 000010 Flushing relay logs done Move available binary log files modified prior to the specified date from a running slave shell gt mysqlbinlogmove server user pass localhost 3311 log type all modified before 2014 08 31 archive slave binlog_dir Applying modified date filter to bin log files Woving bin logi iles mr slave bin 000001 slave bin 000002 slave bin 000003 Flushing binary logs Applying modified date filter to relay log files Moving relay log files lave relay bin 000001 lave relay bin 000002 lave relay bin 000003 lave relay bin 000004 lave relay bin 000005 lave relay bin 000006 lave relay bin 000007 lave relay bin 000008 lave relay bin 000009 lave relay bin 000010 NDNODAHDHAAHAAHAAAR A Flushing relay logs done PERMISSIONS REQUIRED By default the user used to connect to the server must have permissions to flush the binary logs more precisely the RELOAD privilege is required except if the flush step is skipped Additionally the system user used to execute the utility must have read and write access to the locatio
124. 127 0 0 1 port 3307 e SHOW CREATE TABLE world_myisam countrylanguage G KKEKEKKKKKKKKKKKKKKKKKKKKKKEEKEK ils row KKEKEKKKKKKKKKKKKKKKKKKKKKKEEEK Table countrylanguage Create Table CREATE TABLE countrylanguage CountryCode char 3 NOT NULL DEFAULT Language char 30 NOT NULL DEFAULT USO ieee menun Va a INCOME IMUPi I DERAV Percentage float 4 1 NOT NULL DEFAULT 0 0 PRIMARY KEY CountryCode Language KEY CountryCode CountryCode ENGINE MyISAM DEFAULT CHARSET latinl Discussion Notice here we created a copy of the database and changed all tables in the destination database to use the InnoDB storage engine with the new storage engine option We show proof of the change by displaying the CREATE statement for one of the tables on the destination server Notice we also renamed the database by using the lt old_name gt lt new_name gt syntax Permissions Required The user must have SELECT privileges for the database s on the source server and have CREATE INSERT UPDATE on the destination server Tips and Tricks You can exclude specific options by using the exclude option specifying a SQL pattern expression For example to exclude objects that start with xy use exclude xy You can use REGEXP patterns in the exclude option by specifying regexp in addition to the exclude option 18 How Can Tell If a Table on Server X has the same Structure as the Same T
125. 1SXONS NSLS ICI LAG QE UCH DAMAGE HPH D r Le el jel ey IS teal strtod and dtoa The file Python dtoa c which supplies C functions dtoa and strtod for conversion of C doubles to and from strings is derived from the file of the same name by David M Gay currently available from http www netlib org fp The original file as retrieved on March 16 2009 contains the following copyright and licensing notice RK KKK IR KR IK KR IR e A k I A AA IA A I I ok The author of this software is David M Gay Copyright c 1991 2000 2001 by Lucent Technologies Permission to use copy modify and distribute this software for any purpose without fee is hereby granted provided that this entire notice is included in all copies of any software which is or includes a copy or modification of this software and in all copies of the supporting documentation for such software W w N THIS SOFTWARE IS BEING PROVIDED AS IS WITHOUT ANY EXPRESS OR IMPLIED WARRANTY IN PARTICULAR NEITHER THE AUTHOR NOR LUCENT MAKES ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE FERRARA IA AR I AR I AR AA k k k k k k I k k k k kkk A kkk k 8 2 9 Python License Supplement Windows Only The Windows installers for Python may include a copy of the OpenSSL libraries The terms of the Oracle license do
126. 1e4 aa8d 606720440b68 10 af6 b22ee T7b0b 11le4 aa8d 606720440b68 11 af6 b22ee T7b0b 11le4 aa8d 606720440b68 12 injecting emplLy transactions for localhost 2312 af6 b22ee T7b0b 11e4 aa8d 606720440b68 6 af6 b22ee T7b0b 11le4 aa8d 606720440b68 10 af6b22ee T7b0b 11le4 aa8d 606720440b68 11 af6 b22ee T7b0b 11le4 aa8d 606720440b68 done PERMISSIONS REQUIRED The user used to connect to each slave must have the required permissions to inject empty transactions more precisely the SUPER privilege is required to set the gt id_next variable 5 27 mysqluc Command line client for running MySQL Utilities This utility provides a command line environment for running MySQL Utilities The mysqluc utility hence console allows users to execute any of the currently installed MySQL Utilities command The option ut ildir is used to provide a path to the MySQL Utilities if the location is different from when the utility is executed The console has a list of console or base commands These allow the user to interact with the features of the console itself The list of base commands is shown below along with a brief description Command Description help utilities Display list of all utilities supported help lt utility gt Display help ror a specific utility help help commands show this list exit quit Exit the console set lt variable gt lt value gt Store
127. 2 databases on the local server and run all tests even if earlier tests fail shell gt mysqldbcompare serverl root localhost empl emp2 run all tests serverl on llocaliests zq connected Checking databases empl on serverl and emp2 on server2 WARNING Objects in server2 emp2 but not in serverl emp1 TRIGGER CEG PROCEDURE pil TABLE t1 VIEW vi Defn Row Data Type Object Name Die Count Check FUNCTION 1 pass TABLE departments pass pass Compare table checksum FAIL Find row differences FAIL Data differences found among rows empl departments emp2 departments EE 1 4 1 4 KEK KKK KKK KK KEK KKK KEKKK KKK KK lie row KEK KKK KKK KKK KKK KKKKKEK KK KEK dept_no d002 dept_name dunno dept_name Finance 1 rows Rows in empl departments not in emp2 departments KREKKKKKKKKK KKK KKK KKK KKKKEK ail 2 row KREKKKKKKKKKKKKKKKKKKKKKEKEK dept_no d008 dept_name Research rows Rows in emp2 departments not in empl departments KREKKKKKKKKK KKK KKK KK KKKKKK al row KREKKKKKKKKKKKKKKKKKKKKKEKK dept_no d100 dept_name stupid rows TABLE dept_manager pass pass Compare table checksum pass Database consistency check failed done Given two databases with the same table layout Data for each table contains mysql gt select from dbl1 tl 4 4 il Test 789 2 Test 456 3 Test is 4 New row dbl 4 rows in set 0 00 sec mysql gt select fro
128. 3 08 01IT15 24 26 32 Localhost a OCt eC elas 0 Connece 2013 08 01IT15 24 26 34 localhost 2ooe oot la T 0 Connece 201308 0 PElS2 242216 55 localhost cool oot E275 0 connece 201 S 08 0 nla 2416 36 Localhost eOOe cool l2 i 0 econnece 2013 0s Oils hee SSP Localhost EOE EGOE r laws 0 Connect 20IS OF OLWilssAeoag Se r see Oe YB Ge i Ol T045 Connect 2013 08 Omi SEO oro oslo c ane sie mtsOolen r laO Orem Ss S SS S SS PRPRPRP PR Discussion To perform this operation the mysqlauditgrep utility requires the indication of the target audit log file as expected two criteria search options and one formatting option to convert the output to the desired format In this case the users option was applied to search the records for the specified user i e root and the event type option to retrieve only event of a specific type i e connect The format option is the one used to define the output format of the obtained search results In this example only the Connect value was used for the event t ype option which correspond to the logging in event when a client connects Nevertheless this option accepts a comma separated list of event types with the following supported values beside Connect Audit Binlog Dump Change user Close stmt Out Connect Create DB Daemon Debug Delayed insert Drop DB Execute Fetch Field List Init DB Kill Long Data NoAudit
129. 311 MASTER loca liiost 3310 KSAY Oca ltiosetsole KSAY As shown in the example you must provide valid login information for the master To show additional information about the IO thread status to confirm if the slaves are really connected to the master use the option verbose shell gt mysqlrplshow master root localhost 3311 discover slaves login root verbose master on localhost connected Finding slaves for master localhost 3311 Replication Topology Graph localhost 3311 MASTER localhost ssi ues wes SOL Yes SLAVE localhost v32 los wes SOL Yes SLAVE To show the full replication topology of a master running on the local host use the following command shell gt mysqlrplshow master root localhost 3311 recurse discover slaves login root master on localhost connected Finding slaves for master localhost 3311 Replication Topology Graph 181 PERMISSIONS REQUIRED localhost 3311 MASTER t o leeellaoses SS Siw lheeellingsies ssl SLAVE MASTER To locellaomesasils Siw To show the full replication topology of a master running on the local host prompting for the user name and password for slaves that do not have the same user name and password credentials as the master use the following command shell gt mysqlrplshow recurse prompt num retries 1 master root localhost 3331 disc
130. 77 pass pass pass pass pass pass PERMISSIONS REQUIRED Master_SSL_CA_Path Master SSL Cert i Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master 0 Master_SSL_Verify_Server_Cert No IbsiSic _ OC Taverne amp 0 Last TOCETrTOr 3 Last ES OLSETENOR aO Last SOL Error done PERMISSIONS REQUIRED The users on the master need the following privileges SELECT and INSERT privileges on mysql database REPLICATION SLAVE REPLICATION CLIENT and GRANT OPTION The slave users need the SUPER privilege Also when using GTIDs the slave users must also have SELECT privilege over the mysql database 5 22 mysqlrplshow Show Slaves for Master Server This utility shows the replication slaves for a master It prints a graph of the master and its slaves labeling each with the host name and port number You must specify the discover slaves login option to provide the user name and password to discover any slaves in the topology To explore the slaves for each client use the recurse option This causes the utility to connect to each slave found and attempt to determine whether it has any slaves If slaves are found the process continues until the slave is found in the list of servers serving as masters a circular topology The graph displays the topology with successive indents A notation is made for circular topologies If you use the recurse option the utility attempts to connect to the
131. AMAGES WHATSOEVER RESULTING FROM LOSS OF USE DATA OR PROFITS WHETHER IN AN ACTION OF CONTRACT NEGLIGENCE OR OTHER TORTIOUS ACTION ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE Modified by Jack Jansen CWI July 1995 Use binascii module to do the actual line by line conversion between ascii and binary This results in a 1000 fold speedup The C version is still 5 times faster though Arguments more compliant with Python standard XML Remote Procedure Calls The xmlrpclib module contains the following notice The XML RPC client interface is Copyright c 1999 2002 by Secret Labs AB Copyright c 1999 2002 by Fredrik Lundh By obtaining using and or copying this software and or its associated documentation you agree that you have read understood and will comply with the following terms and conditions Permission to use copy modify and distribute this software and its associated documentation for any purpose and without fee is hereby granted provided that the above copyright notice appears in all copies and that both that copyright notice and this permission notice appear in supporting documentation and that the name of Secret Labs AB or the author not be used in advertising or publicity pertaining to distribution of the software without specific written prior permission SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANT
132. An error occurs if a prefix matches more than one valid value The path to the MySQL client tools should be included in the PATH environment variable in order to use the authentication mechanism with login paths This will allow the utility to use the my_print_defaults tools which is required to read the login path values from the login configuration file mylogin cnf EXAMPLES To clone joe aS sam and sally with passwords and logging in as root on the local machine use this command shell gt mysqluserclone source root localhost destination root localhost joe localhost sam secretl localhost sally secret2 localhost Source on localhost connected Destination on localhost connected Cloning 2 weers Cloning joe localhost to user sam secretl localhost Cloning joe localhost to user sally secret2 localhost done The following command shows all users on the local server in the most verbose output in CSV format shell gt mysqluserclone source root localhost list format csv vvv Source on localhost connected user host database joe localhost util_test rpm localhost saliiy localhost ute elante site sam localhost util_test joe user util_test PERMISSIONS REQUIRED The permissions required include the ability to read the mysql database and to have read access to the data directory 204 Chapter 6 Extending MySQL Utilities Table of Contents 6 1 Introduc
133. BLE ied test john localhost 3306 TABLE 12 test john localhost 3306 TABLE ii test 4 4 4 To find all object that contain t2 in the name or the body for routines triggers and events shell gt mysqlmetagrep b pattern t2 server john localhost 3306 4 4 4 4 Connection Object Type Object Name Database 4 4 4 4 john localhost 3306 TRIGGER te tee test johu localbost 3306 TABLE E2 test 4 4 4 4 In the preceding output the trigger name does not match the pattern but is displayed because its body does This is the same as the previous example but using the REGEXP operator Note that in the pattern it is not necessary to add wildcards before or after t2 150 PERMISSIONS REQUIRED shell gt mysqlmetagrep Gb pattern t2 server john localhost 4 4 4 Connection Object Type Object Name Database 4 4 4 POoEs localhost 3306 TRIGGER ee eo test root localhost 3306 TABLE te test 4
134. Centrum all rights reserved Permission to use copy modify and distribute this Python software and its associated documentation for any purpose without fee is hereby granted provided that the above copyright notice appears in all copies and that both that copyright notice and this permission notice appear in supporting documentation and that the name of neither Automatrix Bioreason or Mojam Media be used in advertising or publicity pertaining to distribution of the software without specific written prior permission UUencode and UUdecode functions The uu module contains the following notice 249 Python License Copyright 1994 by Lance Ellinghouse Cathedral City California Republic United States of America All Rights Reserved Permission to use copy modify and distribute this software and its documentation for any purpose and without fee is hereby granted provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation and that the name of Lance Ellinghouse not be used in advertising or publicity pertaining to distribution of the software without specific written prior permission LANCE ELLINGHOUSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS IN NO EVENT SHALL LANCE ELLINGHOUSE CENTRUM BE LIABLE FOR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY D
135. Connection information for slave servers List multiple slaves in comma separated list The list will be evaluated literally whereby each server is considered a slave to the master listed regardless if they are a slave of the master To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply 128 NOTES this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt e Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt e ssl ca The path to a file that contains a list of trusted SSL CAs e ssl cert The name of the SSL certificate file to use for establishing a secure connection e ssl key The name of the SSL key file to use for establishing a secure connection e ssl Specifies if the server connection requires use of SSL If an encrypted connection cannot be established the connecti
136. D enabled server but use the skip gtid option To make the most use of GTIDs you should copy all of the databases on the server with the a11 option OPTIONS mysqldbcopy accepts the following command line options e help Display a help message and exit 96 OPTIONS license Display license information and exit character set lt charset gt Sets the client character set The default is retrieved from the server variable character_set_client default storage engine lt def_engine gt The engine to use for tables if the destination server does not support the original storage engine on the source server destination lt destination gt Connection information for the destination server To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt e Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencry
137. DHE RSA AES256 SHA Note E To configure an account to only permit SSL encrypted connections the grants for that account must include the REQUIRE SSL clause in your GRANT Syntax statement In the same form that you use the SSL options with the MySQL Command Line Tool you can use the SSL options on each of the MySQL Utilities The following is an example of mysqlserverinfo using SSL options shell gt mysqlserverinfo server root pass localhost 3307 ssl ca C newcerts cacert pem ssl cert C newcerts client cert pem ssl key C newcerts client key pem format vertical Source on localhost connected KKKKKKKKKKKKKKKKKKKKKKKKK LL row KKKKKKKKKKKKKKKKKKKKKKKKEK server localhost 3307 config_file Ialinewery _Ikeieys binary_log_pos relay_log relay_log_pos NEPSLOn 4 0 5 datadir C MySQL instance_3307 basedir C MySOL mysql 5 6 15 winx64 plugin_dir C MySQL mysql 5 6 15 winx64 lib plugin general_log OFF general_log_file general_log_file_size log_error C MySQL instance_3307 clone err log_error_file_size 1569 bytes slow_query_log OFF slow_query_log_file slow_query_log_file_size L ror done Or you can indicate the SSL options by Using Option Files as is mentioned in the Section 2 2 Connecting to MySQL Servers documentation This is an example of how it may look for a group with the options in an options file for the command used above instance_3307 port 3307 u
138. E AGREEMENT is between BeOpen com BeOpen having an office at 160 Saratoga Avenue Santa Clara CA 95051 and the Individual or Organization Licensee accessing and otherwise using this software in source or binary form and its associated documentation the Software 2 Subject to the terms and conditions of this BeOpen Python License Agreement BeOpen hereby grants Licensee a non exclusive royalty free world wide license to reproduce analyze test perform and or display publicly prepare derivative works distribute and otherwise use the Software alone or in any derivative version provided however that the BeOpen Python License is retained in the Software alone or in any derivative version prepared by Licensee 3 BeOpen is making the Software available to Licensee on an AS IS basis BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES EXPRESS OR IMPLIED BY WAY OF EXAMPLE BUT NOT LIMITATION BEOPEN MAKES NO AND DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT INFRINGE ANY THIRD PARTY RIGHTS 4 BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE SOFTWARE FOR ANY INCIDENTAL SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF USING MODIFYING OR DISTRIBUTING THE SOFTWARE OR ANY DERIVATIVE THEREOF EVEN IF ADVISED OF THE POSSIBILITY THEREOF 5 This License Agreement will automatically terminate upon a material br
139. E ON util_test TO priv_test_user3 Q ROUTENET eteaLIL jeesie o EE For joe user GRANT ALL PRIVILEGES ON util_test gt TO joe user For Joe wildcard Ciki GRANT ALL PRIVILEGES ON util_test TO joe_wildcard For priv_test_user e s GRANT EXECUTE TRIGGER ON util_test TO priv_test_user WITH GRANT OPTION Woe Vere Cest sean VCs GRANT ALTER ROUTINE ON FUNCTION util_test fl1 TO priv_test_user2 WITH GRANT OPTION GRANT SELECT UPDATE SHUTDOWN EXECUTE ON TO priv_test_user2 For priv_test_usera s GRANT DROP EXECUTE TRIGGER ON TO priv_test_user3 GRANT UPDATE DELETE ALTER ROUTINE ON util_test TO priv_test_user3 ROUTENET eieaLIL jeesie 5 pie For joe user GRANT ALL PRIVILEGES ON util_test TO joe user For joe_wildeard s GRANT ALL PRIVILEGES ON util_test TO joe_wildcard For priv_test_user e s GRANT EXECUTE TRIGGER ON util_test TO priv_test_user WITH GRANT OPTION ov RON Pisivmibe SiemuU Sem 2aGls GRANT SELECT UPDATE SHUTDOWN EXECUTE ON TO priv_test_user2 For priv_test_usera s GRANT ALTER ROUTINE ON PROCEDURE util_test pl TO priv_test_user3 WITH GRANT OPTION RANT DROP EXECUTE TRIGGER ON TO priv_test_user3 GRANT UPDATE DELETE ALTER ROUTINE ON util_test gt TO priv_test_user3
140. E USE OR INABILITY TO USE THE LIBRARY INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE EVEN IF 239 Paramiko License SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library and you want it to be of the greatest possible use to the public we recommend making it free software that everyone can redistribute and change You can do so by permitting redistribution under these terms or alternatively under the terms of the ordinary General Public License To apply these terms attach the following notices to the library it is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty and each file should have at least the copyright line and a pointer to where the full notice is roundi lt one line to give the library s name and a brief idea of what it does gt Copyright C lt year gt lt name of author gt This library is free software you can redistribute it and or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation either version 2 1 of the License or at your option any later version This library is distributed im the ho
141. EI beest el CREATE TABLE CI la char 30 DEFAULT NULL ENGINE MEMORY DEFAULT CHARSET latinl done Source on localhost connected USE util_test Exporting data from util_test Data for table util _test tli NSERT INTO util_test t1 VALUES 01 Test Basic database example NSERT INTO util_test t1 VALUES 02 Test Basic database example NSERT INTO util_test t1 VALUES 03 Test Basic database example NSERT INTO util_test tl1 VALUES 04 Test Basic database example NSERT INTO util_test tl1 VALUES 05 Test Basic database example NSERT INTO util_test t1 VALUES 06 Test Basic database example NSERT INTO util_test tl1 VALUES 07 Test Basic database example 6 celoiie Connecting to the current server as master CHANGE MASTER TO MASTER_HOST localhost MASTER_USER rpl MASTER_PASSWORD rpl MASTER_PORT 3311 MASTER_LOG_FILE clone bin 000001 MASTER_LOG_POS 106 Starting slave START SLAVE Similarly to export a database and include the replication commands to use the current server s master for example to start a new slave using the same the master use the following command shell gt mysqldbexport server root localhost 3311 util_test export both rpl user rpl rpl rpl slave v 108 PERMISSIONS REQUIRED Source on localhost connected Stopping slave STOP SLAVE Source on localhost connected Exporting metadata from util_te
142. ER for triggers Additionally the SELECT privilege is also required for the mysq1 database On the destination to copy all objects the user must have these privileges CREATE ALTER SELECT INSERT UPDATE LOCK TABLES DROP if drop first option is used SUPER when binary logging is enabled CREATE VIEW for views CREATE ROUTINE EXECUTE for procedures and functions EVENT for events TRIGGER for triggers and GRANT OPTION to copy grants The SUPER privilege might also be required for some objects views procedures functions events and triggers depending on their DEFINER value Actual privileges required may differ from installation to installation depending on the security privileges present and whether the database contains certain objects such as views or events and whether binary logging is enabled The new storage engine and default storage engine options apply to all destination tables in the operation Some option combinations may result in errors during the operation For example eliminating tables but not views may result in an error a the view is copied The rp1 option is not valid for copying databases on the same server An error will be generated When copying data and including the GTID commands you may encounter an error similar to GTID_PURGED can only be set when GTID_EXECUTED is empty This occurs because the destination server is not in a clean replication state To aleviate this problem you can issue a
143. EVER CAUSED AND ON ANY THEORY OF LIABILITY WHETHER IN CONTRACT STRICT LIABILITY OR TORT INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY Ul Ob THE USE OFTHIS SOFTWARE EVEN TE ADVISED OF THM POSOL BLG FS UCH DAMAGE HPD no he licence and distribution terms for any publically available version or derivative of this code cannot be changed i e this code cannot simply be copied and put under another distribution licence including the GNU Public Licence 253 254
144. IES OF MERCHANT ABILITY AND FITNESS IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR BE LIABLE FOR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE DATA OR PROFITS WHETHER IN AN ACTION OF CONTRACT NEGLIGENCE OR OTHER TORTIOUS ACTION ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE test_epoll The test_epoll contains the following notice Copyright c 2001 2006 Twisted Matrix Laboratories Permission is hereby granted free of charge to any person obtaining a copy of this software and associated documentation files the Software to deal in the Software without restriction including without limitation the rights to use copy modify merge publish distribute sublicense and or sell copies of the Software and to permit persons to whom the Software is furnished to do so subject to the following conditions The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software 250 Python License Supplement Windows Only THE SOFTWARE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND EXPRESS OR IMPLIED INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM DAMAGES OR OTHER LIABILITY WHETHER IN AN ACTION OF CONTRACT TORT OR OTHERWISE ARISING FRO
145. Kill Long Data NoAudit Ping Prepare Processlist Query Quit Refresh Register Slave Reset stmt Set option Shutdown Sleep Statistics Table Dump Time file stats Display the audit log file statistics 71 NOTES NOTES format FORMAT f FORMAT Output format to display the resulting data Supported format values GRID default TAB CSV VERTICAL and RAW help Display a help message and exit license Display license information and exit pattern lt PATTERNs e lt PATTERN gt Search pattern to retrieve all entries with at least one attribute value matching the specified pattern By default the standard SQL LIKE patterns are used for matching If the regexp option is set then REGEXP patterns must be specified for matching query type lt QUERY_TYPE gt Commaz separated list of SQL statements commands to search for and match Supported values CREATE ALTER DROP TRUNCATE RENAME GRANT REVOKE SELECT INSERT UPDATE DELETE COMMIT SHOW SET CALL PREPARE EXECUTE DEALLOCATE regexp basic regexp G Indicates that pattern matching will be performed using a regular expression REGEXP from the Python re module By default the simple standard SQL L KE patterns are used for matching This affects how the value specified by the pattern option is interpreted Start date lt START_DATE gt Starting date time to retrieve log entries from the specified date time range If not sp
146. Location For Binary Log Files 3 1 1 How To Change The Location For Binary Log Files At some point a user might want to change the location where the binary log files are stored by default in the datadir There are many reasons for separating the binary log files from the database data These include fault tolerance performance disk management For example you may want to store the binary log files on a different device You can use the 1og bin startup option but simply changing this option is not enough and it will likely result on errors when starting the MySQL server In fact the existing binary log files also need to be moved to the new location and or the entries in the respective index file updated Objectives Change the location for the binary log files on an existing MySQL server Simplify the operation Executing this task manually can be tedious and error prone since it requires existing binary log files to be moved to the new location and the binary log index file to be correctly updated Fortunately the mysqlbinlogmove utility can help us perform this task in an easy way moving all files and automatically updating the respective index file entries appropriately Let s assume that a server is currently running and that it was started with log bin server bin which means that the binary log files are created in the dat adir with the base filename server bin Let s also consider that the dat adir is var lib
147. M OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE Select kqueue The select and contains the following notice for the kqueue interface Copyright c 2000 Doug White 2006 James Knight 2007 Christian Heimes All rights reserved Redistribution and use in source and binary forms with or without modification are permitted provided that the following conditions AIS iWiSie s 1 Redistributions of source code must retain the above copyright notice this list of conditions and the following disclaimer 2 Redistributions in binary form must reproduce the above copyright notice this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution HIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS AS IS AND NY EXPRESS OR IMPLIED WARRANTIES INCLUDING BUT NOT LIMITED TO THE MPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE RE DISCLAIMED IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE OR ANY DIRECT INDIRECT INCIDENTAL SPECIAL EXEMPLARY OR CONSEQUENTIAL AMAGES INCLUDING BUT NOT LIMITED TO PROCUREMENT OF SUBSTITUTE GOODS R SERVICES LOSS OF USE DATA OR PROFITS OR BUSINESS INTERRUPTION OWEVER CAUSED AND ON ANY THEORY OF LIABILITY WHETHER IN CONTRACT STRICT IABILITY OR TORT INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY Ot OEC EAE WS OUR AISLES SORTWARE EVEN DES ADVTSED OFA THEJ
148. MySQL Utilities Abstract This is the MySQL Utilities Reference Manual It documents both the GPL and commercial editions of the MySQL Utilities 1 6 release series through 1 6 3 If you have not yet installed MySQL Utilities please download your free copy from the download site MySQL Utilities is available for Windows OS X and Linux variants For notes detailing the changes in each release see the MySQL Utilities Release Notes For legal information see the Legal Notices For help with using MySQL please visit either the MySQL Forums or MySQL Mailing Lists where you can discuss your issues with other MySQL users For additional documentation on MySQL products including translations of the documentation into other languages and downloadable versions in variety of formats including HTML and PDF formats see the MySQL Documentation Library Document generated on 2015 12 15 revision 45889 Table of Contents PICTACC Rise e hee nk eth oe OG E E alk Se he a A E A Sean ee et Toten as See Aa Sita ae v 1 How to Install MySQL Utilities 0 0 eee cece eee ee eet tree rere ead a eee ee esse ee aaaaeeeeeeeeeeeaaaaaeneeseeeees 1 11 Prerequisites ar eem hens ae a ee a ea es EEA 1 1n2 SOurCe Codema arne a a e a a aea VA OAA 1 1 3 Oracle Linux and Red Hat Linux 6 ceeeeeeeeceeeee cece eee e ee aa ee eeeeeeeeeeaeaaeaeeeeeeeeeaeaaaaneeeeeees 1 1 4 Debian EINUX 4 aac hie ei Savio ena ala ti tia el att 2 15 Microsoft
149. NGE ANY THIRD PARTY RIGHTS 5 CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON 6 1 FOR ANY INCIDENTAL SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF MODIFYING DISTRIBUTING OR OTHERWISE USING PYTHON 1 6 1 OR ANY DERIVATIVE THEREOF EVEN IF ADVISED OF THE POSSIBILITY THEREOF 6 This License Agreement will automatically terminate upon a material breach of its terms and conditions 7 This License Agreement shall be governed by the federal intellectual property law of the United States including without limitation the federal copyright law and to the extent such U S federal law does not apply by the law of the Commonwealth of Virginva excluding Virginia s conflict of law provisions Notwithstanding the foregoing with regard to derivative works based on Python 1 6 1 that incorporate non separable material that was previously distributed under the GNU General Public License GPL the law of the Commonwealth of Virginia shall govern this License Agreement only as to issues arising under or with respect to Paragraphs 4 5 and 7 of this License Agreement Nothing in this License Agreement shall be deemed to create any relationship of agency partnership or joint venture between CNRI and Licensee This License Agreement does not grant permission to use CNRI trademarks or trade name in a trademark sense to endorse or promote products or services of Licensee or any third party 8 By clicking on t
150. NSE 2 0 A copy of the associated Apache License can also be viewed here Section 8 2 2 Apache License Version 2 0 January 2004 8 2 7 Python bindings to the OpenStack Nova API python novaclient You are receiving a copy of python novaclient code The terms of the Oracle license do NOT apply to the python novaclient program it is licensed under the following license separately from the Oracle programs you receive If you do not wish to install this program you may delete it from the install directory Copyright 2010 Jacob kap llan Moss Copyright 2011 OpenStack Foundation All Rights Reserved Licensed under the Apache License Version 2 0 the License you may not use this file except in compliance with the License You may obtain a copy of the License at http www apache org licenses LICENSE 2 0 Unless required by applicable law or agreed to in writing software distributed under the License is distributed on an AS IS BASIS WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied See the License for the specific language governing permissions and limitations under the License 2 Include the following License ONLY ONCE in the documentation even if there are multiple products licensed under the license The following applies to all products licensed under the Apache 2 0 License You may not use the identified files except in compliance with the Apache License Version 2 0 the License
151. O EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT INDIRECT INCIDENTAL SPECIAL EXEMPLARY OR CONSEQUENTIAL DAMAGES INCLUDING BUT NOT LIMITED TO PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES LOSS OF USE DATA OR PROFITS OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY WHETHER IN CONTRACT STRICT LIABILITY OR TORT INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE Any feedback is very welcome http www math keio ac jp matumoto emt html email matumoto math keio ac jp Sockets The socket module uses the functions getaddrinfo and getnameinfo which are coded in separate source files from the WIDE Project http www wide ad jp Cersaie CC 19S 1996 1997 einel IOS arin DOJET All rights reserved Redistribution and use in source and binary forms with or without modification are permitted provided that the following conditions are mets 1 Redistributions of source code must retain the above copyright notice this list of conditions and the following disclaimer 2 Redistributions in binary form must reproduce the above copyright notice this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution 3 Neither the name of the project nor the names of its contributors may be used to endorse
152. OF THE POSSIBILITY OF SUCH DAMAGE This product includes cryptographic software written by Eric Young eay cryptsoft com This product includes software written by Tim A RIERO and ery piles Omen cOm E if Original SSLeay License a Coone eime VE LSCI inane VOU cum I eayiC Cia Oms Ort Gom 252 Python License Supplement Windows Only Be i i mR Rn PA PO A RRA SpA eR Re RRA RB Re Se A A a OP OP a a ORR A Re e R A R o e E S All rights reserved This package is an SSL implementation written by Eric Young eay cryptsoft com he implementation was written so as to conform with Netscapes SSL H his library is free for commercial and non commercial use as long as he following conditions are aheared to The following conditions poly to all code found an this distribution be it the BCs RSA hash DES etc code not just the SSL code The SSL documentation included with this distribution is covered by the same copyright terms except that the holder is Tim Hudson tjh cryptsoft com Gp tS Copyright remains Eric Young s and as such any Copyright notices in the code are not to be removed If this package is used in a product Eric Young should be given attribution as the author of the parts of the library used This can be in the form of a textual message at program startup or in documentation online or textual provided with the package Redistribution and use in source and
153. QL server The Fabric node stores state and routing information in its state store which is a MySQL database Before MySQL Fabric 1 6 x Fabric was part of the MySQL Utilities Fabric is now a standalone product that can be used with or without the Utilities Also MySQL Fabric is no longer bundled with MySQL Utilities as of the 1 6 2 release For additional details see the MySQL Fabric documentation and MySQL Fabric release notes 223 224 Chapter 8 Appendix Table of Contents 8 1 MySQL Utilities Frequently Asked Questions 0 ccccceeceeeeeeeee ee eeeteeeeeeeeeeeeaaaaeeneeeeeeeeeaeaaeeees 225 8 2 Third Party LICGNS S 22 titscciecc eerie Hace A EAA 226 8 2 1 Apache LIDCIOUG waceiceccccteieessncnerceucineieeandeebseuliveeens iaai aeni aaa aaa na eaaa 227 8 2 2 Apache License Version 2 0 January 2004 ssssssissssrrsssrrissrrrrssrrrissrrrrnnrrnessnnt 230 8 2 3 Doctrine DBAL 2 3 4 oo cect cc te eee e ener eee e teeter ee ee ddeon a dinaiia naaa ni ad aiii einai na inaa 233 8 2 4 GNU Lesser General Public License Version 2 1 February 1999 a nn 233 8 2 5 ParamikO LICENSE sacccccsecicencsesteect eN NENE EAEN EEEN EAEEREN RENEE RAER 240 8 2 6 Python Bindings to the OpenStack Neutron API python neutronclient 0 eee 240 8 2 7 Python bindings to the OpenStack Nova API python novaclient cceeeeeeeeeeeees 241 8 2 8 Python LICENSE 2 2i tsieiee cli ele Ale at ea eva ne cee ena 242 8 2 9 Python Lic
154. R IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS N THE SOFTWARE 8 2 4 GNU Lesser General Public License Version 2 1 February 1999 iS 3 q 7 The following applies to all products licensed under the GNU Lesser General Public License Version 2 1 You may not use the identified files except in compliance with the GNU Lesser General Public License Version 2 1 the License You may obtain a copy of the License at http www gnu org licenses lgpl 2 1 html A copy of the license is also reproduced below Unless required by applicable law or agreed to in writing software distributed under the License is distributed on an AS IS BASIS WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied See the License for the specific language governing permissions and limitations under the License GNU LESSER GENERAL PUBLIC LICENSE Version 2 1 February 1999 Copyright C 1991 1999 Free Software Foundation Inc bil wexesiniiciliiin otse t Imigccle iikeyor I BOS CON WIN OZ WO astOIb ius Everyone is permitted to copy and distribute verbatim copies of this license document but changing it is not allowed This is the first released version of the Lesser GPL It also counts as the successor of the GNU Library Public License version 2 hence the version number 2 1 Preamble The licenses for most software are designed to take away your freedom to share and change it By contrast t
155. REPLICATION CLIENT LOCK TABLES and SELECT The user for the slaves must have permissions to start stop the slave perform the checksum and get information about the slave status More specifically the login user to connect to slaves requires the following privileges SUPER and SELECT 5 24 mysqlserverclone Clone Existing Server to Create New Server This utility enables you to clone an existing MySQL server instance to create a new server instance on the same host The utility creates a new datadir new data and on Unix systems starts the server with a socket file You can optionally add a password for the login user account on the new instance If the user does not have read and write access to the folder specified by the new data option the utility shall issue an error Similarly if the folder specified by new data exists and is not empty the utility will not delete the folder and will issue an error message Users must specify the delete data option to permit the utility to remove the folder prior to starting the cloned server OPTIONS mysqlserverclone accepts the following command line options e help Display a help message and exit e license Display license information and exit e delete data Delete the folder specified by new data if it exists and is not empty e basedir The base directory for the MySQL server source as an alternative to the server option 189 OPTIONS shell gt mysq
156. SL key file to use for establishing a secure connection Ssl Specifies if the server connection requires use of SSL If an encrypted connection cannot be established the connection attempt fails Default setting is 0 SSL not required skip lt skip objects gt Specify objects to skip in the operation as a comma separated list no spaces Permitted values are CREATE_DB DATA EVENTS FUNCTIONS GRANTS PROCEDURES TABLES TRIGGERS and VIEWS skip blobs 105 NOTES Do not export BLOB data e skip gtid Skip creation of GTID_ PURGED statements e all Generate an export file with all of the databases and the GTIDs executed to that point e verbose v Specify how much information to display Use this option multiple times to increase the amount of information For example v verbose vv more verbose vvv debug e version Display version information and exit NOTES You must provide connection parameters user host password and so forth for an account that has the appropriate privileges to access all objects in the operation To export all objects from a source database the user must have these privileges SELECT and SHOW VIEW on the database as well as SELECT on the mysq1 database Actual privileges needed may differ from installation to installation depending on the security privileges present and whether the database contains certain objects such as views or events Some combinations of t
157. W 7405 ENG 48 between the U S Department of Energy and The Regents of the University of California for the operation of UC LLNL DISCLAIMER This software was prepared as an account of work sponsored by an agency of the United States Government Neither the United States Government nor the University of California nor any of their em ployees makes any warranty express or implied or assumes any liability or responsibility for the accuracy completeness or usefulness of any information apparatus product or process disclosed or represents that its use would not infringe privately owned rights Reference herein to any specific commer cial products process or service by trade name trademark manufacturer or otherwise does not necessarily constitute or imply its endorsement recommendation or favoring by the United States Government or the University of California The views and opinions of authors expressed herein do not necessarily state or reflect those of the United States Government or the University of California and shall not be used for advertising or product endorsement purposes i The source code for the md5 module contains the following notice Copyright C 1999 2002 Aladdin Enterprises All rights reserved This software is provided as is without any express or implied warranty In no event will the authors be held liable for any damages arising from the use of this software Permission is granted to an
158. _ iF Ij qi OFF audit_log_policy ALL audit_log_rotate_on_size 0 audit_log_strategy ASYNCHRONOUS 4 4 Executing POLICY command Showing options after command Audit Log Variables and Options 4 4 Variable _name Value 4 4 audit_log_buffer_size 1048576 audit_log_file amelie log fuurelilic _Ihexep_ ie heen OnE audit_log_policy LOGINS audit_log_rotate_on_size 0 53 How Do Copy Move The Audit Log audit_log_strategy ASYNCHRONOUS 4 4 Discussion In order to change the type of events recorded to the audit log file the policy settings must be changed This is done with the mysqlauditadmin utility using the command policy and specifying the desired policy value with the value option As expected the specification of the target server is also required using the server option In the above example the policy value was set to LOGINS to write only login events to the log file Nevertheless other values are also permitted to control the information written to the log file ALL write all events QUERIES write only query event NONE disable logging DEFAULT use the default policy Permissions Required User must have the SELECT privilege for the mysql database To view the log file the user must have
159. a name that begins with trig and has a following character 95 OPTIONS By default the utility creates each table on the destination server using the same storage engine as the original table To override this and specify the storage engine to use for all tables created on the destination server use the new storage engine option If the destination server supports the new engine all tables use that engine To specify the storage engine to use for tables for which the destination server does not support the original storage engine on the source server use the default storage engine option The new storage engine option takes precedence over default storage engine if both are given If the new storag ngine or default storage engine option is given and the destination server does not support the specified storage engine a warning is issued and the server s default storage engine setting is used instead By default the operation uses a consistent snapshot to read the source databases To change the locking mode use the locking option with a locking type value Use a value of no locks to turn off locking altogether or lock all to use only table locks The default value is snapshot Additionally the utility uses WRITE locks to lock the destination tables during the copy You can include replication statements for copying data among a master and slave or between slaves The rp1 option permits you to select fro
160. a notification concerning this requirement will be printed And if format is passed in without search parameters then all the records of the audit log are displayed in the specified format The file stats option is not considered a search criteria and is used to display the file statistics of a specified audit log Other search options will be ignored when the file stats option is used except the format option will continue to format the results accordingly To specify the format of the generated results use one of the following values with the format option GRID default Display output in grid or table format like that of the mysql client command line tool e CSV Display output in comma separated values format e VERTICAL Display output in single column format like that of the G command for the mysq1 client command line tool e RAW Display output results in the original raw format of the audit log records which is written in XML Standard SQL Pattern Matching The simple patterns defined by the SQL standard enables users to use two characters with special meanings percent matches zero or more characters and _ underscore matches exactly one arbitrary character In standard SQL these types of patterns are used with the LIKE comparison operator and they are case insensitive by default This utility assumes that they are case insensitive For example e audits Match any string that st
161. a variable for recall in commands show options Display list of options specified by the user on dLevuligyela show variables Display list of variables lt ENTER gt Press ENTER to execute command 198 mysqluc Command line client for running MySQL Utilities lt ESCAPE gt Press ESCAPE to clear the command entry lt DOWN gt Press DOWN to retrieve the previous command lt UP gt Press UP to retrieve the next command in history lt TAB gt Press TAB for type completion of utility option or variable names lt TAB gt lt TAB gt Press TAB twice for list of matching type completion context sensitive One of the most helpful base commands is the ability to see the options for a given utility by typing help lt utility gt When the user types this command and presses ENTER the console will display a list of all of the options for the utility The console provides tab completion for all commands options for utilities and user defined variables Tab completion for commands allows users to specify the starting N characters of a command and press TAB to complete the command If there are more than one command that matches the prefix and the user presses TAB twice a list of all possible matches is displayed Tab completion for options is similar The user must first type a valid MySQL Utility command then types the first N characters of a command and presses TAB for example verb lt TAB gt In this case the consol
162. ab file formats quiet q Turn off all messages for quiet execution server lt server gt Connection information for the server To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket e Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt skip lt skip_objects gt Specify objects to skip in the operation as a comma separated list no spaces Permitted values for this list are CREATE_DB DATA EVENTS FUNCTIONS GRANTS PROCEDURES TABLES TRIGGERS and VIEWS skip blobs Do not import BLOB data skip gtid Skip execution of GTID_PURGED statements skip rpl Do not execute replication commands ssl ca The path to a file that contains a list of trusted SSL CAs ssl cert The name of the SSL certificate
163. ability operations for MySQL servers mysqlfailover e Provides automatic failover on a replication topology e Uses Global Transaction Identifiers GTID MySQL Server 5 6 5 mysqlreplicate e Setup replication e Start from beginning current specific binlog pos mysqlrplms e Provides round robin multi source replication a slave server continually cycles through multiple masters in order to store a consolidated data set e Uses Global Transaction Identifiers GTID MySQL Server 5 6 9 mysqlrpladmin e Administers the replication topology Allows recovery of the master e Commands include elect failover gtid health start stop and switchover mysqlrplcheck e Check replication configuration e Tests binary logging on master mysqlrplshow e Show slaves attached to master e Can search recursively e Show the replication topology as a graph or list mysqlrplsync e Check data consistency between servers in a replicated setup 61 Server Operations e Uses Global Transaction Identifiers GTID e Requires MySQL Server 5 6 14 and higher e mysqlslavetrx e Skip multiple transaction on slaves e Uses Global Transaction Identifiers GTID 4 5 Server Operations These utilities are used to perform server wide operations mysqlserverclone e Start a new instance of a running server e mysqlserverinfo e Show server information e Can search for running servers on a host e Access online or offline servers 4 6 Spe
164. able on Server Y Risks Should the copy fail in the middle the destination databases may be incomplete or inconsistent Should this occur drop the destination database in question repair the cause of the failure and restart the copy 3 2 4 How Can Tell If a Table on Server X has the same Structure as the Same Table on Server Y Multiple database servers that are kept synchronized manually or are compartmentalized for security purposes but are by practice kept up to date manually are prone to unintentional and sometimes intentional divergence For example you may maintain a production server and a development server The development server may have the same databases and the same structures as the production server but maybe not the same data However the natural course of administrative tasks and maintenance can sometimes leave the development server behind When this happens you need to have a way to quickly check the schema for a table on the production server to see if the development server has the same structure The utility of choice for this operation is mysqldiff Objectives The goal is to compare a table schema on one machine to another and show they differ Example Execution shell gt mysqldiff serverl root root localhost server2 root root localhost 3307 world city world city changes for server2 serverl on localhost connected server2 on localhost connected Comparing worl
165. ailable in your system s PATH Alternatively you can access their location from MySQL Workbench by selecting Tools from the main menu and then Start Shell for MySQL Utilities This opens a terminal shell window in the mysqluc utility shell Type help to list the available commands Figure 2 1 Starting MySQL Utilities from Workbench MySQL Workbench Local instance MySQL56_1 x File Edit View Query Database Server Tools Scripting Help a JG Sl So al Browse Audit Log File Configuration Navigator Utilities Start Shell for MySQL Utilities SCHEMAS Q Filter objects gt sakila gt test world Eure Schemas Information s Object Info Session i Connecting to MySQL Servers You can launch any of the utilities listed by typing the name of the command To find out what options are available use the option or read the appropriate manual page The utilities are designed to work on MySQL systems with grants enabled but can also operate on servers started with the skip grant tables startup option However this practice is strongly discouraged and should be used only in situations where it is appropriate or deemed a last resort 2 2 Connecting to MySQL Servers This section describes the ways you can connect to a MySQL server via a MySQL Utility or via the MySQL Utilities library methods 2 2 1 Connection Parameters To connect to a server it is necessary to specify connection parameters
166. al log slow query log user mysql log error source temp_clone Cloning the MySQL server running on localhost Creating new data directory Configuring new instance roca cingim sg M teoo llss Setting up empty database and mysql tables Starting new instance of the server Testing connection to new instance Success Setting the root password Connection Information uroot proot socket source temp_clone mysql sock aa CENS Now that we have a running instance we can export all of the data from the host to the clone shell gt mysqldbexport server root root localhost 3306 export both all gt data sql shell gt mysqldbimport server root root localhost 3307 import both data sql Source on localhost connected Importing definitions and data from data sql done Discussion As you can see this is a multiple step process We saw examples of using the mysqlserverinfo mysqlserverclone mysqldbexport and mysqldbimport utilities 47 How Can Find What MySQL Servers Are Running Notice in the example we used port 3307 for the clone which is reflected in the mysqidbimport utility server option Permissions Required The user must have permission to read all databases Since we are using the root account for these examples and you typically would permissions are not generally a problem You also need permissions to create the new data directory and write data
167. all MySQL Utilities on OS X or Ubuntu After you download and unpack the repository distribution open a terminal window and navigate to the directory containing the file Then unpack the file and install MySQL Utilities using the setup py script as shown below shell gt unzip mysql utilities 1 6 3 zip shell gt cd mysql utilities 1 6 3 shell gt python setup py build shell gt sudo python setup py install Note R Using this repository requires that you have Connector Python installed or install it separately For additional information see Section 1 1 Prerequisites 1 3 Oracle Linux and Red Hat Linux 6 This repository is available as an architecture independent RPM package rpn file Debian Linux After you download the package install it using the following command or similar depending on your platform configuration shell gt sudo rpm i mysql utilities 1 6 3 el16 noarch rpm You can also use the RPM package manager that is part of your base operating system See your operating system documentation for more details Note R MySQL Utilities requires Connector Python to be installed For additional information see Section 1 1 Prerequisites 1 4 Debian Linux The deb repository is built for Debian 6 and is architecture independent Although built expressly for Debian 6 it can be installed on various ports such as amd64 i386 etc Python 2 6 and Debian 7 currently ships with Python 2 7 For Debian 7
168. all databases default None databases action store dest dbs_to_copy if opt dbs_to_copy is None for db in serverl get_all_databases 208 Example db_list append db 0 None else or Clo iin ojo Cle rto coos solae HW g db_list append db None Notice we are creating a list of tuples This is because the dbcopy module uses a list of tuples in the form old_db new_db to enable you to copy a database to a new name For our purposes we do not want a rename so we leave the new name value set to None Next we want a list of all of the users Once again you could construct the new solution to be flexible by permitting the user to specify the users to copy We leave this as an exercise In this case we do not have a primitive for getting all users created on a server But we do have the ability to run a query and process the results Fortunately there is a simple SQL statement that can retrieve all of the users on a server For our purposes we get all of the users except the root and anonymous users then add each to a list for processing later users serverl exec_query SELECT user host FROM mysql user WHERE user root and user for user in users user_list append user 0 user 1 Now we must clone the original server and create a viable running instance When you examine the mysqlserverclone utility code you see that it calls another module located in the mysql utilities c
169. ample format g specifies the grid format An error occurs if a prefix matches more than one valid value The path to the MySQL client tools should be included in the PATH environment variable in order to use the authentication mechanism with login paths This will allow the utility to use the my_print_defaults tools which is required to read the login path values from the login configuration file mylogin cnf EXAMPLES For each example assume that the root user on localhost has sufficient privileges to kill queries and connections Kill all connections created by user john shell gt mysqlprocgrep server root localhost match user john kill connection format CSV The following KILL commands were executed Id User Host db Command Time State Info 4 john localhost 50706 mysql Sleep 5 Kill all connections that have been idle for more than 1 hour shell gt mysqlprocgrep server root localhost match command sleep age lh kill connection PERMISSIONS REQUIRED The user must have the SELECT privilege on the mysql database 154 mysqlreplicate Set Up and Start Replication Between Two Servers 5 18 mysqlreplicate Set Up and Start Replication Between Two Servers This utility permits an administrator to start replication from one server the master to another the slave The user provides login information for the slave and connection information for connecting to the master It is als
170. and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt sql print sql Q Instead of displaying the selected processes emit the SELECT statement that retrieves information about them If the kill connection or kill query option is given the utility generates a stored procedure named kill_processes for killing the queries rather than a SELECT statement sql body Like sq1 but produces the output as the body of a stored procedure without the CREATE PROCEDURE part of the definition This could be used for example to generate an event for the server Event Manager When used with a kill option code for killing the matching queries is generated Note that it is not possible to execute the emitted code unless it is put in a stored routine event or trigger For example the
171. and the waiting time for slaves to reach an established synchronization point namely the checksum timeout 183 and rpl timeout 184 options A polling process is applied on each slave to periodically check if replication caught up with the defined sync point The periodic interval to perform this check can be adjusted with the interval 184 option These option are fundamental to control the impact of the execution of the utility on the replication system limiting the execution time of the checksum queries for large tables and the time slaves wait for replication to catch up In case the timeouts defined by those options are reached the check is skipped Nevertheless the user can always execute the utility later only for the skipped tables using higher timeout values The utility provides the flexibility to be executed separately for different set of servers only affecting different parts of the replication system at each time For example considering an heterogeneous system where slaves have a different performances composed by one master M and three slaves S1 S2 and S3 To minimize the impact on the master the user can run the utility first for the master M and the fastest slave S1 and then run it again only for the slaves S1 S2 and S3 If no consistency issues are found in the first execution M S1 nor in the second execution S1 S2 S3 then by transitivity and due to the inclusion of the same serv
172. and vertical The default is grid innodb i Display InnoDB tablespace usage This includes information about the shared InnoDB tablespace as well as idb files for InnoDB tables with their own tablespace logs l Display general query log error log and slow query log usage no headers h Do not display column headers This option applies only for grid csv and tab output quiet q Suppress informational messages relaylog r Display relay log usage server lt server gt Connection information for the server To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure Use login paths from your my login cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt ssl ca The path to a file that contains a list of trusted SSL CAs ssl cert
173. ansactions with custom data changes were accidentally committed on a slave without turning off binary logging and that those changes are specific to that slave and should not be replicated e g additional data for reporting purposes data mining or local administrative commands If that slave becomes the new master as a result of a failover or switchover then those errant transactions will start being replicated across the topology In order to avoid this situation errant transactions should be skipped on all slaves Note R An errant transaction is a transaction that exists on a slave but not on all of the slaves connected to the master An errant transaction has a GTID associated with the UUID of the slave to which it was committed These type of transactions can result from write operations performed on the slave while binary logging is enabled By nature these transactions should not be replicated It is considered poor practice to execute write operation on slave with binary logging enabled because it will create errant transactions that can lead to unstable topologies in failover scenarios The best way to deal with errant transactions is to avoid writing or applying query statements to the slave directly without turning off binary logging first 195 OPTIONS There are other situations like provisioning and scale out where injecting empty transaction can be a useful technique See Using GTIDs for Failover and Scaleout for more
174. arts with audit e Slogs Match any string containing the word log wo ow a Match any string consisting of one or more characters 69 REGEXP Pattern Matching POSIX For documentation about the standard SQL pattern matching syntax see Pattern Matching REGEXP Pattern Matching POSIX Standard REGEXP patterns are more powerful than the simple patterns defined in the SQL standard A regular expression is a string of ordinary and special characters specified to match other strings Unlike SQL Patterns REGEXP patterns are case sensitive The REGEXP syntax defines the following characters with special meaning Match any character A Match the beginning of a string Match the end of a string Match zero or more repetitions of the preceding regular expression 4 Match one or more repetitions of the preceding regular expression Match zero or one repetition of the preceding regular expression Match either the regular expressions from the left or right of I Indicates a set of characters to match caret symbol acquires a different meaning if it is the first character of the set matching the complementary set i e all the characters that are not in Note R Special characters lose their special meaning inside sets In particular the the set will be matched m Match m repetitions of the preceding regular expression m n Match from m to n repetitions of the preceding regular e
175. at contains a list of trusted SSL CAs e ssl cert The name of the SSL certificate file to use for establishing a secure connection e ssl cert The name of the SSL key file to use for establishing a secure connection e ssl Specifies if the server connection requires use of SSL If an encrypted connection cannot be established the connection attempt fails Default setting is 0 SSL not required e version Display version information and exit NOTES For the format option the permitted values are not case sensitive In addition values may be specified as any unambiguous prefix of a valid value For example format g specifies the grid format An error occurs if a prefix matches more than one valid value The path to the MySQL client tools should be included in the PATH environment variable in order to use the authentication mechanism with login paths This will allow the utility to use the my_print_defaults tools which is required to read the login path values from the login configuration file mylogin cnf EXAMPLES Find all objects with a name that matches the pattern t_ the letter t followed by any single character shell gt mysqlmetagrep pattern t_ server john localhost 4 4 4 4 Connection Object Type Object Name Database 4 4 4 4 john localhost 3306 TA
176. ate a clone of his user account for two new users sally and john Each of these users will require a new password Example Execution shell gt mysqluserclone source root localhost destination root localhost joe localhost sally secretl localhost john secret2 localhost sourcelonmMocal hostem connected Destination on localhost connected Cloning 2 users Cloning joe localhost to user sally secretl localhost Cloning joe localhost to user john secret2 localhost Rae Me i Sb Sh Sh SE OSE OE Discussion In the above example we see the use of the mysqluserclone utility to clone the joe user to two new user accounts Notice we used the source option to connect to the original server and dest ination for the same server After that we simply list the user we want to clone and the new users we want to create In this case we use the format username password host to specify the user account name password optional and host When the utility finishes you will have two new user accounts that have the same privileges as the original user joe localhost Permissions Required On the source server the user must have the SELECT privilege for the mysql database 24 What Options Are Used With Each Utility On the destination server the user must have the global CREATE USER privilege or the INSERT privilege for the mysql database as well as the GRANT OPTION privilege and the privileges that the original
177. ated format e vertical Display output in single column format like that of the G command for the mysq1 client command line tool OPTIONS mysqluserclone accepts the following command line options e help Display a help message and exit e license Display license information and exit e destination lt destination gt Connection information for the destination server To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt e Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt 202 OPTIONS e Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt dump d Display the GRANT statements to create the account rather than executing them In this case the utility does not connect to the destination server and no dest ination option is needed format lt list_for
178. aves for these purposes cases where you are working with a particular server or if replication is not in use you will need some way to duplicate not only the data but also the server and its startup parameters Objectives Create a new instance of a running server complete with the same options and the same data Example Execution To meet this objective we need to use several utilities But before we get started we need to know what specific options the host server is using To do this we use the mysqlserverinfo utility to discover the configuration file and the my_print_defaults tool to print the defaults We can also show the process id to see what command line options are being used We get this from using the show servers option with mysqlserverinfo On POSIX systems we can use the ps command to find the command line options shell gt mysqlserverinfo server root root localhost format vertical show servers The following MySQL servers are active on this host Process id 2377 Data path usr local mysql data Process id 2478 Data path Volumes Source source temp_13001 Process id 2487 Data path Volumes Source source temp_13002 Source on localhost connected kkkkxkxkxkxkxkkkkkkxkkxkxkkkkkkxk iL row KKEKKKEKKKKKEKKKKEKKKAKKKKKKKK server localhost 3306 verston orl OR loc datadir usr local mysql data basedir usr local mysql 5 1 50 osx10 6 x86_64 plugin_dir usr local mysql 5 1 5
179. ay output in tab separated format vertical Display output in single column format like that of the G command for the mysq1 client command line tool The utility uses of the SHOW SLAVE HOSTS statement to determine which slaves the master has If you want to use the recurse option slaves should have been started with the report host and report port options set to their actual host name and port number or the utility may not be able to connect to the slaves to determine their own slaves OPTIONS mysqlrplshow accepts the following command line options help Display a help message and exit license Display license information and exit discover slaves login lt slave login gt Supply the user and password in the form lt user gt lt passwd gt or lt login path gt for discovering slaves and relay slaves in the topology For example discover joe secret will use joe as the user and secret as the password for each discovered slave format lt format gt f lt format gt Specify the display format for column list output Permitted format values are grid csv tab and vertical The default is grid This option applies only if show list is given master lt source gt Connection information for the master server To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to
180. bin 000031 Checking slave localhost 3312 I O thread is currently reading mysql bin 000031 Sh Sh SE OSE OSH OEE 84 PERMISSIONS REQUIRED Checking slave localhost 3313 I O thread is currently reading mysql bin 000031 Range of binlog files available from mysql bin 000023 to mysql bin 000031 Latest binlog file replicated by all slaves mysql bin 000030 Purging binary logs prior to mysql bin 000027 Range of binlog files available from mysql bin 000027 to mysql bin 000031 Range of binlog files purged from mysql bin 000023 to mysql bin 000026 Sh Sh Sh SE OSE OSE OE Display a query statement you could use to manually purge all binary log files not in use from a server without actually purging them by using the dry run option shell gt mysqlbinlogpurge server root root localhost 3310 dry run To manually purge purge the binary logs Execute the following query PURGE BINARY LOGS TO mysql bin 000004 PERMISSIONS REQUIRED By default the user name you specified to connect to the server must have SUPER and REPLICATION SLAVE permissions to be able to purge the binary logs 5 5 mysqlbinlogrotate Binary log rotate utility This utility rotates the binary log by closing the active log and opening a new binary log file The user must provide the server connection parameters with the server 85 option The user can also use the min size 86 option to conditionally rotate the active binary log file on
181. bject and the result of the execution is printed on that stream Note that the output and connector arguments must be supplied as keyword arguments All other arguments are treated as connection specifiers Parameters connections Sequence of connection specifiers to send the search to output File object to use for writing the result connector Connector to use for connecting to the servers 6 4 Parsers 6 4 1 mysql utilities parser Parse MySQL Log Files This module provides classes for parsing MySQL log files Currently Slow Query Log and General Query Log are supported Classes class mysql utilities parser GeneralQueryLog stream This class parses the MySQL General Query Log Instances are iterable but the class does not provide multiple independent iterators For example to read the log and print the entries gt gt gt general_log open var lib mysql mysql log gt gt gt log GeneralQueryLog general_log gt gt gt for entry in log print entry Parameters stream file type a valid file type for example the result of the built in Python function open version Returns Version of the MySQL server that produced the log Return type tuple program Returns Full path of the MySQL server executable Return type str port Returns TCP IP port on which the MySQL server was listening Return type int 216
182. bles list each element as a separated argument for the utility using fully qualified names The user can also choose to exclude some databases or tables from the check using the exclude 183 option The utility also provides some important features that allow users to adjust the execution of the consistency check to their system For example the user may wish the utility to minimize execution of the synchronization process To do so the user uses the rpl timeout 184 to define the maximum time for each slave to synchronize More specifically allow slaves to catch up with the master in order to compare the data During this waiting step the slaves status is periodically polled according to a predefined time interval This polling interval to verify if the slaves are synced can be adjusted with the interval 184 option A checksum query is used to compare the data of each table between servers The checksum calculation step is skipped if its execution exceeds a predefined time avoiding undesirable performance impacts on the target system if it takes too long to execute The user can change the checksum timeout using the checksum t imeout 183 option Users can also use the verbose 185 option to see additional information when the utility executes This utility is designed to work exclusively for servers that support global transaction identifiers GTIDs and have gt id_mode ON Servers with GTID disabled will be skipped by the u
183. bruary 1999 8 2 6 Python Bindings to the OpenStack Neutron API python neutronclient 240 Python bindings to the OpenStack Nova API python novaclient You are receiving a copy of python neutronclient code The terms of the Oracle license do NOT apply to the python neutronclient program it is licensed under the following license separately from the Oracle programs you receive If you do not wish to install this program you may delete it from the install directory Copyright 2012 OpenStack Foundation All Rights Reserved Licensed under the Apache License Version 2 0 the License you may not use this file except in compliance with the License You may obtain a copy of the License at http www apache org licenses LICENSE 2 0 Unless required by applicable law or agreed to in writing software distributed under the License is distributed on an AS IS BASIS WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied See the License for the specific language governing permissions and limitations under the License 2 Include the following License ONLY ONCE in the documentation even if there are multiple products licensed under the license The following applies to all products licensed under the Apache 2 0 License You may not use the identified files except in compliance with the Apache License Version 2 0 the License You may obtain a copy of the License at http www apache org licenses LICE
184. buted as part of the Derivative Works within the Source form or documentation if provided along with the Derivative Works or within a display generated by the Derivative Works if and wherever such third party notices normally appear The contents of the NOTICE file are for informational purposes only and do not modify the License You may add Your own attribution notices within Derivative Works that You distribute alongside or as an addendum to the NOTICE text from the Work provided that such additional attribution notices cannot be construed as modifying the License 231 Apache License Version 2 0 January 2004 You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use reproduction or distribution of Your modifications or for any such Derivative Works as a whole provided Your use reproduction and distribution of the Work otherwise complies with the conditions stated in this License 5 Submission of Contributions Unless You explicitly state otherwise any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License without any additional terms or conditions Notwithstanding the above nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions 6 Trademarks This License doe
185. by object including their access level privileges raw display the GRANT statements that define the user s privileges The utility also provides an optional privileges option that permits users to specify a list of privileges that form the minimal set for access The list of privileges forms a filter such that a user must have all of the privileges specified for a specific object Note R It is possible that the combination of specified privileges can form an invalid set In such cases the utility will ignore the errant privilege For example specifying the SELECT privilege for a routine causes the utility to exclude it from the filter check OPTIONS mysqlgrants accepts the following command line options help Display a help message and exit inherit level lt level gt Specifies the inheritance level of the GRANT operations This parameter has three options global database and object The default value is global e global default indicates grants shown will be at the global level such as GRANT ON All grants are shown e database indicates grants will be shown at the database level such as GRANT ON db1 Global level grants are not shown object indicates grants will be shown at the object level such as GRANT ON db1 tbl1 Database and global level grants are not shown This option was added in MySQL Utilities 1 6 2 license Display license information and exit pri
186. calhost 3332 root localhost 3333 root localhost 3334 candidates root localhost 3333 root localhost 3334 elect Electing candidate slave from candidate list then slaves list Best slave found is located on localhost 3332 Er done To perform failover after a master has failed use the following command shell gt mysqlrpladmin slaves root localhost 3332 root localhost 3333 root localhost 3334 candidates root localhost 3333 root localhost 3334 failover Performing failover Candidate slave localhost 3333 will become the new master Preparing candidate for failover Creating replication user if it does mot exist Stopping slaves Performing STOP on all slaves Switching slaves to new master Starting slaves Performing START on all slaves Checking slaves for errors Failover complete 170 EXAMPLES done To see the replication health of a topology with GTID MODE ON server version 5 6 5 or higher and discover all slaves attached to the master run the following command We use the result of the failover command above shell gt mysqlrpladmin master root localhost 3333 slaves root localhost 3332 root localhost 3334 health Getting health for master localhost 3333 Replication Topology Health 4 4 4 4 4 host joe mole state gtid_mode health 4
187. can be used to store the connection values and the MySQL Connecting to MySQL Servers documentation Permissions Required Required permissions include the ability to read the SSL certificate files and the path where they are located regardless of the form these SSL certificate paths are given to the MySQL Utilities in addition of the required permissions that each utility requires to accomplish its specific task Tips and Tricks In the configuration file different connection options can be stored and separated in groups The desired group used by the MySQL Utilities can be expressed by indicating the group name in the form config path group name such as C MySQL instances cnf instance_3307 port 3307 user root password pass host localhost ssl ca C newcerts cacert pem ssl cert C newcerts client cert pem ssl key C newcerts client key pem instance_3308 port 3308 user root password other pass host localhost ssl ca C newcerts cacert_2 pem ssl cert C newcerts client cert_2 pem ssl key C newcerts client key_2 pem 52 Specialized Operations shell gt mysqlreplicate master c MySQL instances cnf instance_3307 slave C MySQL instances cnf instance_3308 3 6 Specialized Operations The tasks described in this section relate to specific situations or configurations and may not apply in the general case For example some tasks require a specific commercial plugin More specifically the f
188. cenario we used the mysql replicate utility to set up a replication topology between the existing server and the two new servers Notice the use of the b flag which this replication start from the first event recorded in the master s binary log After setting our replication topology we made use of the mysqirpladmin utility specifying both the master and slave servers and using the health command to check the status of the replication Since our master server had lots of information it is normal for the new slaves to take some time to catch up thus the slave delay message on the health column of the output However if all goes well after some time the slaves will eventually catch up and when that happens the health column will show an OK status When this happened we used the mysql rpladmin utility yet again this time with switchover command Using the new master option we specify the server that will become the new master We can not forget the demote master option which turns the old master into a slave otherwise it would still behave as a master just without any slaves Server will become a slave of Server2 After the switchover Server2 becomes the master server for both Server1 and Server3 which are now the slaves Permissions Required The m_account user needs the following privileges for the mysqlreplicate SELECT and INSERT privileges on mysql database REPLICATION SLAVE REPLICATION CLIENT and GRANT OPTION As for the sla
189. cialized Operations These utilities are designed to be used with a specific commercial extension In this case these utilities require the Audit Log Plugin mysqlauditadmin e Monitor the audit log Copy rotate and configure the audit log e mysqlauditgrep e Search the audit log e Output results to different formats 62 Chapter 5 Manual Pages Table of Contents 5 1 mysqlauditadmin Allows users to perform maintenance action on the audit log 63 5 2 mysqlauditgrep Allows users to search the current or an archived audit log 66 68 5 3 mysqlbinlogmove Binary log relocate Utility 0 0 0 2 cece ceeeee cece ceeeeeeeeeee sees aeaaeeeeeeeeeeeeaeaaes 75 5 4 mysqlbinlogpurge Binary log purge Utility 2 0 0 cee eee ee cece eeeeeeeeeeee ee aeaaeeeeeeeeeeeanaaee 81 5 5 mysqlbinlogrotate Binary log rotate Utility 0 0 0 cece cece eee eee eeeteeeeeeeeeeeaaeaeteeeeeeeeeaea 85 5 6 mysqldbcompare Compare Two Databases and Identify Differences cccceeeeeeneeeees 87 5 7 mysqldbcopy Copy Database Objects Between Servers ccccecesseeceeeeneeeeeeaaeeeeeeaaeeeeees 95 5 8 mysqldbexport Export Object Definitions or Data from a Database ccceeeeeeeneeeeeees 101 5 9 mysqldbimport Import Object Definitions or Data into a Database cceeeeeeeeeeeeeees 109 5 10 mysqidiff Identify Differences Among Database Objects
190. cifies if the server connection requires use of SSL If an encrypted connection cannot be established the connection attempt fails Default setting is 0 SSL not required Stats Show index performance statistics verbose v Specify how much information to display Use this option multiple times to increase the amount of information For example v verbose vv more verbose vvv debug version Display version information and exit 145 NOTES e worst lt N gt If stats is also passed in limit index statistics to the worst N indexes The default value of Nis 5 if omitted NOTES You must provide connection parameters user host password and so forth for an account that has the appropriate privileges to read all objects accessed during the operation For the format option the permitted values are not case sensitive In addition values may be specified as any unambiguous prefix of a valid value For example format g specifies the grid format An error occurs if a prefix matches more than one valid value The path to the MySQL client tools should be included in the PATH environment variable in order to use the authentication mechanism with login paths This will allow the utility to use the my_print_defaults tools which is required to read the login path values from the login configuration file mylogin cnf EXAMPLES To check all tables in the employees database on the local server to se
191. cifying the object to be transformed in either the difference report default or the transformation report designated with the difftype sql option Consider the following command shell gt mysqldbcompare serverl root hostl server2 root host2 difftype sql db1 dbx The leftmost database db1 exists on the server designated by the server1 option host 1 The rightmost database dbx exists on the server designated by the server2 option host 2 changes for server1 Produce output that shows how to make the definitions of objects on server1 like the definitions of the corresponding objects on server2 changes for server2 Produce output that shows how to make the definitions of objects on server2 like the definitions of the corresponding objects on server1 The default direction is server1 You must provide connection parameters user host password and so forth for an account that has the appropriate privileges to access all objects in the operation If the utility is to be run on a server that has binary logging enabled and you do not want the comparison steps logged use the disable binary logging option OPTIONS mysqldbcompare accepts the following command line options all a Compare all database in common with the same name between two servers The a11 option ignores the following databases INFORMATION _SCHEMA PERFORMANCE_SCHEMA mysql and sys Note R The sys database is
192. cks permissions for the master slaves and candidates at startup 129 NOTES At startup the console will attempt to register itself with the master If another console is already registered and the failover mode is auto or elect the console will be blocked from running failover When a console quits it unregisters itself from the master If this process is broken the user may override the registration check by using the force option Mixing IP and hostnames is not recommended The replication specific utilities will attempt to compare hostnames and IP addresses as aliases for checking slave connectivity to the master However if your installation does not support reverse name lookup the comparison could fail Without the ability to do a reverse name lookup the replication utilities could report a false negative that the slave is not connected to the master For example if you setup replication using MASTER_HOST ubuntu net on the slave and later connect to the slave with mysqlrplcheck and have the master specified as master 192 168 0 6 using the valid IP address for ubuntu net you must have the ability to do a reverse name lookup to compare the IP 192 168 0 6 and the hostname ubuntu net to determine if they are the same machine Similarly in order to avoid issues mixing local IP 127 0 0 1 with localhost all the addresses 127 0 0 1 will be internally converted to localhost by the utility Nevertheless I
193. command shell gt mysqlauditadmin audit log name audit log 13486539046497235 copy remote login user host copy to PERMISSIONS REQUIRED The user must have permissions to read the audit log on disk and write the file to the remove location 5 2 mysqlauditgrep Allows users to search the current or an archived audit log 68 Standard SQL Pattern Matching This utility allows you to search the current or archived audit logs allowing you to display data from the audit log file according to the defined search criterion It also allows you to output the results in different formats namely GRID default TAB CSV VERTICAL and RAW the original XML format This utility allows you to search and filter the returned audit log records by users users date and time ranges start date and nd date SQL query types query type logged event and record types event type status status and matching patterns pattern Any of these search options can be combined and used together with the retrieved records resulting from all passed in options being true The pattern supports two types of pattern matching standard SQL used with the SQL LIKE operator SQL patterns and standard REGEXP POSIX regular expression patterns This utility always requires an audit log file to be passed in so the AUD T_LOG_FILE argument is searched as a full path and file name for the audit log file If not specified
194. comments slightly for automatic TOC extraction 1999 10 18 lpd Fixed typo in header comment ansi2knr rather than md5 added conditionalization for C compilation from Martin Purschke lt purschke bnl gov gt TOIS OSW Led Original version Asynchronous socket services The asynchat and asyncore modules contain the following notice Copyright 1996 by Sam Rushing All Rights Reserved Permission to use copy modify and distribute this software and its documentation for any purpose and without fee is hereby granted provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation and that the name of Sam Rushing not be used in advertising or publicity pertaining to distribution of the software without specific written prior permission SAM RUSHING DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS IN NO EVENT SHALL SAM RUSHING BE LIABLE FOR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE DATA OR PROFITS WHETHER IN AN ACTION OF CONTRACT NEGLIGENCE OR OTHER TORTIOUS ACTION ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE Cookie management The Cookie module contains the following notice Copyright 2000 by Timothy O Malley lt timo alum mit edu gt All Rights Reserved Permission to us
195. connect to the slaves and the utility will attempt to discover all the slaves connected with the master using the specified login For example discover slaves login root secret is used to discover all of the slaves and login to each using the root user id and the password secret The discover slaves login 183 can be very handy especially if there is a huge number of slaves in the topology but bear in mind that the explicit specification of slaves is safer and that discovery can fail to find some servers In particular it is important to note that in order for slaves to be discovered they must be started with the report host and report port options with appropriate values and they must be correctly connected to the master IO thread running otherwise discovery may fail to identify the slave In the above example no data consistency issues were found In case any data difference are found each is clearly identified by the DIFF prefix followed by concise information of where and what is the difference Additionally at the end the utility displays a summary of the number of issues found The utility also allows users to check slaves without specifying the master However be advised that only checking the slaves will not guarantee that there is no data consistency issue between 43 How To Fix Errant Transactions on the Replication Topology the master and the slaves Also keep in mind that the results provided by the
196. ction of software functions and or data prepared so as to be conveniently linked with application programs which use some of those functions and data to form executables The Library below refers to any such software library or work which has been distributed under these terms A work based on the Library means either the Library or any derivative work under copyright law that ds to say a work containing the Library or 2 portion of it either verbatim or with modifications and or translated straightforwardly into another language Hereinafter translation is included without limitation in the term modification Source code for a work means the preferred form of the work for making modifications to it For a library complete source code means all the source code for all modules it contains plus any associated interface definition files plus the scripts used to control compilation and installation of the library Activities other than copying distribution and modification are not covered by this License they are outside its scope The act of running a program using the Library is not restricted and output from such a program is covered only if its contents constitute a work based on the Library independent of the use of the Library in a tool for writing it Whether that is true depends on what the Library does and what the program that uses the Library does 1 You may copy and distribute verbatim copies of the Library s co
197. d slave on localhost connected Checking for binary logging on master Setting up replication H done Next switchover to the previous master to restore the initial replication topology shell gt mysqlrpladmin master root server2 3312 slaves root server2 3313 root server4 3314 root server5 3315 rpl user rpl rpl new master root serverl1 3311 demote master switchover Checking privileges Performing switchover from master at server2 3312 to slave at serverl1 3311 Checking candidate slave prerequisites Checking slaves configuration to master Waiting for slaves to catch up to old master Stopping slaves Performing STOP on all slaves Demoting old master to be a slave to the new master Switching slaves to new master Starting all slaves Performing START on all slaves Checking slaves for errors Switchover complete Replication Topology Health 4 4 4 4 4 host lee Ort role state gtid_mode health 4 4 serverl SSal al MASTER UP ON OK server2 133712 SLAVE UP ON OK server3 3313 SLAVE UP ON CuK server4 S34 SLAVE UP ON OK 39 Restore the Previous Master After Failover server5 3315 SLAVE UP ON OK The initial replication topology is now restored and mysqlfailover can be re
198. d city to world city FAIL Object definitions differ changes for server2 yorllel ley qm Ywerellel eaea 4 6 4 7 CountryCode char 3 NOT NULL DEFAULT District char 20 NOT NULL DEFAULT Population int 11 NOT NULL DEFAULT 0 Climate enumi tropicall dry mild continental polar DEFAULT NULL PRIMARY KEY ID KEY CountryCode CountryCode CONSTRAINT city_ibfk_1 FOREIGN KEY CountryCode REFERENCES Country Code Compare failed One or more differences found Discussion Notice to accomplish this task we simply specified each server with server1 and server2 then specified the database objects to compare with the lt db gt lt object gt lt db gt lt object gt syntax Permissions Required The user must have SELECT privileges for both objects on both servers as well as SELECT on the mysql database Tips and Tricks You can set the direction of the compare by using the changes for option For example to see the changes for server1 as the target use changes for server1 19 How Can Synchronize a Table on Two Servers Where Neither is Up to date 3 2 5 How Can I Synchronize a Table on Two Servers Where Neither is Up to date When working with servers that are used in different networks or are compartmentalized or simply intentionally manually redundant they do not use replication or perhaps through some crisis you may encoun
199. d double clicking the pkg file OS X Note R MySQL Utilities requires Connector Python to be installed For additional information see Section 1 1 Prerequisites Chapter 2 Introduction Table of Contents 2 1 Introduction to MySQL Utilities 2 0 eect cette eee e eee eee ee ee ee ee sees aaaaeeeeeeeeeeeaeaaaaeeeeeeseeaeaaeaaes 5 2 2 Connecting to MySQL Servers ashari io aanika eana a d EAEEREN AAEE aeiia 6 2 2 1 Connection Parameters orcssicesiia naia eaaa ai A a aaa aas 6 2 2 2 Specifying Connections in Python Library sssssessssssrssssssssssrrrrsrrssssrrrrrntrssssnrrrnrerss 9 This chapter introduces MySQL Utilities and presents information on how to access and download MySQL Utilities It also includes the basics of how to use the account login option common to all utilities 2 1 Introduction to MySQL Utilities What are the MySQL Utilities It is a package of utilities that are used for maintenance and administration of MySQL servers These utilities encapsulate a set of primitive commands and bundles them so they can be used to perform macro operations with a single command The utilities are written in Python available under the GPLv2 license and are extendable using the supplied library They are designed to work with Python versions 2 6 or later and there is no support yet for Python v3 1 How do we access the MySQL Utilities The MySQL Utilities are command line scripts which by default are av
200. d see a list of the objects whose name matches a prefix or pattern Fortunately the mysqlimetagrep utility can get this done Objectives Find all objects whose name begins with a known prefix More specifically find any mention of the word cost Example Execution shell gt mysqlmetagrep server root root localhost body 4 4 4 Connection Object Type Object Name INscoe ss Clliccalhostessi0 Cuan HUNG EON Mapus t Ecos root aiocalhost oS0 0 TABLE supplies root 0localhos t 330e TABLE Eai e E E E EN eee pattern cost 4 4 Database Field Type Matches 4 4 gricts ROUTINE acijust cost gricts COLUMN eoste sakila COLUMN replacement_cost 4 4 shell gt mysql uroot proot e SHOW CREATE FUNCTION griots adjust_cost G KKEKEKKKKKKKKKKKKKKKKKKKKKKEEK ile row KKEKKKKKKKKKKKKKKKKKKKKKKKEEK HUniGE lon Macus tacos sql_mode Create Function CREATE DEFINER root localhost RETURNS double DETERMINISTIC remem COSE Il 10 character_set_client latinl collation_connection latinl_swedish_ci Database Collation latinl_swedish_ci Discussion FUNCTION adjust_cost cost double In this example we see the use of
201. databases on a server without GTIDs enabled and there are GTID statements present in the file Use the skip gtid option to ignore the GTID statements To make the most use of GTIDs and export import you should export all of the databases on the server with the a11 option This will generate an export file with all of the databases and the GTIDs executed to that point Importing this file on another server will ensure that server has all of the data as well as all of the GTIDs recorded correctly in its logs OPTIONS mysqldbimport accepts the following command line options e help 110 OPTIONS Display a help message and exit license Display license information and exit autocommit Enable autocommit for data import By default autocommit is off and data changes are only committed once at the end of each imported file bulk insert b Use bulk insert statements for data character set lt charset gt Sets the client character set The default is retrieved from the server variable character_set_client default storage engine lt def_engine gt The engine to use for tables if the destination server does not support the original storage engine on the source server drop first d Drop each database to be imported if exists before importing anything into it dryrun Import the files and generate the statements but do not execute them This is useful for testing input file validity format lt f
202. db CountryLanguage done shell gt mysql uroot proot e SHOW DATABASES 4 Database 4 information_schema employees mysql world_innodb world_innodb_clone Discussion Notice we specified the source of the database we wanted to copy as well as the destination In this case they are the same server You must specify it this way so that it is clear we are operating on the same server 16 How Can Make a Copy of a Database and Change the Storage Engine Notice how we specified the new name We used the lt old_name gt lt new_name gt syntax You can do this for as many databases as you want to copy That s right you can copy multiple databases with a single command renaming each along the way To copy a database without renaming it if the destination is a different server you can omit the lt new_name gt portion Permissions Required The user must have SELECT privileges for the database s on the source server and have CREATE INSERT UPDATE on the destination server Tips and Tricks Risks You can copy all of the databases on a source server to the destination by using the a11 option although this option does not permit rename actions To rename you must specify the databases one at a time You can specify certain objects to exclude skip in the copy Use the skip option to omit the type of objects For example you may want to e
203. different servers The comparison may be executed against two databases of different names on a single server by specifying only the server1 option The user can also connect to another server by specifying the server2 option In this case db1 is taken from server1 and db2 from server2 When a database pair is specified all objects in one database are compared to the corresponding objects in the other Objects not appearing in either database produce an error To compare a specific pair of objects add an object name to each database name using the db obj format For example use the db1 obj1 db2 0b 42 format to compare two named objects or db1 obj1 to compare an object with the same name in databases with the same name It is not legal to mix a database name with an object name For example db1 obj1 db2 and db1 db2 0b 42 are illegal formats The comparison may be run against a single server for comparing two databases of different names on the same server by specifying only the server1 option Alternatively you can also connect to another server by specifying the server2 option In this case the first object to compare is taken from server1 and the second from server2 By default the utility generates object differences as a difference report However you can generate a transformation report containing SQL statements for transforming the objects for conformity instead Use the sql value for the difftype option to produce a li
204. e options in Option dictionary width width of printout default 75 iter max iterations default 2 ok_to_fail if True do not throw exception default True Returns bool True success Fail failed This example is typical of the methods and classes in the library Notice that this method has three required parameters and a dictionary of options that may exist Each method and function that uses this mechanism defines its own default values for the items in the dictionary A quick look at the method documentation shows the key names for the dictionary This can be seen in the preceding example where the dictionary contains three keys and the documentation lists their defaults To call this method and pass different values for one or more of the options the code may look like this opt_dictionary width g L00 iter 8 il tok to tail False result do_something_wonderful 1 obj_1l obj_2 opt_dictionary The documentation block for the preceding method is the style used throughout the library Example Now that you are familiar with the MySQL utilities and the supporting library modules let us take a look at an example that combines some of these modules to solve a problem Suppose that you want to develop a new database solution and need to use real world data and user accounts for testing The mysqlserverclone MySQL utility looks like a possibility but it makes only an instance of a running server
205. e copy modify and distribute this software and its documentation for any purpose and without fee is hereby granted provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation and that the name of Timothy O Malley not be used in advertising or publicity pertaining to distribution of the software without specific written prior permission 248 Python License Timothy O Malley DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS IN NO EVENT SHALL Timothy O Malley BE LIABLE FOR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE DATA OR PROFITS WHETHER IN AN ACTION OF CONTRACT NEGLIGENCE OR OTHER TORTIOUS ACTION ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE Profiling The profile and pstats modules contain the following notice Copyright 1994 by InfoSeek Corporation all rights reserved Written by James Roskind Permission to use copy modify and distribute this Python software and its associated documentation for any purpose subject to the restriction in the following sentence without fee is hereby granted provided that the above copyright notice appears in all copies and that both that copyright notice and this permission notice appear in supporting documentation and that
206. e encrypted not visible Example lt ogin path gt lt port gt lt socket gt Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt skip flush binlogs 77 NOTES Skip the binary log flush operation to refresh server s internal information after moving the binary log files e ssl ca The path to a file that contains a list of trusted SSL CAs e ssl cert The name of the SSL certificate file to use for establishing a secure connection e ssl key The name of the SSL key file to use for establishing a secure connection e Ssl Specifies if the server connection requires use of SSL If an encrypted connection cannot be established the connection attempt fails Default setting is 0 SSL not required e verbose v Specify how much information to display Use this option multiple times to increase the amount of information For example v verbose vv more verbose vvv debug e version Display version information and exit NOTES By default binary logs are flushed after moving the files when the server 77 option is used In particular FLUSH BINARY LOGS is executed after moving all binary log files and FLUSH RELAY LOGS after moving all relay log files This
207. e password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket e Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt ssl ca The path to a file that contains a list of trusted SSL CAs 184 NOTES e ssl cert The name of the SSL certificate file to use for establishing a secure connection e ssl cert The name of the SSL key file to use for establishing a secure connection e ssl Specifies if the server connection requires use of SSL If an encrypted connection cannot be established the connection attempt fails Default setting is 0 SSL not required e verbose V Specify how much information to display Use this option multiple times to increase the amount of information For example v verbose vv more verbose vvv debug e version Display version information and exit NOTES The data consistenc
208. e License at http www apache org licenses LICENSE 2 0 232 Doctrine DBAL 2 3 4 Unless required by applicable law or agreed to in writing software distributed under the License is distributed on an AS IS BASIS WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied See the License for the specific language governing permissions and limitations under the License 8 2 3 Doctrine DBAL 2 3 4 The following software may be included in this product Copyright c 2006 2012 Doctrine Project Permission is hereby granted free of charge to any person obtaining a copy of this software and associated documentation files the Software to deal in the Software without restriction including without limitation the rights to use copy modify merge publish distribute sublicense and or sell copies of the Software and to permit persons to whom the Software is furnished to do so subject to the following conditions The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software J THE SOFTWARE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND EXPRESS R IMPLIED INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY ITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT IN NO EVENT SHALL HE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM DAMAGES OR OTHER LIABILITY WHETHER IN AN ACTION OF CONTRACT TORT OR OTHERWISE ARISING ROM OUT OF O
209. e database name If you do not want to use the last folder as the database name simply specify the colon like this home me data1 t1 frm In this case the database will be omitted from the CREATE statement OPTIONS e help show the program s help page license Display license information and exit basedir lt basedir gt The base directory for the server installed Use this or server for the default mode diagnostic Turn on diagnostic mode to read frm files byte by byte and generate best effort CREATE statement new storage engine lt engine gt Set the ENGINE option for all frm files read port lt port gt The port to use for the spawned server in the default mode Must be a free port Required for default mode Server lt server gt Connection information for a server Use this option or basedir for the default mode If provided with the diagnostic mode the storage engine and character set information will be validated against this server To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure 134 NOTES e Use login paths from your myl
210. e following command using the slave with the database to be copied as the source and the slave where the database needs to copied to as the destination shell gt mysqldbcopy source root localhost 3311 destination root localhost 3312 test123 rpl slave rpl user rpl Source on localhost connected Destination on localhost connected Source on localhost connected Stopping slave Copying database test123 Copying TABLE test123 t1l Copying data for TABLE test123 t1l Connecting to the current server s master Starting slave done PERMISSIONS REQUIRED The user must have SELECT SHOW VIEW EVENT and TRIGGER privileges for the database s on the source server On the destination server the user must have the following privileges for the copied database s CREATE ALTER SELECT INSERT UPDATE LOCK TABLES DROP if drop first option is used and SUPER depending on the objects DEFINER value 5 8 mysqldbexport Export Object Definitions or Data from a Database This utility exports metadata object definitions or data or both from one or more databases By default the export includes only definitions mysqldbexport differs from mysqldump in that it can produce output in a variety of formats to make your data extraction transport much easier It permits you to export your data in the format most suitable to an external tool another MySQL server or other use without the need to reformat the data
211. e given SSL certificates with the MySQL Command Line Tool by executing the command show variables like ssl shell gt mysql uroot ppass port 3307 e show variables like ss1 4 Variable_name Value have_openssl YES have_ssl YES ssl_ca C newcerts cacert pem ssl_capath ssl_cert C newcerts server cert pem ssl_cipher cel emil Sell_Sxe ljoeiie a ssl_key C newcerts server key pem 4 4 However at this moment the root account is not using an encrypted ssl connection as you can see with the MySQL Command Line Tool running the status command shell gt mysql uroot ppass port 3307 e status mysql Ver 14 14 Distrib 5 6 15 for Win64 x86_64 Connection id ial Current database Current user root localhost SSL Not in use You need to add the SSL options necessarily to establish an encrypted connection with SSL this can be done in the following form shell gt mysql uroot ppass port 3307 ssl ca C newcerts cacert pem ssl cert C newcerts server cert pem ssl key C newcerts server key pem e status mysql Ver 14 14 Distrib 5 6 15 for Win64 x86_64 50 How Can I Use a secure encrypted connection between Utilities and a MySQL Server Connection id L5 Current database Current user root localhost SSihg Cipher in use is
212. e information displayed includes the following e Server connection information e Server version number Data directory path name e Base directory path name e Plugin directory path name Configuration file location and name e Current binary log coordinates file name and position e Current relay log coordinates file name and position This utility can be used to see the diagnostic information for servers that are running or offline If you want to see information about an offline server the utility starts the server in read only mode In this case you must specify the basedir datadir and start options to prevent the utility from starting an offline server accidentally Note Be sure to consider the ramifications of starting an offline server on the error and similar logs It is best to save this information prior to running this utility To specify how to display output use one of the following values with the format option grid default Display output in grid or table format like that of the mysql client command line tool e CSV Display output in comma separated values format tab Display output in tab separated format e vertical Display output in single column format like that of the G command for the mysq1 client command line tool To turn off the headers for grid csv or tab display format specify the no headers option To see the common default settings for the local server s configuration file
213. e option the permitted values are not case sensitive In addition values may be specified as any unambiguous prefix of a valid value For example difftype d specifies the differ type An error occurs if a prefix matches more than one valid value The path to the MySQL client tools should be included in the PATH environment variable in order to use the authentication mechanism with login paths This will allow the utility to use the my_print_defaults tools which is required to read the login path values from the login configuration file mylogin cnf If any database object identifier specified as an argument contains special characters or is a reserved word then it must be appropriately quoted with backticks In turn names quoted with backticks must also be quoted with single or double quotes depending on the operating system i e in Windows or in non Windows systems in order for the utilities to read backtick quoted identifiers as a single argument For example to show the difference between table weird table1 from database weird db name and table weird table2 from database other weird db name the objects pair must be specified using the following syntax in non Windows weird db name weird table1 other weird db name weird table2 EXAMPLES To compare the employees and emp databases on the local server use this command shell gt mysqldiff serverl root localhost employees emp1 server
214. e rights that we gave you You must make sure that they too receive or can get the source code If you link other code with the library you must provide complete object files to the recipients so that they can relink them with the library after making changes to the library and recompiling it And you must show them these terms so they know their rights We protect your rights with a two step method 1 we copyright the library and 2 we offer you this license which gives you legal permission to copy distribute and or modify the library To protect each distributor we want to make it very clear that there is no warranty for the free library Also if the library is modified by someone else and passed on the recipients should know that what they have is not the original version so that the original author s reputation will not be affected by problems that might be introduced by others Finally software patents pose a constant threat to the existence of any free program We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder Therefore we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license Most GNU software including some libraries is covered by the ordinary GNU General Public License This license the GNU Lesser General Public License applies t
215. e the possible redundant and duplicate indexes use this command shell gt mysqlindexcheck server root localhost employees Source on localhost connected The following indexes are duplicates or redundant for table employees dept_emp Q REATE INDEX emp_no ON employees dept_emp emp_no USING BTREE may be redundant or duplicate of ALTER TABLE employees dept_emp ADD PRIMARY KEY emp_no dept_no The following indexes are duplicates or redundant for table employees dept_manager Q REATE INDEX emp_no ON employees dept_manager emp_no USING BTREE may be redundant or duplicate of ALTER TABLE employees dept_manager ADD PRIMARY KEY emp_no dept_no The following indexes are duplicates or redundant for table employees salaries CREATE INDEX emp_no ON employees salaries emp_no USING BTREE may be redundant or duplicate of ALTER TABLE employees salaries ADD PRIMARY KEY emp_no from_date The following indexes are duplicates or redundant for table employees titles CREATE INDEX emp_no ON employees titles emp_no USING BTREE may be redundant or duplicate of ALTER TABLE employees titles ADD PRIMARY KEY emp_no title from_date PERMISSIONS REQUIRED Regarding the privileges needed to run this utility the user needs SELECT privilege on the mysql database as well as for the databases which tables are being checked 5 16 mysqlmetagrep Search Database Object Definitions This
216. e tl frm file CREATE statement for mysql test std_data frm_files tl frm CREATE TABLE templ t1 Pa int 11 DEFAULT NULL ENGINE MyISAM DEFAULT CHARSET latinl Reading the t2 frm file CREATE statement for mysql test std_data frm_files t2 frm 136 PERMISSIONS REQUIRED CREATE TABLE dbl R e a int 11 DEFAULT NULL ENGINE MyISAM DEFAULT CHARSET latinl Reading the t3 frm file CREATE statement for mysql test std_data frm_files t3 frm CREATE TABLE t3 a int 11 DEFAULT NULL ENGINE MyISAM DEFAULT CHARSET latinl i eConce The following demonstrates running the utility in diagnostic mode to read all of the frm files in a directory shell gt mysqlfrm diagnostic mysql data sakila WARNING Cannot generate character set or collation names without the server option CAUTION The diagnostic mode is a best effort parse of the frm file As such it may not identify al Reading frm file for mysql data sakila city frm The frm file is a TABLE CREATE TABLE Statement CREATE TABLE city city_id smallint 5 unsigned NOT NULL AUTO_INCREMENT city varchar 150 NOT NULL country_id gt smallint 5 unsigned NOT NULL last_update timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP PRIMARY KEY PRIMARY catylid Kine deba ek coinme wel comey e ENGINE InnoDB done PERMISSIONS REQUIRED The permission
217. e will complete the option For the cases where an option requires a value the console will complete the option name and append the character Tab completion for options works for both the full name and the alias if available If the user presses TAB twice the console will display a list of matching options Pressing TAB twice immediately after typing the name of a MySQL Utility will display a list of all options for that utility Tab completion for variables works the same as that for options In this case the user must first type the character then press TAB For example if a variable SERVER1 exists when the user types server SER lt TABs the console will complete the SERVER variable name For cases where there are multiple variables pressing TAB twice will display a list of all matches to the first N characters Pressing TAB twice after typing only the character will display a list of all variables Note R The mysq prefix is optional in the console For example typing disku lt TAB gt in the console will complete the command as diskusage Executing utilities is accomplished by typing the complete command and pressing ENTER The user does not have to type python or provide the py file extension The console will add these if needed The user can also run commands using the option execute The value for this option is a semi colon separated list of commands to execute These can be base commands or M
218. each of its terms and conditions 6 This License Agreement shall be governed by and interpreted in all respects by the law of the State of California excluding conflict of law provisions Nothing in this License Agreement shall be deemed to create any relationship of agency partnership or joint venture between BeOpen and Licensee This License Agreement does not grant permission to use BeOpen trademarks or trade names in a trademark sense to endorse or promote products or services of Licensee or any third party As an exception the BeOpen Python logos available at http www pythonlabs com logos html may be used according to the permissions granted on that web page 7 By copying installing or otherwise using the software Licensee agrees to be bound by the terms and conditions of this License Agreement CNRI LICENSE AGREEMENT FOR PYTHON 1 6 1 1 This LICENSE AGREEMENT is between the Corporation for National Research Initiatives having an office at 1895 Preston White Drive Reston VA 20191 CNRI and the Individual or Organization Licensee accessing and otherwise using Python 1 6 1 software in source or binary form and its associated documentation 2 Subject to the terms and conditions of this License Agreement CNRI hereby grants Licensee a nonexclusive royalty free world wide license to reproduce analyze test perform and or display publicly prepare derivative works distribute and otherwise use Python 1 6 1 alone o
219. ecified or the value is 0 all entries from the start of the log are displayed Accepted formats yyyy mm ddThh mm ss or yyyy mm dd status lt STATUS gt Commaz separated list of status values or intervals to search for all audit log records with a matching status Status values are non negative integers corresponding to MySQL error codes Status intervals are closed i e include both endpoints and defined simply using a dash between its endpoints For Example 1051 1068 1075 1109 1146 The status option is available as of MySQL Utilities 1 2 4 1 3 3 users lt USERSs gt u lt USERS gt Commaz separated list of user names to search for their associated log entries For example dan jon john paul philip stefan verbose v Specify how much information to display Use this option multiple times to increase the amount of information For example v verbose vv more verbose vvv debug version Display version information and exit This utility is available as of MySQL Utilities 1 2 0 72 EXAMPLES This utility can only be applied to servers with the audit log plugin enabled And the audit log plugin is available as of MySQL Server versions 5 5 28 and 5 6 10 This utility support both of the existing audit log file formats old and new The new audit log format is supported as of MySQL Utilities 1 4 3 See The Audit Log File for more information about available file formats This utility
220. ectedly The act of taking the master offline intentionally and switching control to another slave is called switchover In this case there is no loss of transactions as the master is locked and all slaves are allowed to catch up to the master Once the slaves have read all events from the master the master is shutdown and control switched to a slave in this case called a candidate slave Recovering from the loss of a downed master is more traumatic and since there is no way to know what transactions the master may have failed to send the new master called a candidate slave must be the slave that is most up to date How this is determined depends on the version of the server see below However it can result in the loss of some transactions that were executed on the downed master but not sent The utility accepts a list of slaves to be considered the candidate slave If no slave is found to meet the requirements the operation will search the list of known slaves The utility also provides a number of useful commands for managing a replication topology including the following elect This command is available to only those servers supporting global transaction identifiers GTIDs perform best slave election and report best slave to use in the event a switchover or failover is required Best slave election is simply the first slave to meet the prerequisites GTIDs are supported in version 5 6 5 and higher This command requires the options
221. ection parameters with the server 77 option or the source location of the binary log files using the option binlog dir 76 When the server 77 option is used the utility will determine the binary logs basename and index file location from the server depending on its version and all binary log files will be moved except the ones currently in use with the higher sequence number In order to move all binary logs the the binlog dir 76 option must be used requiring the MySQL server to be stopped By default the utility only moves binary log files To move relay log files or both the user must use the log type 77 option with the desired value When the server server 77 is used by default binary logs are flushed at the end of the move operation in order to reload the binary logs data cache on the server Users can skip this step using the skip flush binlogs 77 option The utility always attempts to determine the necessary information base filename binary logs and index location based on the available server s data or the default values Nevertheless custom values might be used and some variables might not be available for older server versions or simply the server connection might not provided If custom file names are used the user can specify them using the options bin log index 77 bin log basename 76 relay log index 77 and relay log basename 77 respectively for binary log and relay lo
222. ed herein then Licensee hereby agrees to include in any such work a brief summary of the changes made to Python 4 PSF is making Python available to Licensee on an AS IS basis PSF MAKES NO REPRESENTATIONS OR WARRANTIES EXPRESS OR IMPLIED BY WAY OF EXAMPLE BUT NOT LIMITATION PSF MAKES NO AND DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT INFRINGE ANY THIRD PARTY RIGHTS 5 PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON FOR ANY INCIDENTAL SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF MODIFYING DISTRIBUTING OR OTHERWISE USING PYTHON OR ANY DERIVATIVE THEREOF EVEN IF ADVISED OF THE POSSIBILITY THEREOF 6 This License Agreement will automatically terminate upon a material breach of its terms and conditions 7 Nothing in this License Agreement shall be deemed to create any relationship of agency partnership or joint venture between PSF and Licensee This License Agreement does not grant permission to use PSF trademarks or trade name in a trademark sense to endorse or promote products or services of Licensee or any third party 8 By copying installing or otherwise using Python Licensee agrees to be bound by the terms and conditions of this License Agreement 243 Python License BEOPEN COM LICENSE AGREEMENT FOR PYTHON 2 0 BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1 1 This LICENS
223. ee OFF audit_log_format OLD audit_log_include_accounts audit_log_policy ALL audit_log_rotate_on_size 0 audit_log_statement_policy ALL audit_log_strategy ASYNCHRONOUS 4 4 Executing POLICY command Showing options after command Audit Log Variables and Options 4 4 Variable_name Value 4 4 audit_log_buffer_size 1048576 audit_log_connection_policy NONE audit_log_current_session ON audit_log_exclude_accounts audit_log_file audit log auureliiie_Ihexep_ Eiee OFF audit_log_format OLD audit_log_include_accounts audit_log_policy ALL audit_log_rotate_on_size 0 audit_log_statement_policy ALL audit_log_strategy ASYNCHRONOUS 4 4 To change the audit log automatic file rotation size audit_log_rotate_on_size to 32535 and show the system variables before and after the execution of the rotate_on_size command use the following command Notice that the value set is actually 28672 because the specified rotate_on_size value is truncated to a multiple of 4096 shell gt mysqlauditadmin show options server root localhost 3310 rotate_on_size value 32535 67 PERMISSIONS REQUIRED Showing options before command Audit Log Variables and Options 4 4
224. el 9f80 bda8146bdb0a_ localhost 3334 SLAVE 6dd6 abf 4 71 d 1le1l 9f80 d406a0117519 ess s tos SSS SS SS SS SSS Q quit R refresh H health G GTID Lists U UUIDs L log entries If once the master is detected as down and failover mode is auto or elect and there are viable candidate slaves the failover feature will engage automatically and the user will see the failover messages appear When failover is complete the interface returns to monitoring replication health after 5 seconds The following shows an example of failover occurring Failover starting Candidate slave localhost 3332 will become the new master Preparing candidate for failover Creating replication user if it does not exist Stopping slaves Performing STOP on all slaves Switching slaves to new master Starting slaves Performing START on all slaves Checking slaves for errors Failover complete Discovering slaves for master at localhost 3332 Failover console will restart in 5 seconds After the failover event the new topology is shown in the replication health report MySQL Replication Monitor and Failover Utility Failover Mode auto Next Interval Mon Mar 19 16 05 12 2012 Master Information Binary Log File Position Binlog_Do_DB Binlog_Ignore_DB mysql bin 000001 1117 GTID Executed Set 132 PERMISSIONS REQUIRED 2A67DE00 2DA1 11E2 A711 00764F2BE90F 1 7 UUIDs 4 4 4 4
225. emp_13002 tmpdir source temp_130 pid file source temp_13002 clone pid port 13002 server id 102 basedir source mysql 5 6 socket source temp_13002 mysql sock log slave upd gtid mode on enforce gtid consistency log bin master info repository TABLE report port 13002 report host localhost 3 5 3 How Can I Use a secure encrypted connection between Utilities and a MySQL Server Security is a big concern and MySQL Utilities is prepared to use a secure connection to MySQL server Using Secure Connections using an encrypted connection with SSL Objectives Use the mysqlserverclone utility to create a new instance of your installed MySQL Server This new instance will be enabled for secure connections using SSL to establish a secure connection by using the SSL options You can also use an Options file to specify the SSL certificates needed for the secure connection Example Execution To meet this objective you need to supply values for the following options of mysqlserverclone e basedir e new port e new data e mysqld e root password If you are unfamiliar with the previous options you can find more info in the Section 5 24 mysqlserverclone Clone Existing Server to Create New Server section In the mysqld option you need to specify the ssl ca ssl cert and ssl key options with his respective SSL certificate for the new instance of the server By doing this t
226. ense Supplement Windows Only ccceeeeeeeeeee cece aa eeeeeeeeeeeeeeaaeaeeeees 251 This chapter includes additional information about MySQL Utilities including a list of frequently asked questions and third party license information 8 1 MySQL Utilities Frequently Asked Questions FAQ Categories e General Questions 225 e Storage Engine Questions 225 The mysgqlfrm Utility frm File Reader Questions 225 General 8 1 1 Are these utilities present in the community version Of MySQL 0 cceeeeeeeeeeeeeeeeeeeeeeaee 225 8 1 1 Are these utilities present in the community version of MySQL Yes see Chapter 1 How to Install MySQL Utilities Storage Engines 8 1 1 Can the utilities be used with MyISAM or CSV oo eee ce eeeeee cece ee aaa eeeeeeeeeeeeaaaaeeeeeeeeeeeeaas 225 8 1 1 Can the utilities be used with MyISAM or CSV Yes There are no storage engine specific limitations in using the utilities There are some features written specifically for InnoDB so those may not apply but in general no utility is storage engine specific For example the mysqldiskusage utility shows exact sizes for MyISAM and InnoDB files but uses estimated sizes for any other storage engine based on number of rows and row size The mysqlfrm Utility frm File Reader 8 1 1 Can the frm reader read a frm file without the associated data files c ceseeeeeeeee eee 225 8 1 2 Will the frm reader modify my original frm file
227. eplication commands detected in the input stream whenever GTIDs are enabled Permissions Required The user used to read data from the master must have the SELECT privilege on all databases exported The user on the slave must have the SUPER privilege to start replication Tips and Tricks The warning issued during the import concerning GTIDs is to ensure you are aware that the process for gathering the proper GTIDs to execute on the slave include transactions from all databases Thus 15 How Do Make a Copy of a Database on the Same Server if you ran a partial export that includes the replication commands and you have GTIDs enabled you should use the skip rp1 option to skip the replication commands and restart replication manually Should your data be large enough to make the use of mysqidbexport impractical you can use mysqldbexport to generate the correct replication commands anyway by using the export definitions option This will generate the SQL statements for the objects but not the data You can then use the replication commands generated with your own backup and restore tools You can use the option rp1 slave to generate a output stream that considers the source server a slave and uses the source servers master settings for generating the CHANGE MASTER command 3 2 2 How Do Make a Copy of a Database on the Same Server If you are working with a database and want to experiment with changes to objects or data eith
228. er S1 in both checks it can be said that there is no consistency issues in the all topology M S1 S2 S3 at the time the first check was completed This kind of execution must be performed sequentially and not concurrently otherwise the synchronization process of each instance will likely affect the other and it will not work properly 3 4 7 How To Fix Errant Transactions on the Replication Topology At some point in time when performing some maintenance administration operation or other task which verify your replication topology you may discover the existence of errant transactions Some utilities like mysqli failover and mysqlrpladmin will detect errant transactions and will issue a warning or error before executing some of their respective operations This is done because this kind of transaction can lead to an unstable replication topology after a failover or switchover What are errant transactions Errant transactions are transactions directly applied by a client on a slave and that do not exist on all the slaves connected to the master By nature these transactions should not be replicated and can lead to replication errors if the slave that possesses them is promoted to master In practice this can happen for example if the errant transaction corresponds to a data insert or delete on a table that only exists on that slave This kind of transactions usually result from a mistake 44 How To Fix Errant Transactions on the Replicatio
229. er from direct manipulation SQL commands or as a result of interaction with an application it is prudent to always have a copy to fall back to if something should go wrong Naturally a full backup is key for any production server but what if you just want to do something as a test or as a prototype Sure you can restore from your backup when the test is complete but who has the time for that Why not just make a copy of the database in question and use it Objectives The goal is to make a copy of a database and rename it to another name We want to do this on a single database server without resorting to messy file copies and or stopping the server In this case we want to copy the world_innodb database in its entirety and rename the copy to word_innodb_ clone The utility of choice here is named mysqldbcopy and it is capable of copying databases from server to another or on the same server Lets have a look at the execution Example Execution shell gt mysqldbcopy source root root localhost destination root root localhost world_innodb world_innodb_ clone Source on localhost connected Destination on localhost connected Copying database world_innodb renamed as world_innodb_clone Copying TABLE world_innodb City Copying TABLE world_innodb Country Copying TABLE world_innodb CountryLanguage Copying data for TABLE world_innodb City Copying data for TABLE world_innodb Country Copying data for TABLE world_inno
230. er2 Data differences found among rows UPDATE db2 tl SET b Test 7389 WHERE a 1 UPDATE db2 tl SET b Test 123 WHERE a 3 DELETE FROM db2 t1 WHERE a 5 NSERT INTO db2 t1 a b VALUES 4 New row db1 Database consistency check failed done 94 PERMISSIONS REQUIRED With the difftype sq1 SQL generation option set show reverse shows the object transformations in both directions Here is an excerpt of the results shell gt mysqldbcompare serverl root root localhost server2 root root localhost db1 db2 changes for serverl1 show reverse a difftype sql Defn Row Data Type Object Name DURE Count Check TABLE ie dl pass pass Compare table checksum FAIL Find row differences FAIL Transformation for changes for serverl Data differences found among rows DATE dbl tl SET b Test 123 WHERE a DATE dbl tl SET b Test 789 WHERE a LETE FROM dbl ti WHERE a 4 SERT INTO dpI tl a B VATU Sao INew row dbaj R usii DE zz ea tno tag Transformation for reverse changes changes for server2 Data differences found among rows UPDATE db2 tl1 SET b Test 789 WHERE a 1 UPDATE dbz tl SET 6b Test 1237 WHERE a a DELETE FROM db2 t1 WHERE a 5 NSERT INTO db2 tl1 a D VALUES 4 New row dbl Database consistency check failed done PERMISSIONS REQUIRED The u
231. eral tasks such as reporting information about a server and searching for objects or processes on a server 3 3 1 How Can Find Out How Much Space My Data Uses When preparing to create a backup or maintenance on a server related to storage it is often the case we need to know how much space is used by our data and the logs the server maintains Fortunately there is a utility for that Objectives Show the disk space used by the databases and all logs using the mysqlidiskusage utility Example Execution shell gt sudo env PYTHONPATH SPYTHONPATH mysqldiskusage server root root localhost all Souncowoum localhost ie im cOnneocrEcc Database totals 4 4 db_name total 4 4 oltp2 829 669 bvm IS 129 dbl 9 O95 db2 1 025 employees ZAG UN G2 griots 14 AILS mysql OOS TAA oltpl Hy Oy re ie room_temp 9 847 sakila O test Aa AII test_arduino 9 999 welford_kindle 12 032 world 472 185 world_innodb 829 669 4 4 Total database disk usage 210 175 251 bytes or 200 44 MB Log information 4 4 log_name size 4 4 host123 log 7 BIA AGS host123 slow log ey Se host123 local cerf S21 VIA BOS 4 4 Tocel sive oie logs 1 279 178 Wis loywces or i io Gs Binary log inf
232. ermissions under this License 8 Limitation of Liability In no event and under no legal theory whether in tort including negligence contract or otherwise unless required by applicable law such as deliberate and grossly negligent acts or agreed to in writing shall any Contributor be liable to You for damages including any direct indirect special incidental or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work including but not limited to damages for loss of goodwill work stoppage computer failure or malfunction or any and all other commercial damages or losses even if such Contributor has been advised of the possibility of such damages 9 Accepting Warranty or Additional Liability While redistributing the Work or Derivative Works thereof You may choose to offer and charge a fee for acceptance of support warranty indemnity or other liability obligations and or rights consistent with this License However in accepting such obligations You may act only on Your own behalf and on Your sole responsibility not on behalf of any other Contributor and only if You agree to indemnify defend and hold each Contributor harmless for any liability incurred by or claims asserted against such Contributor by reason of your accepting any such warranty or additional liability END OF TERMS AND CONDITIONS APPENDIX How to apply the Apache License to your work To
233. erval lt seconds gt Interval in seconds for switching masters Default 60 seconds Minimum is 30 seconds pidfile lt pidfile gt Pidfile for running mysqlrplms as a daemon This file contains the PID process identifier that uniquely identify a process It is needed to identify and control the process forked by mysaqlrplms e verbose V Specify how much information to display Use this option multiple times to increase the amount of information For example v verbose vv more verbose vvv debug e version Display version information and exit NOTES The login user for the master servers must have the appropriate permissions to grant access to all databases and have the ability to create user accounts For example the user accounts used to connect to each of the masters must have the WITH GRANT OPTION privilege 161 EXAMPLES The server IDs on the masters and slave must be nonzero and unique The utility reports an error if the server ID is 0 on either server or the same on the masters and slave Set these values before starting this utility Mixing IP and hostnames is not recommended The replication specific utilities will attempt to compare hostnames and IP addresses as aliases for checking slave connectivity to the master However if your installation does not support reverse name lookup the comparison could fail Without the ability to do a reverse name lookup the replication utilities could report
234. erver will be shutdown and all temporary files removed after the frm files are read A diagnostic mode is available by using the diagnostic option This switches the utility to read the frm files byte by byte to recover as much information as possible The diagnostic mode has additional limitations in that it cannot decipher character set or collation values without using an existing server installation specified with either the server or basedir option This can also affect the size of the columns if the table uses multibyte characters Use this mode when the default mode cannot read the file or if a MySQL server is not installed on the host To read frm files list each file as a separate argument for the utility as shown in the following examples You will need to specify the path for each frm file you want to read or supply a path to a directory and all of the frm files in that directory will be read You can specify the database name to be used in the resulting CREATE statement by prepending the frm file with the name of the database followed by a colon For example oltp t1 frm will use oltp for the database name in the CREATE statement The optional database name can also be used with paths For example home me oltp t1 frm will use oltp as the database name If you leave off the optional database name and include a path the last folder will be the database name For example home me data1 t1 frm will use data1 as th
235. es between two servers can also be compared using the a11 option In this case only the databases in common with the same name between the servers are successively compared Therefore no databases need to be specified but the server1 and server2 options are required Users can skip the comparison of some of the databases using the exclude option Note E The data must not be changed during the comparison Unexpected errors may occur if data is changed during the comparison The objects considered in the database include tables views triggers procedures functions and events A count for each object type can be shown with the vv option The check is performed using a series of steps called tests By default the utility stops on the first failed test but you can specify the run all tests option to cause the utility to run all tests regardless of their end state example if the row counts differ among two tables being compared the data consistency will also fail Note E Using run all tests may produce expected cascade failures For The tests include the following 1 Check database definitions A database existence precondition check ensures that both databases exist If they do not no further processing is possible and the run al1l tests option is ignored 2 Check existence of objects in both databases The test for objects in both databases identifies those objects missing from one or another database The remai
236. es provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt e Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt e ssl ca The path to a file that contains a list of trusted SSL CAs e ssl cert The name of the SSL certificate file to use for establishing a secure connection e ssl cert The name of the SSL key file to use for establishing a secure connection e ssl Specifies if the server connection requires use of SSL If an encrypted connection cannot be established the connection attempt fails Default setting is 0 SSL not required timeout lt seconds gt Maximum timeout in seconds to wait for each replication command to complete For example timeout for slave waiting to catch up to master Default 300 seconds e verbose V Specify how much information to display Use this option multiple times to increase the amount of information For example v verbo
237. ession ON audit_log_exclude_accounts audit_log_file audit log audit_log_flush OFF audit_log_format OLD audit_log_include_accounts audit_log_policy ALL audit_log_rotate_on_size 0 audit_log_statement_policy ALL audit_log_strategy ASYNCHRONOUS 4 4 To perform a manual rotation of the audit log file use the following command shell gt mysqlauditadmin server root localhost 3310 rotate Executing ROTATE command To display the audit log file statistics run the following command shell gt mysqlauditadmin file stats audit log name SERVER data audit log 66 EXAMPLES l aneit dlez audit log 13486539046497235 Ea ee RE Wed Sep 26 11 07 43 2012 Wed Sep 26 11 05 04 2012 Wed Sep 26 11 07 43 2012 Wed Sep 26 11 05 04 2012 To change the audit log policy to log only query events and show the system variables before and after the execution of the policy command use the following command shell gt mysqlauditadmin show options server root localhost 3310 policy value QUERIES Showing options before command Audit Log Variables and Options 4 4 Variable_name Value 4 audit_log_buffer_size 1048576 audit_log_connection_policy ALL audit_log_current_session ON audit_log_exclude_accounts audit_log_file audit log ayereliiie_Ihexep_ ae i
238. ey Use the verbose option to see additional information in the health report and additional messages during failover The utility supports two modes of operation The default mode running as a console works as described above An additional mode that permits you to run the utility as a daemon is provided for POSIX platforms When run as a daemon the utility does not have interactivity However all events are written to the log file You can control what is written to the log by using the report values option To run the utility as a daemon use the daemon option There are four commands that can be used in daemon option These include e start Starts the daemon The 1og option is required e stop Stops the daemon If you used the option pidfile the value must be the same when starting the daemon e restart 125 OPTIONS Restarts the daemon If you used the option pidfile the value must be the same when starting the daemon nodetach Starts the daemon but it will not detach the process from the console The 10g option is required OPTIONS mysqlfailover accepts the following command line options help Display a help message and exit license Display license information and exit candidates lt candidate slave connections gt Connection information for candidate slave servers Valid only with failover command List multiple slaves in comma separated list To connec
239. ferences cce 87 5 7 mysqldbcopy Copy Database Objects Between Servers cccccsseeeeeeeneeeeeeaaeeeees 95 5 8 mysqldbexport Export Object Definitions or Data from a Database ccee 101 5 9 mysqldbimport Import Object Definitions or Data into a Database eee 109 5 10 mysqldiff Identify Differences Among Database Objects 0 ceceeeeeeeeeeeeees 114 5 11 mysqldiskusage Show Database Disk Usage ccccccceeeeceeeeeeeeeeaeeeeeeeaaeeeeeeas 120 5 12 mysql failover Automatic replication health monitoring and failover 0 123 5 13 mysqlfrm File reader for frm files cee cccccseeeececeeeeececeeeeeeeeeeeseeeeeegeseeeeeneeeeanaess 133 5 14 mysqigrants Display grants by ObDjeCt eee e cece nee cece nate eres RIE ES 137 5 15 mysqlindexcheck Identify Potentially Redundant Table Indexes n 143 5 16 mysqimetagrep Search Database Object Definitions c cece cecseeeeeeeeeeeeeeeeeees 146 5 17 mysqlprocgrep Search Server Process Lists ccssscecesseeeeeeeaeeeeeeaaeeeeesaneeees 151 5 18 mysqlreplicate Set Up and Start Replication Between Two Servers 00068 155 5 19 mysql rplms Set Up and Start Replication Among a Slave and Multiple Masters 159 5 20 mysqlrpladmin Administration utility for MySQL replication ceeeeeeeeeees 164 5 21 mysqlrplcheck Check Rep
240. file to use for establishing a secure connection ssl cert 112 NOTES The name of the SSL key file to use for establishing a secure connection e ssl Specifies if the server connection requires use of SSL If an encrypted connection cannot be established the connection attempt fails Default setting is 0 SSL not required table lt db gt lt table gt Specify the table for importing This option is required while using format raw_csv e verbose vV Specify how much information to display Use this option multiple times to increase the amount of information For example v verbose vv more verbose vvv debug e version Display version information and exit NOTES The login user must have the appropriate permissions to create new objects access read the mysql database and grant privileges If a database to be imported already exists the user must have read permission for it which is needed to check the existence of objects in the database Actual privileges needed may differ from installation to installation depending on the security privileges present and whether the database contains certain objects such as views or events and whether binary logging is enabled Some combinations of the options may result in errors during the operation For example excluding tables but not views may result in an error when a view is imported The new storage engine and default storage engine options a
241. flush operation is required to refresh the binary log data on the server otherwise errors might occur or inconsistent information might be displayed regarding the moved files without restarting the server For example when executing the following statements SHOW BINLOG EVENTS and SHOW BINARY LOGS Nevertheless the flush operation also closes and reopens the binary log files See FLUSH Syntax for more information about the FLUSH statement Recall that the skip flush binlogs 77 option can be used to skip the flush operation The path to the MySQL client tools should be included in the PATH environment variable in order to use the authentication mechanism with login paths This will allow the utility to use the my_print_defaults tools which is required to read the login path values from the login configuration file mylogin cnf LIMITATIONS This utility does not support remote access to binary log files and must be executed on the local server EXAMPLES Move available binary log files from a running server shell gt mysqlbinlogmove server user pass localhost 3310 archive binlog_dir Moving bin log files server bin 000001 server bin 000002 server bin 000003 server bin 000004 server bin 000005 78 EXAMPLES Flushing binary logs done Move all binary log files from a stopped server specifying the source binary log directory shell gt mysqlbinlogmove binlog dir
242. g demonstrates launching the console using the commands shown above but piped into the console on the command line The results are the same as above shell gt echo set SERVER root host123 mysqldiskusage server S SERVER mysqluc The following demonstrates launching the console and setting variables via the command line shell gt mysqluc SERVER root host123 VAR_A 57 e show variables Variable Value SERVER root host123 201 PERMISSIONS REQUIRED VAR_A oe PERMISSIONS REQUIRED There are no special permissions required to run mysqluc however you must have the necessary privileges to execute the desired utilities See the PERMISSIONS REQUIRED section for each command you wish to execute 5 28 mysqluserclone Clone Existing User to Create New User This utility uses an existing MySQL user account on one server as a template and clones it to create one or more new user accounts with the same privileges as the original user The new users can be created on the original server or a different server To list users for a server specify the 1ist option This prints a list of the users on the source no destination is needed To control how to display list output use one of the following values with the format option e grid default Display output in grid or table format like that of the mysql client command line tool e CSV Display output in comma separated values format tab Display output in tab separ
243. g files By default all of the binary log files found are moved except the ones currently in use if the server 77 option is used The sequence 77 option can be used to restrict the files to move based on their sequence number It is also possible to filter the files to move based on their modification date using the modified before 77 option The utility displays the list of binary files that are moved Users can also use the verbose 78 option to see additional information when the utility executes e g used values for server variables Note R This utility was added in MySQL Utilities 1 6 0 OPTIONS mysqlbinlogmove accepts the following command line options e binlog dir lt binlog_dir gt Source directory full path for the binary log files to move e bin log basename lt binlog_basename gt Basename for the binary log files If not available it is assumed to be any name ended with bin 76 OPTIONS bin log index lt binlog_index gt Location full path of the binary log index file If not specified it is assumed to be located in the binary log directory help Display a help message and exit license Display license information and exit log type lt log_type gt Type of the binary log files to move i e binary log or relay log files Supported values bin for binary log files relay for relay log files all for both binary log and relay log files Default bin
244. g the xec before option Further let us assume the master MySQL Server is using port 3306 on the host host1 and the MySQL Server that will become the new master is using port 3308 on host can_host2 The script would therefore be invoked in the following manner s run_before sh host 3306 can_host2 3308 Table 5 2 External Script Parameters MySQL Failover Option Parameters Passed to External Script xec befor master host master port candidate host candidate port exec after new master host new master port xec fail check master host master port exec post failover old master host old master port new master host new master port no errors during failover 130 EXAMPLES MySQL Failover Option Parameters Passed to External Script exec post failover old master host old master port errors during failover EXAMPLES To launch the utility you must specify at a minimum the master option and either the discover slaves login option or the slaves option The discover slaves login option can be used in conjunction with the slaves option to specify a list of known slaves or slaves that do not report their host and IP and to discover any other slaves connected to the master An example of the user interface and some of the report views are shown in the following examples a STATUS view If there are multiple GTIDs listed the utility s
245. ge engine option Example Execution 17 How Can Make a Copy of a Database and Change the Storage Engine shell gt mysqldbcopy source root root localhost 3306 destination root root localhost 3307 new storage engine myisam world_innodb world_myisam SOURCE Gin LOCEUIURESES con Gemmecieael Destination on localhost commected Copying database world_innodb renamed as world_myisam Replacing ENGINE InnoDB with ENGINE myisam for table world_myisam City Copying TABLE world_innodb City WARNING FOREIGN KEY constraints for table world_myisam City are missing because the new storage engine for the table is not InnoDB Replacing ENGINE InnoDB with ENGINE myisam for table world_myisam Country Copying TABLE world_innodb Country Replacing ENGINE InnoDB with ENGINE myisam for table world_myisam CountryLanguage Copying TABLE world_innodb CountryLanguage WARNING FOREIGN KEY constraints for table world_myisam CountryLanguage are missing because the new storage engine for the table is not InnoDB Copying data for TABLE world_innodb City Copying data for TABLE world_innodb Country Copying data for TABLE world_innodb CountryLanguage doner shell gt mysql uroot proot h 127 0 0 1 port 3307 e SHOW DATABASES 4 Database 4 information_schema mysql sakila world world_myisam 4 shell gt mysql uroot proot h
246. ge to check for finding running servers This option applies only to Windows and is ignored unless show servers is given The default range is 3306 3333 Server lt server gt Connection information for a server Use this option multiple times to see information for multiple servers To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure Use login paths from your my login cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt show defaults d Display default settings for mysqid from the local configuration file It uses my_print_defaults to obtain the options show servers Display information about servers running on the local host The utility examines the host process list to determine which servers are running ssl ca 193 EXAMPLES The
247. gements for third party software incorporated in the Python distribution Mersenne Twister The _random module includes code based on a download from http www math keio ac jp matumoto MT2002 emt19937ar html The following are the verbatim comments from the original code A C program for MT19937 with initialization improved 2002 1 26 Coded by Takuji Nishimura and Makoto Matsumoto Before using initialize the state by using init_genrand seed or init_by_array init_key key_length Copyright C 1997 2002 Makoto Matsumoto and Takuji Nishimura All rights reserved Redistribution and use in source and binary forms with or without modification are permitted provided that the following conditions are mets 1 Redistributions of source code must retain the above copyright notice this list of conditions and the following disclaimer 2 Redistributions in binary form must reproduce the above copyright notice this list of conditions and the following disclaimer in the documentation and or other materials provided with the PASCE Lou LOn 3 The names of its contributors may not be used to endorse or promote products derived from this software without specific prior written permission THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED IN N
248. ges to read the data directory but in this case you will see an estimate of the disk usage rather than actual bytes used You may also not be able to see a list of the logs 3 3 2 My Server Crashed Need to Know the Structure of a Table How Can Do That When things go wrong badly enough that your server is down but you can still access the disks you may find yourself faced with a number of complex recovery tasks One of those is the need to discover the structure of a particular table or set tables Perhaps this is needed for an emergency recovery a redeployment or setup for a forensic investigation Whatever the case without a running MySQL server it is not possible to know the structure of a table unless you keep meticulous notes and or use some form of high availability redundancy Fortunately there is a utility for situations like this The mysqlfrm utility can be used to discover the structure of a table Objectives With a downed or offline server discover the structure of a table More specifically generate the CREATE TABLE SQL command Example Execution shell gt sudo env PYTHONPATH SPYTHONPATH mysqlfrm basedir usr local mysql 22 My Server Crashed Need to Know the Structure of a Table How Can Do That port 3333 user lt user gt usr local mysql data welford_kindle books frm Spawning server with user lt user gt Starting the spawned server on port 3333 done Reading frm files
249. gt no health Turn off health report after switchover or failover ping lt number gt Number of ping attempts for detecting downed server Note on some platforms this is the same as number of seconds to wait for ping to return This value is also used to check down status of master Failover will wait ping seconds to check master response If no response failover event occurs quiet q Turn off all messages for quiet execution rpl user lt replication_user gt The user and password for the replication user requirement in the format lt users lt password gt or lt login path gt E g rpl passwd Default None script threshold lt return_code gt Value for external scripts to trigger aborting the operation if result is greater than or equal to the threshold Default None no threshold checking seconds behind lt seconds gt Used to detect slave delay The maximum number of seconds behind the master permitted before slave is considered behind the master Default 0 168 NOTES e slaves lt slave connections gt Connection information for slave servers List multiple slaves in comma separated list The list will be evaluated literally whereby each server is considered a slave to the master listed regardless if they are a slave of the master To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utiliti
250. hall display to indicate there are additional GTIDs to view You can view the complete list of Note R The GTID Executed Set will display the first GTID listed in the SHOW MASTER GTIDs on the GTID display screens The default interface will display the replication health report like the following In this example the log file is enabled A sample startup command is shown below shell gt mysqlfailover master root localhost 3331 discover slaves login root log log txt MySQL Replication Monitor and Failover Utility Failover Mode auto Next Interval Mon Mar 19 15 56 03 2012 Master Information Binary Log File Position Binilog_Do_DB Binlog_lgnore DB Wise olin OMONOOU S77 ib GTID Executed Set 2A67DE00 2DA1 11R2 A711 00764F2BE90F 1 7 Replication Health Status 4 4 4 l host port role state gtid_mode health 4 4 4 4 4 localhost mSS MASTER UP ON OK Plo colho situ oso SLAVE UP ON OK Pelicocallhosita posses SLAVE UP ON OK eliocallhosit osoe SLAVE UP ON FOK 4 4 4 4 4 Q quit R refresh H health G GTID Lists U UUIDs L log entries Press Q to exit the utility R to refresh the current display and H returns to the replication health report Press G key to show a GTID
251. he ACCEPT button where indicated or by copying installing or otherwise using Python 1 6 1 Licensee agrees to be bound by the terms and conditions of this License Agreement ACCERT CWI LICENSE AGREEMENT FOR PYTHON 0 9 0 THROUGH 1 2 Copyright c 1991 1995 Stichting Mathematisch Centrum Amsterdam The Netherlands All rights reserved Permission to use copy modify and distribute this software and its documentation for any purpose and without fee is hereby granted provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation and that the name of Stichting Mathematisch Centrum or CWI not be used in advertising or publicity pertaining to distribution of the software without specific written prior permission STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE FOR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE DATA OR PROFITS WHETHER IN AN ACTION OF CONTRACT NEGLIGENCE OR OTHER TORTIOUS ACTION ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE 245 Python License Licenses and Acknowledgements for Incorporated Software This section is an incomplete but growing list of licenses and acknowled
252. he GNU General Public Licenses are intended to guarantee your freedom to share and change free software to make sure the software is free for all its users This license the Lesser General Public License applies to some specially designated software packages typically libraries of the Free Software Foundation and other authors who decide to use it You can use it too but we suggest you first think carefully about whether 233 GNU Lesser General Public License Version 2 1 February 1999 this license or the ordinary General Public License is the better strategy to use in any particular case based on the explanations below When we speak of free software we are referring to freedom of use not price Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software and charge for this service if you wish that you receive source code or can get it if you want it that you can change the software and use pieces of it in new free programs and that you are informed that you can do these things To protect your rights we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it For example if you distribute copies of the library whether gratis or for a fee you must give the recipients all th
253. he MySQL Utilities MySQL Utilities is both a set of command line utilities as well as a Python library for making the common tasks easy to accomplish The library is written entirely in Python meaning that it is not necessary to have any other tools or libraries installed to make it work It is currently designed to work with Python v2 6 or later and there is no support yet for Python v3 1 Layout This manual is arranged in an order designed to provide a quick reference for how to use MySQL Utilities It begins with a brief introduction of MySQL Utilities then presents a list of common administration tasks with examples of how utilities can be used to perform the tasks From there the manual begins a deeper dive into the utilities starting with overviews of each utility leading to a detailed description of each via a manual page format Thus the manual provides a documentation solution for several needs How to Use This Manual You can use this manual to get a quick solution to an administrative task complete with explanation of how to run the utilities involved and the options and parameters needed See the tasks chapter for this information You can use the manual to learn what utilities exist and how each fits into your own administrative needs See the utility overview chapter for this information You can also use the manual to get more information about each utility and what each option and parameter does via the manuals section
254. he name of the user to connect passwd The password to use when connecting The default if no password is supplied is the empty password host The domain name of the host or the IP address This field accepts host names and IPv4 and IPv6 addresses It also accepts quoted values which are not validated and passed directly to the calling methods This enables users to specify host names and IP addresses that are outside of the supported validation mechanisms port The port to use when connecting to the server The default if no port is supplied is 3306 which is the default port for the MySQL server as well unix_socket The socket to connect to instead of using the host and port parameters The following demonstrates executing a utility using command line options for connecting to a server shell gt mysqlserverinfo py server root other pass localhost 3308 format vertical Source on localhost connected KKK KKEKKKEKKEKKEKKKKKKKKK KK KK elles row KKEKEKKEKKKEKKEKKKKEKKKKKKKKKKK server localhost 13001 config_file etc my cnf etc mysql my cnf binary_log clone bin 000001 binary_log_pos 341 relay_log relay_log_pos Versa Oncol Og datadir Volumes Source source temp_13001 basedir Volumes Source source bzr mysql 5 6 plugin_dir Volumes Source source bzr mysql 5 6 lib plugin Specifying Connections in Python Library general_llog OFF general_log_file general_log_file_size log_error
255. he new server instance will use the given certificates to establish a secure connection If you are uncertain of how to create the SSL certificates please following the steps indicated on Creating SSL and RSA Certificates and Keys The ssl ca ssl cert and ssl key options of mysqlserverclone are used to connect to an 49 How Can I Use a secure encrypted connection between Utilities and a MySQL Server existing instance of MySQL in case you need to use ssl to connect to it and these options are not used to indicate the certificates to use by the new server instance For that reason it is necessary to use the mysqld option of mysqlserverclone The following is an example of the running command shell gt mysqlserverclone basedir C MySQL mysql1 5 6 15 winx64 new data C MySQL instance_3307 new port 3307 root password pass mysqld ssl ca C newcerts cacert pem ssl cert C newcerts server cert pem ssl key C newcerts server key pem Cloning the MySQL server located at C MySQL mysql 5 6 15 winx64 Creating new data directory Configuring new instance IOYSENE Tinley TMWASIe EL TEIN 5 6 5 Setting up empty database and mysql tables Starting new instance of the server Testing connection to new instance Success Setting the root password Connection Information STMOGE Ass T done Now we have a new MySQL server instance and you can confirm the use of th
256. he options may result in errors when the export is imported later For example eliminating tables but not views may result in an error when a view is imported on another server For the format export and display options the permitted values are not case sensitive In addition values may be specified as any unambiguous prefix of a valid value For example format g specifies the grid format An error occurs if a prefix matches more than one valid value The path to the MySQL client tools should be included in the PATH environment variable in order to use the authentication mechanism with login paths This will allow the utility to use the my_print_defaults tools which is required to read the login path values from the login configuration file mylogin cnf If any database identifier specified as an argument contains special characters or is a reserved word then it must be appropriately quoted with backticks In turn names quoted with backticks must also be quoted with single or double quotes depending on the operating system i e in Windows or in non Windows systems in order for the utilities to read backtick quoted identifiers as a single argument For example to export a database with the name weird db name it must be specified as argument using the following syntax in non Windows weird db name Keep in mind that you can only take advantage of multiprocessing if your system has multiple CPUs available fo
257. he requirement to distribute the source code even though third parties are not compelled to copy the source along with the object code 236 GNU Lesser General Public License Version 2 1 February 1999 5 A program that contains no derivative of any portion of the Library but is designed to work with the Library by being compiled or linked with it is called a work that uses the Library Such a work in isolation is not a derivative work of the Library and therefore falls outside the scope of this License However linking a work that uses the Library with the Library creates an executable that is a derivative of the Library because it contains portions of the Library rather than a work that uses the library The executable is therefore covered by this License Section 6 states terms for distribution of such executables When a work that uses the Library uses material from a header file that is part of the Library the object code for the work may be a derivative work of the Library even though the source code is not Whether this is true is especially significant if the work can be linked without the Library or if the work is itself a library The threshold for this to be true is not precisely defined by law If such an object file uses only numerical parameters data structure layouts and accessors and small macros and small inline functions ten lines or less in length then the use of the object file is unrestricted
258. heck for localhost 3311 filtered by replication rule Checking tO table data n Setting data synchronization point for slaves Compute checksum on slaves wait to catch up and resume replication OK test_epleynic cbi 0 checksum for server localhost 23i12 188 PERMISSIONS REQUIRED Checking tl table data Setting data synchronization point for slaves Compute checksum on slaves wait to catch up and resume replication OK test_rplsync_doel tl checksum for server localhost 3311 OK test rpleync_dol tl checksum for server localhost s3i2 SKIP Table t2 check for localhost 3311 filtered by replication rule SKIP Table t2 check for localhost 3312 filtered by replication rule SKIP Table t3 check for localhost 3311 filtered by replication rule SKIP Table t3 check for localhost 3312 filtered by replication rule SKIP Database test_rplsync_db0O check filtered by replication rule SKIP Database test_rplsync_db2 check filtered by replication rule SKIP Database test_rplsync_db3 check filtered by replication rule eC OnWer SUMMARY No data consistency issue found PERMISSIONS REQUIRED The user for the master must have permissions to lock tables perform the checksum and get information about the master status Specifically the user used to connect to the master requires the following privileges SUPER or
259. hs This will allow the utility to use the my_print_defaults tools which is required to read the login path values from the login configuration file mylogin cnf EXAMPLES To display the server information for the local server and the settings for mysqid in the configuration file with the output in a vertical list use this command shell gt mysqlserverinfo server root pass localhost d format vertical Source on localhost connected KKEKKKKKKKKKEKKKEKKKKKKK KK KK Ts row KKEKKKKKKKKKKKKKKKKKKK KK KK server localhost 3306 Wes eiMs sq il Shere datadir usr local mysql data basedir usr local mysql 5 1 50 osx10 6 x86_64 plugin_dir usr local mysql 5 1 50 osx10 6 x86_64 lib plugin config_file etc my cnf binary_log my_llog 0U000GE binanyelogepos 212383 relay_log None 194 PERMISSIONS REQUIRED relay_log_pos None 1 rows Defaults for server localhost 3306 port 3306 basedir usr local mysql datadir usr local mysql data server_id 5 log bin my_log general_log slow_query_log innodb_data_file_path ibdatal 778M ibdata2 50M autoextend Comes PERMISSIONS REQUIRED The permissions required include the ability to read the mysql database and to have read access to the data directory The user must have permissions to read the data directory or use an administrator or super user Sudo account to obtain access to the data directory 5 26 mysqlslavetrx Slave
260. ibution medium does not bring the other work under the scope of this License 3 You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library To do this you must alter all the notices that refer to this License so that they refer to the ordinary GNU General Public License version 2 instead of to this License If a newer version than version 2 of the ordinary GNU General Public License has appeared then you can specify that version instead if you wish Do not make any other change in these notices Once this change is made in a given copy it is irreversible for hat copy so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy ct This option is useful when you wish to copy part of the code of the Library into a program that is not a library 4 You may copy and distribute the Library or a portion or derivative of it under Section 2 in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine readable source code which must be distributed under the terms of Sections 1 and 2 above ona medium customarily used for software interchange If distribution of object code is made by offering access to copy from a designated place then offering equivalent access to copy the source code from the same place satisfies t
261. ich such Contribution s was submitted If You institute patent litigation against any entity including a cross claim or counterclaim in a lawsuit alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed 4 Redistribution You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium with or without modifications and in Source or Object form provided that You meet the following conditions a You must give any other recipients of the Work or Derivative Works a copy of this License and b You must cause any modified files to carry prominent notices stating that You changed the files and c You must retain in the Source form of any Derivative Works that You distribute all copyright patent trademark and attribution notices from the Source form of the Work excluding those notices that do not pertain to any part of the Derivative Works and d If the Work includes a NOTICE text file as part of its distribution then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file excluding those notices that do not pertain to any part of the Derivative Works in at least one of the following places within a NOTICE text file distri
262. ignored as of Utilities 1 6 2 89 OPTIONS help Display a help message and exit license Display license information and exit changes for lt direction gt Specify the server to show transformations to match the other server For example to see the transformation for transforming object definitions on server1 to match the corresponding definitions on server2 use changes for server1 Permitted values are server1 and server2 The default is servert character set lt charset gt Sets the client character set The default is retrieved from the server variable character_set_client difftype lt difftype gt d lt difftype gt Specify the difference display format Permitted format values are unified context differ and sql The default is unified disable binary logging If binary logging is enabled disable it during the operation to prevent comparison operations from being written to the binary log Note Disabling binary logging requires the SUPER privilege exclude lt exclude gt x lt exclude gt Exclude one or more databases from the operation using either a specific name such as dbi ora search pattern Use this option multiple times to specify multiple exclusions By default patterns use database patterns such as LIKE With the regexp option patterns use regular expressions for matching names format lt format gt f lt format gt Specify the display format for changed or missing
263. il_test vl kese done connected DEFAULT CHARSET latin1 EE RENERENCESE E O a LT CHARSET latinl Similarly to export the data of the database util_test producing bulk insert statements use this command shell gt mysqldbexport server root pass localhost export DATA bulk insert util_test Source on localhost USE util_test Exporting data from util_test Data for table util_test tl INSERT INTO util_test t1 VALUES 02 Test Basic database exampl 03 Test Basic database exampl 04 Test Basic database exampl 05 Test Basic database exampl 06 Test Basic database exampl O7 Test Basic database exampl Data for table util_test t2 NSERT INI NSERT INIT 2 iS 3 16 NSERT INI done TO util_test t2 VALUES 12 Test Basic database exampl 13 Test Basic database exampl Data for table util_test t3 TO util_test t3 VALUES test fkeys test fkeys Data for table util_test t4 TO util_test t4 VALUES connected 01 Test Basic database example e iy eip S y Sty S y enhy 11 Test Basic database example eii e p 1 14 test fkeys 3 2 8 If the database to be exported does not contain only InnoDB tables and you want to ensure data integrity of the exported data by locking the tables during the read step add a locking lock all option to the command shell gt mysqldbexport server root pass
264. ilege 5 23 mysqlrplsync Replication synchronization checker This utility permits you to check replication servers for synchronization It checks data consistency between a master and slaves or between two slaves The utility reports missing objects as well as missing data The utility can operate on an active replication topology applying a synchronization process to check the data Those servers where replication is not active can still be checked but the synchronization process will be skipped In that case it is up to the user to manually synchronize the servers 182 OPTIONS The user must provide connection parameters for the servers That is the utility requires the master and slaves using the master 184 and slaves 184 options To compare only slaves the user need only provide the slaves 184 option The utility also provides a feature to discover slaves connected to the master using the discover slaves login 183 and master 184 options To use the discover slaves feature all slaves must use the following startup options report host and report port to specify the correct hostname and port of the server If these are missing or report the incorrect information the slave may not be discovered and therefore not included in the synchronization check The discover slaves feature ignores slaves that cannot be reached By default all data is included in the comparison To check specific databases or ta
265. ilities command import dbcopy Ery dbcopy copy_db conn dest_values db_list options except exception UtilError e print ERROR e errmsg sys exit Lastly we copy the user accounts Once again we must provide a dictionary of options and call the command module directly In this case the userclone module provides a method that clones one user to one or more users So we must loop through the users and clone them one at a time from mysql utilities command import userclone options overwrite True quiet c TEUS Mepl lee ile True RO user in usor libe Cey res userclone clone_user conn dest_values user user options except exception UtilError e print ERROR e errmsg sys exit We are done As you can see constructing new solutions from the MySQL utility command and common modules is easy and is limited only by your imagination Enhancing the Example A complete solution for the example named copy_server py is located in the appendix It is complete in so far as this document explains but it can be enhanced in a number of ways The following briefly lists some of the things to consider adding to make this example utility more robust Table locking Currently databases are not locked when copied To achieve a consistent copy of the data on an active server you may want to add table locking or use transactions for example if you are using InnoDB for a more consistent copy Skip user
266. ilover operation Additional permissions are also required to register and unregister the running mysqffailover instance on the master and slaves Specifically the login user must have the following privileges SUPER GRANT OPTION REPLICATION SLAVE RELOAD DROP CREATE INSERT and SELECT The referred permissions are required for the login users used for all servers master slaves and candidates 5 13 mysql frm File reader for frm files The mysqlfrm utility is designed as a recovery tool that reads frm files and produces equivalent CREATE statements from the table definition data found in the file In most cases the generated CREATE statement is usable for recreating the table on another server or for extended diagnostics However some features are not saved in the frm files and therefore will be omitted The exclusions include but are not limited to e foreign key constraints e auto increment number sequences The mysqlfrm utility has two modes of operation The default mode is designed to spawn an instance of an installed server by referencing the base directory using the basedir option or by connecting to the server with the server option The process will not alter the original frm file s This mode also requires the port option to specify a port to use for the spawned server It must be different 133 OPTIONS than the port for the installed server and no other server must be using the port The spawned s
267. import server root localhost import definitions format csv data csv Source on localhost connected Importing definitions from data csv done Similarly to import the data from the ut i1_test database to the server on the local host importing the data using bulk insert statements use this command shell gt mysqldbimport server root localhost import data bulk insert format csv data csv Source on localhost connected Importing data from data csv done To import both data and definitions from the ut il_test database importing the data using bulk insert statements from a file that contains SQL statements use this command shell gt mysqldbimport server root localhost import both bulk insert format sql data sql Source on localhost connected Importing definitions and data from data sql done PERMISSIONS REQUIRED You also need permissions to create the new data directory and write data to it 5 10 mysqldiff Identify Differences Among Database Objects This utility reads the definitions of objects and compares them using a diff like method to determine whether they are the same The utility displays the differences for objects that are not the same Use the notation db1 db2 to name two databases to compare or alternatively just db1 to compare two databases with the same name The latter case is a convenience notation for comparing same named databases on
268. in csv or tab format does not contain column headers specify the no headers option To turn off all feedback information specify the quiet option By default the utility creates each table on the destination server using the same storage engine as the original table To override this and specify the storage engine to use for all tables created on the destination server use the new storage engine option If the destination server supports the new engine all tables use that engine To specify the storage engine to use for tables for which the destination server does not support the original storage engine on the source server use the default storage engine option The new storage engine option takes precedence over default storage engine if both are given If the new storage engine or default storage engine option is given and the destination server does not support the specified storage engine a warning is issued and the server s default storage engine setting is used instead You must provide connection parameters user host password and so forth for an account that has the appropriate privileges to access all objects in the operation For details see NOTES If you attempt to import databases on a server with GTIDs enabled GTID_MODE ON a warning will be generated if the import file did not include the GTID statements generated by mysqidbexport The utility will also generate a warning if you import
269. in grid format the default use this command shell gt mysqldiskusage server root localhost employees test Source on localhost connected Database totals 4 4 db_name total test 4 096 Total database disk usage 205 983 744 bytes or 196 00 MB done To see all disk usage for the server in CSV format use this command shell gt mysqldiskusage server root localhost format csv a vv Source on localhost connected Database totals db_name db_dir_size data_size misc_files total ces O00 0 elasin O O OA elaz n O O A Obl a O O A backupmitest SATO mnn 2S AT employees 242519463 205979648 242519463 448499111 mysql 867211 657669 191720 849389 122 PERMISSIONS REQUIRED ill SEE TOZA BEAS NES test 561627 4096 52066 56162 util test a 19625 2048 175771 19625 Hed eSsie Nop PSA Ol pal Saa A meii test or TIGAS 20e Snar MIGAS Total database disk usage 449 490 516 bytes or 428 00 MB Log information The general_log is turned off on the server The slow_query_log is turned off on the server binary log information Current binary log file mysql bin 000076 log_file size data mysql bin 000076 125 data mysql bin 000077 125 data mysql bin 000078 556 data mysql bin 000079 168398223 data mysql bin index 76 Total size of binary logs 168 399 105 bytes or 160 00 MB Server is not an active slave no relay log i
270. ination of options master and slaves master and discover slaves login e slaves Note R The health column will display no master specified when generating a health report for a collection of slaves and no master option specified The master health state is based on the following if GTID_MODE 0ON the server must have binary log enabled and there must exist a user with the REPLICATE SLAVE privilege 164 mysql rpladmin Administration utility for MySQL replication The slave health state is based on the following the O_ THREAD and SQL_THREADS must be running it must be connected to the master there are no errors the slave delay for non gtid enabled scenarios is not more than the threshold provided by the max position and the slave is reading the correct master log file and slave delay is not more than the seconds behind threshold option reset Execute the STOP SLAVE and RESET SLAVE commands on all slaves This command requires the slaves option The discover slaves login option is not allowed because it might not provide the expected result excluding slaves with the IO thread stopped Optionally the master option can also be used and in this case the utility will perform an additional check to verify if the specified slaves are associated replication is configured to the given master start Execute the START SLAVE command on all slaves This command requires the slaves option The
271. information about this scenario Users must specify the set of GTIDs for the transactions to skip with the gt id set 196 option and the server connection parameters for the list of target slaves using the slaves 196 option The utility displays the GTID set that is effectively skipped for each slave If any of the specified GTIDs correspond to an already committed transaction on a slave then those GTIDs will be ignored for that slave not skipped because no other transaction empty or not can be applied with the same GTID Users can execute the utility in dry run mode using the dryrun 196 option to confirm which transactions would be skipped with the provided input values without effectively skipping them The utility does not require replication to be stopped However in some situations it is recommended For example in order to skip a transaction from the master on a slave that slave should be stopped otherwise the target transaction might be replicated before the execution of the skip operation and therefore not skipped as expected Users can also use the verbose 197 option to see additional information when the utility executes This includes a list of slaves not supporting GTIDs and the GTIDs of the injected transactions OPTIONS mysqlslavetrx accepts the following command line options e dryrun Execute the utility in dry run mode show the transactions GTID that would have been skipped for each slave but withou
272. ing but not limited to communication on electronic mailing lists source code control systems and issue tracking systems that are managed by or on behalf of the Licensor for the purpose of discussing and improving the Work but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as Not a Contribution Contributor shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work 2 Grant of Copyright License Subject to the terms and conditions of this License each Contributor hereby grants to You a perpetual worldwide non exclusive no charge royalty free irrevocable copyright license to reproduce prepare Derivative Works of publicly display publicly perform sublicense and distribute the Work and such Derivative Works in Source or Object form 3 Grant of Patent License Subject to the terms and conditions of this License each Contributor hereby grants to You a perpetual worldwide non exclusive no charge royalty free irrevocable except as stated in this section patent license to make have made use offer to sell sell import and otherwise transfer the Work where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution s alone or by combination of their Contribution s with the Work to wh
273. ing on master Setting up replication co clone shell gt mysqlreplicate master m_account 192 168 1 1 13001 slave slave_acc2 192 168 1 3 3306 rpl user repl slavepass b master on 192 168 i1 1 2 connected slave on 192 168 13s connected Checking for binary logging on master Setting up replication co Clone shell gt mysqlrplcheck master m_account 192 168 1 1 13001 slave slave_acc1 192 168 1 2 13001 master on 192 168 1 1 connected slave on 192 168 1 2 connected Test Description status Checking for binary logging on master pass Are there binlog exceptions pass Replication user exists pass Checking server_id values pass Checking server_uuid values pass Is slave connected to master pass Check master information file pass Checking InnoDB compatibility pass Checking storage engines compatibility pass Checking lower_case_table_names settings pass Checking slave delay seconds behind master FAIL Slave is NNN seconds behind master 32 How Can Use Replication done shell gt mysqlrplcheck master m_account 192 168 1 1 13001 slave slave_acc2 192 168 1 3 3306 master on 192 168 1 1 connected slave on 192 168 1 3 connected Test Description Status Checking for binary logging on master pass Are there binlog exceptions pass Replication user exists pass Checking server_id values pass Checking server_uuid values pass Is slave connec
274. inlog exceptions Replication user exists Checking server_id values master id 10 slave id altel Is slave connected to master Check master information file Master information file Master_Log_File Read_Master_Log_Pos Mei sie ie CHOSE MEisie ic VSSR Master_Password MISLE FONE Connect Retry Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path M ster Sob Cert Master_SSL_Cipher Master_SSL_Key Master_SSL_Verify_Server_Cert Checking InnoDB compatibility clone bin 000001 482 hostl SASA XXXX S210 60 0 Checking storage engines compatibility Checking lower_case_table_names settings Master lower_case_ table names Slave llower_case_ table names 2 2 Checking slave delay seconds behind master Slave status Slave_I0_ State Master_Host ME sie ie USER IMBSie ie Ie ieie Connect Retriy Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_ Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table ibeysiie _ Iie 119K bese Wie ieree Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Waiting for master to send event hosti rpl SSO 60 clone bin 000001 482 clone relay bin 000006 251 clone bin 000001 Xes xes 482 SS None 1
275. ion This places the appropriate STOP and START slave statements 102 OPTIONS in the export whereby the STOP SLAVE statement is placed at the start of the export and the CHANGE MASTER followed by the START SLAVE statements are placed after the export stream slave Include the CHANGE MASTER statement to make the destination server a slave connected to the same master as the server specified in the server option It only works if the current server is a slave This places the appropriate STOP and START slave statements in the export whereby the STOP SLAVE statement is placed at the start of the export and the CHANGE MASTER followed by the START SLAVE statements are placed after the export stream both Include both the master and slave information for CHANGE MASTER statements for either spawning a new slave with the current server s master or using the current server as the master All statements generated are labeled and commented to enable the user to choose which to include when imported To include the replication user in the CHANGE MASTER statement use the rpl user option to specify the user and password If this option is omitted the utility attempts to identify the replication user In the event that there are multiple candidates or the user requires a password these statements are placed inside comments for the CHANGE MASTER statement You can also use the comment rp1 option to place the replication statements in
276. ion parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt e Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt master lt connection gt Connection information for the master server To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt e Use a configuration file unencrypted not visible Note available in relea
277. isplay width of the test report The default is 75 characters NOTES The login user must have the appropriate permissions to read all databases and tables listed For the difftype option the permitted values are not case sensitive In addition values may be specified as any unambiguous prefix of a valid value For example difftype d specifies the differ type An error occurs if a prefix matches more than one valid value The path to the MySQL client tools should be included in the PATH environment variable in order to use the authentication mechanism with login paths This will allow the utility to use the my_print_defaults tools which is required to read the login path values from the login configuration file mylogin cnf If any database identifier specified as an argument contains special characters or is a reserved word then it must be appropriately quoted with backticks In turn names quoted with backticks must also be quoted with single or double quotes depending on the operating system i e in Windows or in non Windows systems in order for the utilities to read backtick quoted identifiers as a single argument For example to compare a database with the name weird db name with other weird db name the database pair must be specified using the following syntax in non Windows weird db name other weird db name 92 EXAMPLES EXAMPLES Use the following command to compare the emp1 and emp
278. issue might not be an easy task since it might be caused by byzantine failures at distinct levels However the first big step toward a solution to this kind of problem is being able to detect data consistency issues and make sure that the data among the replication servers is synchronized Objectives The goal is to execute the mysqirplsync utility to detect data consistency issues on an active replication system making sure that master and slaves are synchronized Executing this task manually on an active system is difficult and sometimes tedious since changes may be continuously happening on all servers in an asynchronous way and the same data needs to be compared between servers Moreover it can introduce an undesirable and uncontrolled impact on the system performance 42 How To Check If Data Is Correctly Replicated Fortunately the mysqlrplsync utility allows us to perform this task in an easy and optimized way with a controlled impact on the running system limiting the execution time of all operations Let s assume that a replication topology with one master server1 3310 and two slaves server2 3311 server3 3312 was previously setup and it is running without errors Example Execution Start the mysqlrplsync utility specifying the servers you want to check shell gt mysqlrplsync master user pass localhost 3310 slaves rpl pass localhost 3311 rpl pass localhost 3312 GTID differences between Master and Slaves
279. kip this full test use the skip data check option You may want to use the skip xxx options to run only one of the tests This might be helpful when working to bring two databases into synchronization to avoid running all of the tests repeatedly during the process Each test completes with one of the following states pass The test succeeded FAIL The test failed Errors are displayed following the test state line SKIP The test was skipped due to a missing prerequisite or a skip option WARN The test encountered an unusual but not fatal error The test is not applicable to this object To specify how to display diff style output use one of the following values with the difftype option unified default Display unified format output context Display context format output differ Display differ style format output 88 OPTIONS sql Display SQL transformation statement output To specify how to display output for changed or missing rows use one of the following values with the format option e grid default Display output in grid or table format like that of the mysql client command line tool e cSV Display output in comma separated values format e tab Display output in tab separated format e vertical Display output in single column format like that of the G command for the mysq1 client command line tool The changes for option controls the direction of the difference by spe
280. l gulawes Performing START on all slaves Checking slaves for errors Switchover complete eC Oner If the replication health report is generated on the topology following the above command it will display the old master as a slave as shown below Replication Topology Health 4 4 4 4 4 4 host port role state gtid_mode health 4 4 4 4 4 4 localhost S332 MASTER UP ON ORK localhost 3331 SLAVE UP ON Ok lkoceulineste S3sis Simsvyaa UP ON Ox localhost 3334 SLAVE UP ON Oke 4 4 4 4 4 4 You can use the discover slaves feature if and only if all slaves report their host and port to the master A sample command to generate a replication health report with discovery is shown below Note that the option discover slaves login cannot be used in conjunction with the s laves option shell gt mysqlrpladmin master root localhost 3332 discover slaves login root health Discovering slaves for master at localhost 3332 Discovering slave at localhost 3331 Found slave localhost 3331 Discovering slave at localhost 3333 Found slave localhost 3323 Discovering slave at localhost 3334 Found slave localhost 3334 Checking privileges Replication Topology Health 4
281. l on localhost connected WARNING Objects in serverl employees but not in server2 emp1 EVENT el Compare failed One or more differences found shell gt mysqldiff serverl root localhost employees t1l emp1 t1 employees t3 emp1 t3 serverl on localhost connected Comparing employees clito empl tl PASS serverl on localhost connected Comparing employees t3 to empii ts PASS Success All objects are the same shell gt mysqldiff serverl root localhost employees salaries empl salaries differ serverl on localhost connected Comparing employees salaries to empl salaries FAIL Object definitions are not the same CREATE TABLE salaries emp_no gt int 11 NOT NULL geullary meL NO NULE from date date NOT NULL to_date date NOT NULL PRIMARY KEY emp_no from_date KEY emp_no emp_no ENGINE InnoDB DEFAULT CHARSET latin1 He AKAANA 9 ENGINE MyISAM DEFAULT CHARSET latinl B H AAA Compare failed One or more differences found The following examples show how to generate a transformation report Assume the following object definitions Host1 118 EXAMPLES CREATE TABLE dbl tablel num int mis char 30 Host2 CREATE TABLE dbx table3 num int notes char 30 misc char 55 To generate a set of SQL statements that transform the definition of db1 table1 to dbx table3 use this command shell gt mysqldiff server
282. l root host1 server2 root host2 changes for serverl difftype sql db1 tablel1 dbx table3 serverl on hostl connected server2 on host2 connected Comparing dbl tablel to dbx table3 FAIL Transformation statements Sh Se SE SE ALTER TABLE dbl tablel ADD COLUMN notes char 30 AFTER a CHANGE COLUMN misc misc char 55 Compare failed One or more differences found To generate a set of SQL statements that transform the definition of dbx table3 to dbl tablel use this command shell gt mysqldiff serverl root host1 server2 root host2 changes for server2 difftype sql db1 tablel1 dbx table3 serverl on hostl connected server2 on host2 connected Comparing dbl tablel to dbx table3 FAIL Transformation statements Sh Se Se OSE ALTER TABLE dbx table3 DROP COLUMN notes CHANGE COLUMN misc misc char 30 Compare failed One or more differences found To generate a set of SQL statements that transform the definitions of dbx table3 and db1 tablel in both directions use this command shell gt mysqldiff serverl root host1 server2 root host2 show reverse difftype sql db1 tablel dbx table3 serverl on hostl connected server2 on host2 connected Comparing dbl tablel to dbx table3 FAIL Transformation statements destination serverl1 ALTER TABLE dbl tablel ADD COLUMN notes char 30 AFTER a CHANGE COLUMN misc misc char 55 destination se
283. le The database name appears to the left of and the frm name to the right In this case we have database testi and table city so the CREATE statement reads CREATE TABLE testl city shell gt mysqlfrm basedir usr local bin mysql test1l city frm port 3333 Starting the spawned server on port 3333 done Reading frm files Reading the city frm file CREATE statement for city frm Sh Sh SE OSE OSH OEE CREATE TABLE testi city city_id smallint 5 unsigned NOT NULL AUTO_INCREMENT city varchar 50 SNOT NUE country_id gt smallint 5 unsigned NOT NULL last_update timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP PRIMAR TIREE City aw eke ik Gouic ieh eewer Le ENGINE InnoDB DEFAULT CHARSET utf8 done The following demonstrates reading multiple frm files in the default mode using a running server The frm files are located in different folders Notice the use of the database name option for each of the files The t1 file was given the database name temp1 since that is the folder in which it resides t2 was given db1 since that was specified in the path and t3 was not given a database name since we used the without providing a database name shell gt mysqlfrm server root pass localhost 3306 mysql data temp1 t1 frm mysql data temp2 db1 t2 frm port 3310 Starting the spawned server on port 3333 done Reading frm files Reading th
284. le to use for establishing a secure connection e ssl Specifies if the server connection requires use of SSL If an encrypted connection cannot be established the connection attempt fails Default setting is 0 SSL not required e verbose V Specify how much information to display Use this option multiple times to increase the amount of information For example v verbose vv more verbose vvv debug e version Display version information and exit NOTES The path to the MySQL client tools should be included in the PATH environment variable in order to use the authentication mechanism with login paths This will allow the utility to use the my_print_defaults tools which is required to read the login path values from the login configuration file mylogin cnf LIMITATIONS The utility requires all target slaves to support global transaction identifiers GTIDs and have gtid_mode ON EXAMPLES Skip multiple GTIDs on the specified slaves shell gt mysqlslavetrx gtid set af6b22ee 7b0b 11e4 aa8d 606720440b68 7 9 slaves user pass localhost 3311 user pass localhost 3312 WARNING Using a password on the command line interface can be insecure GTID set to be skipped for each server localhost 3311 af b22ee 7b0b 11e4 aa8d 606720440b68 7 9 localhost 3312 af b22ee 7b0b 11e4 aa8d 606720440b68 7 9 Injecting enpe Eransactions for localhost 32 1 injecting en
285. les to carry prominent notices stating that You changed the files and c You must retain in the Source form of any Derivative Works that You distribute all copyright patent trademark and attribution notices from the Source form of the Work excluding those notices that do not pertain to any part of the Derivative Works and d If the Work includes a NOTICE text file as part of its distribution then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file excluding those notices that do not pertain to any part of the Derivative Works in at least one of the following places within a NOTICE text file distributed as part of 228 Apache Libcloud the Derivative Works within the Source form or documentation if provided along with the Derivative Works or within a display generated by the Derivative Works if and wherever such third party notices normally appear The contents of the NOTICE file are for informational purposes only and do not modify the License You may add Your own attribution notices within Derivative Works that You distribute alongside or as an addendum to the NOTICE text from the Work provided that such additional attribution notices cannot be construed as modifying the License You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use reproduction or dist
286. lhost 13001 contig_file etc my cnt etc mysql my cnt binary_log clone bin 000001 binary_log_pos 341 relay_log relay_log_pos Weesie ng 5 6 ly log datadir Volumes Source source temp_13001 basedir Volumes Source source bzr mysql 5 6 plugin_dir Volumes Source source bzr mysql 5 6 lib plugin general_log OFF general_log_file general_log_file_size log_error log_error_file_size slow_query_log OFF slow_query_log_file slow_query_log_file_size I rop die done See the online MySQL Reference Manual for more information about login paths the mylogin cnf file and the mysql_config_editor client 2 2 1 2 Use a Configuration File MySQL Utilities can also accept a configuration path and section for the server connection data This allows you to store one or more sections with connection information Saving the data in configuration files is more secure than specifying the data on the command line but since the file is text the data can still be read by anyone who can access the file To reference the configuration file specify the path and file name followed by a section name in square brackets The path is optional If you do not specify it the utility will attempt to use your local my cnf if available For example if you wanted to create a configuration file in dev env test1 my cnf and you created a section named server1 you would specify it as server dev env test1 my cnf server1 The correspo
287. lhost 3311 OB test_rolsyncld gt t0 checksum for server localnostl33i2 Checking El table data OK cest_rolsync cb tl checksum for server localnostl3311 OB test_rpolsync db tl checksum for server localhnostl3312 Checking test_db database Checking t0 table data OK kestab t0 checksum for server localhost 3311 OK test_db tO checksum for server localhost 3312 Checking Ell table data OK test_db tl checksum for server localhost 3311 OB testldb tl checksum for server localhost 3312 done SUMMARY No data consistency issue found To check the data consistency on an active replication system using slave discovery shell gt mysqlrplsync master user pass localhost 3310 discover slaves login rpl pass Discovering slaves for master at localhost 3310 Discovering slave at localhost 3311 Found slave localhost 3311 Discovering slave at localhost 3312 Found slave localhost 3312 GTID differences between Master and Slaves Slave localhost 3311 is 15 transactions behind Master Slave localhost 3312 is 15 transactions behind Master Checking data consistency Using Master localhost 3310 as base server for comparison Checking test_rplsync_db database Checking t0 table data OK test_rplsync cb t0 checksum for server localnost03211 OK test_rplsync_db t0 check
288. lication Prerequisites ccccceeeceeesseeeeeeaaeeeeeeaneees 174 5 22 mysqlrplshow Show Slaves for Master Server c ccccccsseeceeeaeeeeeeaaeeeeeeaaeeeees 178 5 23 mysqlrplsync Replication synchronization Checker cceceeeeeeeeeeeeeeeeeeeeeeeaes 182 5 24 mysqlserverclone Clone Existing Server to Create New Server ccccsseeees 189 5 25 mysqlserverinfo Display Common Diagnostic Information from a Server 191 5 26 mysqislavetrx Slave transaction skip Utility 0 cceeeeeseeeeeeeeeeeeeeeaaeaeeeeeeeeeeeeaes 195 5 27 mysqluc Command line client for running MySQL Utilities 2 0 0 0 ee eset 198 5 28 mysqluserclone Clone Existing User to Create New User cccceesseeeeeeaeeeees 202 6 Extending MySQL UNITES sssrinin ania naan ia aa da Aa AAEE AENEA Ea 205 6 1 Introduction to extending the MySQL Utilities 20 0 2 eee cece cece eneeeeeeeeeeee ee aaeateeeeeeeeeeeaaa 205 6 2 MySQL Utilities copy_server py sample 0 cccceceeeeeeeeeeeeeeeeeeeeaeaaeeeeeeeeeeeaeaaeaneeeeeees 211 6 3 Specialized Operations 22 0 ceceeeceeeeeeeeeeeae ee eeeeeeeeee E E E ENE 213 6 3 1 mysql utilities command grep Search Databases for Objects 213 6 3 2 mysql utilities command proc Search Processes on Servers 6 214 6 4 Parser snieman da raS eaa aa a a a a alaa aaae Saada 216 6 4 1 mysql utilities parser Parse MySQL Log Files
289. lied at a different level according to the operating system where the mysqldbcopy utility is executed due to python limitations In particular it is applied at the database level for Windows i e different databases are concurrently copied and at the table level for Non Windows POSIX systems i e different tables within the same database are concurrently copied EXAMPLES The following example demonstrates how to use the utility to copy a database named util_test toa new database named util_test_copy on the same server shell gt mysqldbcopy source root pass localhost 3310 test123 mysql sock destination root pass localhost 3310 test123 mysql sock util _test util_test_copy Source on localhost connected Destination on localhost connected Copying database util_test renamed as util_test_copy Copying TABLE util test tl Copying table data Copying TABLE util_test t2 Copying table data Copying TABLE util_test t3 Copying table data Copying TABLE util_test t4 Copying table data Copying VIEW util_test vl Copying TRIGGER util_test trg Copying PROCEDURE util_test pl Copying FUNCTION util_test fl Copying EVENT util_test el Copying GRANTS from util_test done If the database to be copied does not contain only InnoDB tables and you want to ensure data integrity of the copied data by locking the tables during the read step add a locking lock al1 option to the command
290. ll operates and performs whatever part of its purpose remains meaningful For example a function in a library to compute square roots has a purpose that is entirely well defined independent of the application Therefore Subsection 2d requires that any application supplied function or table used by this function must be optional if the application does not supply it the square root function must still compute square roots hese requirements apply to the modified work as a whole If dentifiable sections of that work are not derived from the Library nd can be reasonably considered independent and separate works in hemselves then this License and its terms do not apply to those ections when you distribute them as separate works But when you istribute the same sections as part of a whole which is a work based n the Library the distribution of the whole must be on the terms of his License whose permissions for other licensees extend to the ntire whole and thus to each and every part regardless of who wrote EON O O a e O res ct Thus it is not the intent of this section to claim rights or contest your rights to work written entirely by you rather the intent is to exercise the right to control the distribution of derivative or collective works based on the Library In addition mere aggregation of another work not based on the Library with the Library or with a work based on the Library on a volume of a storage or distr
291. localhost export DATA bulk insert util_test locking lock all Source on localhost USE whil_test Exporting data from util_test connected 107 EXAMPLES Data for table util_test tl INSERT INTO util_test t1l VALUES 01 Test Basic database example 02 Test Basic database example 03 Test Basic database example 04 Test Basic database example 05 Test Basic database example 06 Test Basic database example 07 Test Basic database example Data for table util _test t2 NSERT INTO util_test t2 VALUES 11 Test Basic database example 12 Test Basic database example 13 Test Basic database example Data for table util_test 43 NSERT INTO util_test t3 VALUES 1 SIS test fkeys yy 2 VALS test Ekeys Ir G Mete SE Ekes 1 Data for table util_test t4 NSERT INTO util_test t4 VALUES 2p 2 co celome D To export a database and include the replication commands to use the current server as the master for example to start a new slave using the current server as the master use the following command shell gt mysqldbexport server root localhost 3311 util_test export both rpl user rpl rpl rpl master v source Gm localhost coo conmected Stopping slave STOP SLAVE Source on localhost connected Exporting metadata from util_test DROP DATABASE IF EXISTS util_test CREATE DATABASE util_test USE util_test TABLES U
292. localhost 3306 slave root localhost 3307 rpl user rpl rpl master on localhost connected slave on localhost connected 157 EXAMPLES Checking for binary logging on master Setting up replication done The following command uses pedantic to ensure that replication between the master and slave is successful if and only if both servers have the same storage engines available the same default storage engine and the same InnoDB storage engine shell gt mysqlreplicate master root localhost 3306 slave root localhost 3307 rpl user rpl rpl vv pedantic masterkonmilocallihos tama EC OnmMoc toc in slave on localhost connected master id 2 slave id 99 Checking InnoDB statistics for type and version conflicts Checking storage engines Checking for binary logging on master Setting up replication Flushing tables on master with read lock Connecting slave to master CHANGE MASTER TO MASTER_HOST omitted Starting oslave m status Waiting for master to send event error 0 Unlocking tables on master CONT The following command starts replication from the current position of the master which is the default shell gt mysqlreplicate master root localhost 3306 slave root localhost 3307 rpl user rpl rpl Master on localhost connected SuliavicmonmlOCeENOS tame Connect edk Checking for binary logging on master Setting up replicatio
293. loped by the OpenSSL Project A for use in the OpenSSL Toolkit http www openssl org 4 The names OpenSSL Toolkit and OpenSSL Project must not be used to endorse or promote products derived from this software without i prior written permission For written permission please contact openssl core openssl org 5 Products derived from this software may not be called OpenSSL X nor may OpenSSL appear in their names without prior written X permission of the OpenSSL Project 6 Redistributions of any form whatsoever must retain the following zs acknowledgment iat This product includes software developed by the OpenSSL Project a for use in the OpenSSL Toolkit http www openssl org THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT AS IS AND ANY EXPRESSED OR IMPLIED WARRANTIES NCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED IN NO EVENT SHALL THE OpenSSL PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT INDIRECT INCIDENTAL SPECIAL EXEMPLARY OR CONSEQUENTIAL DAMAGES INCLUDING BUT NOT LIMITED TO PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES LOSS OF USE DATA OR PROFDIS OR BUSINESS LNTERRUP TION HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY WHETHER IN CONTRACT STRICT LIABILITY OR TORT INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE EVEN IF ADVISED
294. lserverclone basedir source mysql 5 6 new data source temp_3007 new port 3007 new id 101 root root mysqld log bin gtid mode on log slave updates enforce gtid consistency master info repository table report host localhost report port 3007 delete force Ignore the maximum path length and the low space checks for the new data option mysqld lt options gt Additional options for mysqld To specify multiple options separate them by spaces Use appropriate quoting as necessary For example to specify log bin binlog and general log file mylogfile use If the option skip innodb is included when connecting to a MySQL server version 5 7 5 or higher the option is ignored and a warning is issued mysqld log bin binlog general log file my log file new data lt path_to_new_datadir gt The full path to the location of the data directory for the new instance The path size must be 200 characters or less and it requires at least 120 MB of free space new id lt server_id gt The server_id value for the new server instance The default is 2 new port lt port gt The port number for the new server instance The default is 3307 quiet q Turn off all messages for quiet execution root password lt password gt The password for the root user of the new server instance Server lt source gt Connection information for the server to be cloned To connect to a
295. ly so we use the Lesser General Public License 234 GNU Lesser General Public License Version 2 1 February 1999 In other cases permission to use a particular library in non free programs enables a greater number of people to use a large body of free software For example permission to use the GNU C Library in non free programs enables many more people to use the whole GNU operating system as well as its variant the GNU Linux operating system Although the Lesser General Public License is Less protective of the users freedom it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library The precise terms and conditions for copying distribution and modification follow Pay close attention to the difference between a work based on the library and a work that uses the library The former contains code derived from the library whereas the latter must be combined with the library in order to run GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING DISTRIBUTION AND MODIFICATION 0 This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License also called this License Each licensee is addressed as you A library means a colle
296. ly if the file size exceeds the specified value in bytes OPTIONS mysqlbinlogrotate accepts the following command line options e version Shows the program s version number e help Displays the help message e bin log index lt binlog_index gt Shows the program s license e server lt server_connection gt Connection information for the server To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt e Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt 85 NOTES e Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt ssl Specifies if the server connection requires use of SSL If an encrypted connection cannot be established the connection attempt fails By default 0 SSL not required ssl ca The path to a file that contains a list of trusted SSL CAs
297. m db2 t1 1 Test 123 93 EXAMPLES 4 rows in set 0 00 sec To generate the SQL statements for data transformations to make db1 t1 the same as db2 t1 use the changes for server1 option We must also include the a option to ensure that the data consistency test is run The following command illustrates the options used and an excerpt from the results generated shell gt mysqldbcompare serverl root root localhost server2 root root localhost db1 db2 changes for serverl a difftype sql Defn Row Data Type Object Name Diese Count Check TABLE ig dL pass pass Compare table checksum FAIL Find row differences FAIL Transformation for changes for serverl Data differences found among rows UPDATE dabilt SET bi Test 123 WHERE a wiu UPDATE dbl tr SET b Test 789 WHERE a 3 DELETE FROM dbl tl WHERE a 4 NSERT INTO db1 tl a b VALUES 5 New row db2 Database consistency check failed done Similarly when the same command is run with changes for server2 and difftype sql the following report is generated shell gt mysqldbcompare serverl root root localhost server2 root root localhost db1 db2 changes for server2 a difftype sql Defn Row Data Type Object Name DIET Count Check TABLE ie dL pass pass Compare table checksum FAIL Find row differences FAIL Transformation for changes for serv
298. m the following replication statements to include in the export master Create and execute a CHANGE MASTER statement to make the destination server a slave of the server specified in the source option This executes the appropriate STOP and START slave statements The STOP SLAVE statement is executed at the start of the copy and the CHANGE MASTER followed by the START SLAVE statements are executed after the copy slave Create and execute a CHANGE MASTER statement to make the destination server a slave connected to the same master as the server specified in the source option This executes the appropriate STOP and START slave statements The STOP SLAVE statement is executed at the start of the copy and the CHANGE MASTER followed by the START SLAVE statements after the copy To include the replication user in the CHANGE MASTER statement use the rpl user option to specify the user and password If this option is omitted the utility attempts to identify the replication user In the event that there are multiple candidates or the user requires a password the utility aborts with an error If you attempt to copy databases on a server with GTIDs enabled GTID_ MODE ON a warning will be generated if the copy does not include all databases This is because the GTID statements generated include the GTIDs for all databases and not only those databases in the export The utility will also generate a warning if you copy databases on a GTI
299. mance of a service Lets imagine an online shopping service The shop started out small so a single server was enough to handle all the requests however now it has become quite popular and as a result that single server is no longer able to handle all the requests Being an online store most of the operations are read operations checking existing products reviews stock availability etc Objectives Our goal is to use replication in order to improve the throughput of the service by adding more servers which will become replicas of the already existing server These replicas will allow scaling out of the service by taking up all the read requests leaving the old server now called the master only in charge of the writes Rather than doing everything by hand with the mysql command line we are going to setup this replication scenario using a single script mysql replicate which will do most of the hard work for us We then check the result using the mysql rpladmin utility Lets assume the existing server Server1 is running on port 13001 on the local machine with IP 192 168 1 1 and that we want to add 2 new servers Server2 running on 192 168 1 2 13001 and Server3 running on 192 168 1 3 3306 Example Execution shell gt mysqlreplicate master m_account 192 168 1 1 13001 slave slave_acc1 192 168 1 2 13001 rpl user repl slavepass b master on 192 168 1 1 2 connected slave on 192 168 1 2 connected Checking for binary logg
300. mat gt f lt list_format gt Specify the user display format Permitted format values are grid csv tab and vertical The default is grid This option is valid only if list is given force Drop the new user account if it exists before creating the new account Without this option it is an error to try to create an account that already exists include global privileges Include privileges that match base_user as well as base_user host list List all users on the source server With this option a destination server need not be specified quiet q Turn off all messages for quiet execution source lt source gt Connection information for the source server To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt
301. mate For information read from the server the account used to connect to the server must have the appropriate permissions to read any objects accessed during the operation If information requested requires file system access but is not available that way the utility prints a message that the information is not accessible This occurs for example if you request log usage but the server is not local and the log files cannot be examined directly To specify how to display output use one of the following values with the format option grid default Display output in grid or table format like that of the mysql client command line tool e CSV Display output in comma separated values format tab Display output in tab separated format e vertical Display output in single column format like that of the G command for the mysq1 client command line tool To turn off the headers for grid csv or tab display format specify the no headers option OPTIONS mysqldiskusage accepts the following command line options e help Display a help message and exit e license Display license information and exit 120 OPTIONS all a Display all disk usage This includes usage for databases logs and InnoDB tablespaces binlog b Display binary log usage empty m Include empty databases format lt format gt f lt format gt Specify the output display format Permitted format values are grid csv tab
302. mmand The available actions include the following copy This command copies the audit log specified by audit log name to the destination path specified by copy to The remote login option can be used to copy log files from a remote location Note the destination path must be locally accessible by the current user 63 OPTIONS policy The policy command is used to change the audit logging policy The accepted values are the following which are set using the value option Note R The server option is also required to execute this command Starting from MySQL server 5 6 20 and 5 7 5 the value is read only for the audit_log_policy variable Now the policy results from the combination of two new variables audit_log_connection_policy and audit_log_statement_policy This change is supported starting from MySQL Utilities 1 5 2 ALL log all events NONE log nothing LOGINS only log login events QUERIES only log query events DEFAULT sets the default log policy rotate_on_size This command sets the file size threshold for automatic rotation of the audit log the audit_log_rotate_on_size variable The value is set using the value option and must be in the range 0 4294967295 This command also requires the server option to be specified Note if the variable is set with a value that is not a multiple of 4096 then it is truncated to the nearest multiple rotate This
303. mplete source code as you receive it in any medium provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty keep intact all the notices that refer to this License and to the absence of any warranty and distribute a copy of this License along with the Library You may charge a fee for the physical act of transferring a copy and you may at your option offer warranty protection in exchange for a fee 2 You may modify your copy or copies of the Library or any portion of it thus forming a work based on the Library and copy and distribute such modifications or work under the terms of Section 1 above provided that you also meet all of these conditions a The modified work must itself be a software library 235 GNU Lesser General Public License Version 2 1 February 1999 b You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change c You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License d If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility other than as an argument passed when the facility is invoked then you must make a good faith effort to ensure that in the event an application does not supply such function or table the facility sti
304. mysql and that the new target directory for the binary log files is mysql server binlogs Example Execution 1 Stop the running MySQL server 2 Start the mysqlbinlogmove utility and specify the source directory of the binary log files and the target directory shell gt mysqlbinlogmove binlog dir var 1lib mysql mysql server binlogs Mowing bina log tiles Z server bin 000001 server bin 000002 server bin 000003 server bin 000004 server bin 000005 server bin 000006 server bin 000007 server bin 000008 server bin 000009 server bin 000010 server bin 000011 done 3 Restart the MySQL server with the new value for the 1og bin option log bin mysql server binlogs server bin Discussion The above example illustrates how to change the binary log directory in an effortless way using the mysqlbinlogmove utility to move existing binary log files to the desired location Changing the 1og bin option requires the restart of the MySQL server Moreover the server also needs to be stopped in order to move all binary log files correctly otherwise an error might occur while 12 How do you purge obsolete binary log files safely moving files currently in use by the server In this case to relocate all available binary log files with the mysqlbinlogmove utility we simply need to specify their source directory using the binlog dir 76 option and the target directory as a
305. mysql database REPLICATION SLAVE REPLICATION CLIENT and GRANT OPTION As for the slave_acc users they need the SUPER privilege The repl user used as the argument for the rp1l user option is either created automatically or if it exists it needs the REPLICATION SLAVE privilege Also when using GTIDs the slave_acc users must also have SELECT privilege over the mysql database in order to run the mysql rplcheck utility successfully Tips and Tricks In the mysqlreplicate utility we could have also used the test db option which creates a dummy database to test the replication setup However the mysqlrplcheck provides more detailed information in that regard As previously stated the b option tells the utility to start replication from the first event recorded in the master s binary log Omitting this flag in turn makes the slaves replicate only what is stored in the master s binary log from the present moment onward Furthermore using the master log file and master log pos options it is possible to specify respectively the master log file and the master log position from which the slave will start its replication process 33 How Do Add New Servers to My Topology and Change Master Role The p flag can be used to ensure that the replication setup is only executed in case the storage engines match in both the master and the slave Regarding the mysqirplcheck utility we can use the s option to check the output
306. mysqlbinlogrotate server root root localhost 3310 min size 1073741824 v Checking user permission to rotate binary logs Active binlog file mysql bin 000002 size 1610612736 bytes The binlog file has been rotated New active binlog file mysql bin 000003 86 PERMISSIONS REQUIRED PERMISSIONS REQUIRED By default the user used to connect to the server must have permissions to rotate the binary logs more precisely the SUPER and REPLICATION SLAVE privileges are required 5 6 mysqldbcompare Compare Two Databases and Identify Differences This utility compares the objects and data from two databases to find differences It identifies objects having different definitions in the two databases and presents them in a diff style format of choice Differences in the data are shown using a similar diff style format Changed or missing rows are shown in a standard format of GRID CSV TAB or VERTICAL Use the notation db1 db2 to name two databases to compare or alternatively just db1 to compare two databases with the same name The latter case is a convenience notation for comparing same named databases on different servers The comparison may be run against two databases of different names on a single server by specifying only the server1 option The user can also connect to another server by specifying the server2 option In this case db1 is taken from server1 and db2 from server2 All databas
307. n Gone Se Sh Sh SE OE The following command starts replication from the beginning of recorded events on the master n hell gt mysqlreplicate master root localhost 3306 slave root localhost 3307 rpl user rpl rpl start from beginning master on localhost connected slave on localhost connected Checking for binary logging on master Setting up replication done The following command starts replication from the beginning of a specific master binary log file n hell gt mysqlreplicate master root localhost 3306 slave root localhost 3307 rpl user rpl rpl master log file my_log 000003 master on localhost connected slave on localhost connected Checking for binary logging on master Setting up replication s COONS The following command starts replication from specific master binary log coordinates specific log file and position shell gt mysqlreplicate master root localhost 3306 slave root localhost 3307 rpl user rpl rpl master log file my_log 000001 master log pos 96 master on localhost connected 158 RECOMMENDATIONS slave on localhost connected Checking for binary logging on master Setting up replication done RECOMMENDATIONS You should set read_only 1 in the my cnf file for the slave to ensure that no accidental data changes such as INSERT DELETE UPDATE and so forth
308. n of the binary logs and index files as well as the destination directory to move the files 5 4 mysqlbinlogpurge Binary log purge utility This utility enables you to safely purge binary logs by ensuring that any files which are in use or required by any of the slaves in a replication topology are not deleted This is achieved by checking which binary logs have been read on each slave This determines the minimal set of binary log files that can be purged connects to the master If the specified server is not the active master mysqlbinlogpurge Cannot determine which binary logs are still needed by Note R In order to determine which binary logs can be purged mysqlbinlogpurge the slaves 81 OPTIONS You must provide the master s connection parameters with the master option and each slave s connection parameters with the slaves option Alternatively use the discover slaves login option configured with the user name and password to connect to the slaves In case the server is not a master you must provide the connection parameters with the server 82 option mysqlbinlogpurge attempts to determine the binary logs to purge by logging in to each server If a slave is not actively participating in a replication topology mysqlbinlogpurge does not purge any logs By default mnysqlbinlogpurge purges all the binary log files that are not in use Use the binlog 83 option to override this behavior and configure the firs
309. n Topology or poor practice with data being changed directly on the slave without turning off logging to the binary log The best way to deal with errant transaction is to avoid them making sure that every transaction on a slave even if needed for example to add data for reporting or execute local administrative commands must be applied with binary logging disabled See SET sql_log_bin Syntax for more information about how to control logging to the binary log However in case errant transaction are found we still need to be able to deal with them in a easy and quick way skipping those transactions and avoiding them from being replicated if the slave becomes the new master Objectives The goal is to execute the mysqlslavet rx utility to skip errant transactions on slaves making sure that those transaction will not be replicated if slave that originated them becomes the new master Skipping errant transactions is done by injecting an empty transaction one by one for each corresponding GTID on every slave This can be a very tedious task when performed manually especially if many transactions need to be skipped Thankfully the mysqislavetrx utility allows us to skip multiple transactions on multiple slaves in a single step Let s assume that we have three slaves slave1 3311 slave2 3312 and slave3 3313 and that one of the slaves slave1 3311 has five errant transactions that need to be skipped on the other slaves The GTID set of
310. n a value and no spaces around the character Once the console is launched the user can see all variables using the show variables command OPTIONS version show program s version number and exit e help show the program s help page license Display license information and exit verbose v control how much information is displayed For example v verbose vv more verbose vvv debug quiet suppress all informational messages execute lt commands gt e lt commands gt Execute commands and exit Multiple commands are separated with semi colons Note R Some platforms may require double quotes around the command list utildir lt path gt location of utilities width lt number gt Display width NOTES Using the execute option or piping commands to the console may require quotes or double quotes for example on Windows EXAMPLES To launch the console use this command shell gt mysqluc 200 EXAMPLES The following demonstrates launching the console and running the console command help utilities to see a list of all utilities supported The console will execute the command then exit shell gt mysqluc e help utilities We diey Description mysqlindexcheck check for duplicate or redundant indexes mysqlrplcheck check replication mysqluserclone clone a MySQL user account to one or more new users mysqldbcompare compare databases for consistenc
311. n an error message The utility permits the user to log all actions taken during the commands The 10g option requires a valid path and file name of the file to use for logging operations The log is active only when this option 165 OPTIONS is specified The option 1og age specifies the age in days that log entries are kept The default is seven 7 days Older entries are automatically deleted from the log file but only if the 10g option is specified The format of the log file includes the date and time of the event the level of the event informational INFO warning WARN error ERROR critical failure CRITICAL and the message reported by the utility The utility has a number of options each explained in more detail below Some of the options are specific to certain commands Warning messages are issued whenever an option is used that does not apply to the command requested A brief overview of each command and its options is presented in the following paragraphs The start stop and reset commands require the s laves option to list all of the slaves in the topology Optionally the master option can be specified for the utility to check if the specified slaves are associated to the given master before executing the command making sure that the command is only applied to slaves connected to the right replication master The options required for the elect health and gtid commands include the ma
312. n argument The binary log files are identified based on the default filename format i e with a base filename ending with bin If a custom basename is used not ending with bin then the bin log basename 76 option must be used to specify it In the above example this option is not required because the binary log basename server bin matches the default format Similarly if a custom location or name is used for the binary log index file it must be specified using the bin log index 77 option By default the binary log index file is assumed to be located in the specified source binary log directory and to use the default filename format As we can see in the above example the mysqlbinlogmove utility displays the list of all files that are moved This helps to confirm that all files were relocated as expected Permissions Required The system user used to execute the utility must have read and write access to the source and destination directories in order to move the binary log files successfully Tips and Tricks By default the utility only moves binary log files Use the log t ype 77 option with the value relay to move relay log files or all to move both binary log and relay log files The mysqibiniogmove utility can also be used to move some binary log files to a different location while the server is still running For example suppose you want to archive the binary log files or free some disk space on
313. n off all messages for quiet execution regexp basic regexp G Perform pattern matches using the REGEXP operator The default is to use LIKE for matching rpl lt dump_option gt replication lt dump_option gt Include replication information Permitted values are master make destination a slave of the source server and slave make destination a slave of the same master as the source only works if the source server is a slave rpl user lt replication_user gt The user and password for the replication user requirement in the form lt user gt lt passwora gt or lt login path gt E g rpl passwd Default None skip gtid Skip creation and execution of GTID statements during the copy operation all Copy all of the databases on the server skip lt objects gt Specify objects to skip in the operation as a comma separated list no spaces Permitted values are CREATE_DB DATA EVENTS FUNCTIONS GRANTS PROCEDURES TABLES TRIGGERS and VIEWS Source lt source gt Connection information for the source server To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secu
314. nate the available binlog files on the server and for each slave verified the latest binlog file that has been loaded finally purges the latest binlog that is not required for any of the slaves In example all binlog files that the utility determinate that were not required by any of the slaves were purged but the option binlog 83 can be used to specify the first binlog file to keep not to purge from the not required binlog files The binlog files that will be keep available on the master are from the indicated file to the current active binlog file As we can see in the example the mysqlbinlogmove utility displays latest binlog file replicated by all slaves and if want the utility to display the current binlog file being read by the I O thread we can use the verbose 84 option Permissions Required The user requires the SUPER and REPLICATION SLAVE privileges to purge the binlog files Tips and Tricks The dry run 83 option can be used to display only the latest binlog file matched by all the slaves without actually purge the binlog files Use it along vv to display even more information as status of the SQL and I O threads of each slave 3 2 Database Operations The tasks described in this section relate to those that are performed on or with one or more databases 3 2 1 How Do Provision a Slave When working with replication one of the common tasks is adding a new slave for scale out Although adding a new slave ha
315. ncies between the storage engines and InnoDB values A round robin scheduling is used to setup replication among the masters and slave The mysalrplms utility follows these assumptions e All servers have GTIDs enabled e There are no conflicts between transactions from different masters For example there are no updates to the same object from multiple masters e Replication is asynchronous OPTIONS mysqlrpims accepts the following command line options daemon lt command gt Run as a daemon The command can be start start daemon stop stop daemon restart stop then start the daemon or nodet ach start but do not detach the process This option is only available for POSIX systems format lt format gt f lt format gt Display the replication health output in either grid default tab csv or vertical format 159 OPTIONS help Display a help message and exit interval lt seconds gt i lt seconds gt Interval in seconds for reporting health Default 15 seconds Minimum is 5 seconds license Display license information and exit log lt log_file gt Specify a log file to use for logging messages log age lt days gt Specify maximum age of log entries in days Entries older than this will be purged on startup Default 7 days masters lt master connections gt Connection information for master servers List multiple masters in comma separated list To connect to a server
316. nd table on an active replication system shell gt mysqlrplsync master user pass localhost 3310 slaves rp1 pass localhost 3311 rpl1 pass localhost 3312 test_rplsync_db test_db t1l GTID differences between Master and Slaves Slave localhost 3311 is 15 transactions behind Master Slave localhost 3312 is 12 transactions behind Master Checking data consistency Using Master localhost 3310 as base server for comparison Checking test_rplsync_db database Checking t0 table data OK test rplsync db t0 checksum for server localhost 3311 OK test_rplsync_do tO checksum for server localhoste 33i2 Checking tl table data test_rplsync_db gt tl checksum for server localhost 3311 OK test_rplsync_do tl checksum for server localhoste 33i2 Checking test_db database Checking til table data OK testidb m Cl checksum for server localhost 3311 OK test_db tl1 checksum for server localhost 3312 AN done SUMMARY No data consistency issue found To check the data consistency on an active replication system excluding a specific database and table shell gt mysqlrplsync master user pass localhost 3310 slaves rp1 pass localhost 3311 rpl pass localhost 3312 exclude test_rplsync_db test_db t1 GTID differences between Master and Slaves Slave localhost 3311 is 15 transactions behind Master
317. nding section in the file may look like the following server1 port 3308 user root password other pass host localhost The following shows the execution of a utility using a configuration file shell gt mysqlserverinfo py server dev env test1l my cnf server1 format vertical Source on localhost connected KREKKKKKKKKKK KKK KKKKKKKKEKEK alll 2 row KREKKKKKKKKKKKKKKKKKKKKKEKK server localhost 13001 config_file etc my cnf etc mysql my cnf binary_log clone bin 000001 binary_log_pos 341 relay_log Connection Parameters relay_log_pos versions 5 6 7olog datadir Volumes Source source temp_13001 basedir Volumes Source source bzr mysql 5 6 plugin_dir Volumes Source source bzr mysql 5 6 lib plugin general_log OFF general_log_file general_log_file_size log_error log error file size slow_query_log OFF slow_query_log_file slow_query_log_file_size 1 row done 2 2 1 3 Command line Options The least secure way to provide connection information for MySQL servers is to specify the data on the command line option This is least secure because the data is visible on the command line and will also be visible in any log or redirection of the execution In this case we specify the data in the following order lt user gt lt passwa gt lt host gt lt port gt lt socket where the passwd port and socket are optional Each item is described in more detail below user T
318. need the connection parameters for the new instance This is provided in the form of a dictionary We know the instance is a clone so some of the values are going to be the same and we use a default root password so that is also known Likewise we specified the data directory and since we are running on a Linux machine we know what the socket path is For Windows machines you can leave the socket value None We pass this dictionary to the copy method dest_values user gt z iconn get user passwd root hosSEY gt z conn get Thost 209 Enhancing the Example port opt new_port unix_socket os path join opt new_data mysql sock In this case a number of options are needed to control how the copy works for example if any objects are skipped For our purposes we want all objects to be copied so we supply only the minimal settings and let the library use the defaults This example shows how you can fine tune the scripts to meet your specific needs without having to specify a lot of additional options in your script We enable the quiet option on so as not to clutter the screen with messages and tell the copy to skip databases that do not exist in case we supply the databases option and provide a database that does not exist options Noumea TEUS force True The actual copy of the databases is easy Just call the method and supply the list of databases from mysql ut
319. nformation InnoDB tablespace information InnoDB_file size type specification data ib_logfile0 5242880 log file data ib_logfilel 5242880 log file data ibdatal 220200960 shared tablespace ibdatal 210M data ibdata2 10485760 shared tablespace ibdata2 10M autoextend data employees departments ibd 114688 file tablespace data employees dept_emp ibd 30408704 file tablespace data employees dept_manager ibd 131072 file tablespace data employees employees ibd 23068672 file tablespace data employees salaries ibd 146800640 file tablespace data employees titles ibd 41943040 file tablespace Total size of InnoDB files 494 125 056 bytes or 471 00 MB done PERMISSIONS REQUIRED The user must have permissions to read the data directory or use an administrator or super user sudo account to obtain access to the data directory 5 12 mysqlfailover Automatic replication health monitoring and failover This utility permits users to perform replication health monitoring and automatic failover on a replication topology consisting of a master and its slaves The utility is designed to run interactively or continuously refreshing the health information at periodic intervals Its primary mission is to monitor the master for failure and when a failure occurs execute failover to the best slave available The utility accepts a list of slaves to be considered the candidate slave This utility is designed to work exclusively for se
320. ning tests apply only to those objects that appear in both databases To skip this test use the skip object compare option That can be useful when there are known missing objects among the databases 3 Compare object definitions 87 mysqldbcompare Compare Two Databases and Identify Differences The definitions the CREATE statements are compared and differences are presented To skip this test use the skip diff option That can be useful when there are object name differences only that you want to ignore Check table row counts This check ensures that both tables have the same number of rows This does not ensure that the table data is consistent It is merely a cursory check to indicate possible missing rows in one table or the other The data consistency check identifies the missing rows To skip this test use the skip row count option Check table data consistency This check identifies both changed rows as well as missing rows from one or another of the tables in the databases Changed rows are displayed as a diff style report with the format chosen GRID by default and missing rows are also displayed using the format chosen This check is divided in two steps first the full table checksum is compared between the tables then if this step fails or is skipped the algorithm to find rows differences is executed To skip the preliminary checksum table step in this test use the skip checksum table option To s
321. ns dbcompare get_create_object Retrieve object create statement diff _objects Diff definitions of two objects check_consistency Check data consistency of two tables format format_tabular_list Format list in either GRID or delimited format to a file format_vertical_list Format list in a vertical format to a file perme Misg Print list based on format CSV GRID TAB or VERTICAL options setup_common_options Set up option parser and options common to all MySQL Utilities add_skip_options Add common skip options check_skip_options Check skip options for validity check_format_option Check format option for validity add_verbosity Add verbosity and quiet options check_verbosity Check whether both verbosity and quiet options are being used add_difftype Add difftype option add_engines Add engine default storage engine options check_engine_options Check whether storage engines listed in options exist parse_connection Parse connection values Fpl Replication Establish replication connection between a master anda slave get_replication_tests Return list of replication test function pointers server get_connection_dictionary Get connection dictionary find_running_servers Check whether any servers are running om tire llocal host connect _servers Connect to source and destination server Server Connect to running MySQL server and perform server level operations table Index Encapsulate index for a given table as defined by SHOW INDEXES Table Encapsulate
322. o certain designated libraries and is quite different from the ordinary General Public License We use this license for certain libraries in order to permit linking those libraries into non free programs When a program is linked with a library whether statically or using a shared library the combination of the two is legally speaking a combined work a derivative of the original library The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom The Lesser General Public License permits more lax criteria for linking other code with the library We call this license the Lesser General Public License because it does Less to protect the user s freedom than the ordinary General Public License It also provides other free software developers Less of an advantage over competing non free programs These disadvantages are the reason we use the ordinary General Public License for many libraries However the Lesser license provides advantages in certain special circumstances For example on rare occasions there may be a special need to encourage the widest possible use of a certain library so that it becomes a de facto standard To achieve this non free programs must be allowed to use the library A more frequent case is that a free library does the same job as widely used non free libraries In this case there is little to gain by limiting the free library to free software on
323. o possible to specify a database to be used to test replication The utility reports conditions where the storage engines on the master and the slave differ It also reports a warning if the InnoDB storage engine differs on the master and slave For InnoDB to be the same both servers must be running the same type of InnoDB built in or the InnoDB Plugin and InnoDB on both servers must have the same major and minor version numbers and enabled state By default the utility issues warnings for mismatches between the sets of storage engines the default storage engine and the InnoDB storage engine To produce errors instead use the pedantic option which requires storage engines to be the same on the master and slave The vv option displays any discrepancies between the storage engines and InnoDB values with or without the pedantic option Replication can be started using one of the following strategies e Start from the current position default Start replication from the current master binary log file and position The utility uses the SHOW MASTER STATUS statement to retrieve this information Start from the beginning Start replication from the first event recorded in the master binary log To do this use the start from beginning option Start from a binary log file Start replication from the first event in a specific master binary log file To do this use the master log file option Start from a specific event
324. ods include the following in order of most secure to least secure e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket e Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt show reverse 116 NOTES NOTES Produce a transformation report containing the SQL statements to conform the object definitions specified in reverse For example if changes for is set to server1 also generate the transformation for server2 Note R The reverse changes are annotated and marked as comments Skip table options Ignore the differences between all table options such as AUTO_INCREMENT ENGINE CHARSET etc A warning is issued if the skip table options option is used and table option differences are found ssl ca The path to a file that contains a list of trusted SSL CAs ssl cert The name of the SSL certificate file to use for establishing a secure connection ssl cert The name of the SSL key file to use for establishing a secure connection SSl Specifies if the server connection requires use of SSL If an encrypted connection cannot be established the connection attempt fails Default setting i
325. of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control means i the power direct or indirect to cause the direction or management of such entity whether by contract or otherwise or ii ownership of fifty percent 50 or more of the outstanding shares or iii beneficial ownership of such entity You or Your shall mean an individual or Legal Entity exercising permissions granted by this License Source form shall mean the preferred form for making modifications including but not limited to software source code documentation source and configuration files Object form shall mean any form resulting from mechanical transformation or translation of a Source form including but not limited to compiled object code generated documentation and conversions to other media types 227 Apache Libcloud Work shall mean the work of authorship whether in Source or Object form made available under the License as indicated by a copyright notice that is included in or attached to the work an example is provided in the Appendix below Derivative Works shall mean any work whether in Source or Object form that is based on or derived from the Work and for which the editorial revisions annotations elaborations or other modifications represent as a whole an original work of authorship For the purpo
326. ogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt e Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt e Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt e ssl ca The path to a file that contains a list of trusted SSL CAs e ssl cert The name of the SSL certificate file to use for establishing a secure connection e ssl cert The name of the SSL key file to use for establishing a secure connection e ssl Specifies if the server connection requires use of SSL If an encrypted connection cannot be established the connection attempt fails Default setting is 0 SSL not required e show stats S Show file statistics and general table information for each frm file read start timeout lt timeout_in_seconds gt Number of seconds to wait for spawned server to start The default is 10 seconds e user Execute the spawned server using this user account Permits the execution of the utility as one user but the spawned server as another Required if running the utility as the root user e g su or sudo e quiet Turn off all messages for quiet execution except CREATE statements and errors e verbose v Control how much information is displayed For example v verbose vv more
327. ollowing tasks are those for use with the Audit Log Plugin 3 6 1 How Do Record Only Login Events The audit log plugin records MySQL servers activity By default it is set to write all auditable events to the log file which can represent a considerable amount of information Fortunately it is possible to control the type of information that is written to the audit log file changing the audit log plugin s policy The policy should be set to log only the events of interest avoiding wasting resources to log unnecessary events In particular if the audit log plugin is only used to monitor access to the database server for security purposes then only the login events need to be recorded The mysqlauditadmin utility allows us to perform such change in a simple way as well as changes other settings Objectives The goal is to set the audit log plugin to only write the login events to the log file It is assumed that the audit log plugin is enabled and running with the default settings logging all auditable events on the localhost and default port 3306 Example Execution shell gt mysqlauditadmin server root localhost 3306 policy value LOGINS show options Showing options before command Audit Log Variables and Options 4 4 Variable_name Value 4 4 audit_log_buffer_size 1048576 audit_log_file audit log auereliiic _Ihexey
328. ollowing values with the format option e grid default Display output in grid or table format like that of the mysq1 client command line tool e CSV Display output in comma separated values format tab Display output in tab separated format vertical Display output in single column format like that of the G command for the mysq1 client command line tool Options mysqlprocgrep accepts the following command line options e help 151 Options Display a help message and exit license Display license information and exit age lt time gt Select only processes that have been in the current state more than a given time The time value can be specified in two formats either using the hh mm ss format with hours and minutes optional or as a sequence of numbers with a suffix giving the period size The permitted suffixes are s second m minute h hour d day and w week For example 4h15m represents 4 hours and 15 minutes For both formats the specification can optionally be preceded by or where means older than the given time and means younger than the given time character set lt charset gt Sets the client character set The default is retrieved from the server variable character_set_client format lt format gt f lt format gt Specify the output display format Permitted format values are grid default csv tab and vertical kill connection Kill
329. omma separated list of connection parameters in the following form where the password port and socket are optional lt user gt 2 lt passwd gt i lt host gt 7 lt port gt 3 lt socket gt or lt alogim pat M e lt joerc eee sockets The utility permits users to discover slaves connected to the master In order to use the discover slaves feature all slaves must use the report host and report port startup variables to specify the correct hostname and ip port of the slave If these are missing or report the incorrect information the slaves health may not be reported correctly or the slave may not be listed at all The discover slaves feature ignores any slaves it cannot connect to or if the IO thread stopped it is not connected to the master The utility permits the user to demote a master to a slave during the switchover operation The demote master option tells the utility to once the new master is established make the old master a slave of the new master This permits rotation of the master role among a set of servers The utility permits the user to specify an external script to execute before and after the switchover and failover commands The user can specify these with the xec before and xec after options The return code of the script is used to determine success thus each script must report 0 success to be considered successful If a script returns a value other than 0 the result code is presented i
330. ommand sub folder These modules are where all of the work done by the utilities take place This enables you to create new combinations of the utilities by calling the actual operations directly Let s do that now to clone the server The first thing you notice in examining the serverclone module is that it takes a number of parameters for the new server instance We supply those in a similar way as options parser add_option new data action store dest new_data type string help the full path to the location of the data directory for the new instance parser add_option new port action store dest new_port type string default 3307 help the new port for the new instance default default parser add_option new id action store dest new_id type string default 2 help the server_id for the new instance default default from mysql utilities command import serverclone eyes res serverclone clone_server conn opt new_data opt new_port opt new_id root None False True except exception UtilError e print ERROR e errmsg sys exit As you can see the operation is very simple We just added a few options we needed like new data new port and new id much like mysqlserverclone and supplied some default values for the other parameters Next we need to copy the databases Once again we use the command module for mysqidbcopy to do all of the work for us First we
331. on attempt fails Default setting is 0 SSL not required timeout lt seconds gt Maximum timeout in seconds to wait for each replication command to complete For example timeout for slave waiting to catch up to master Default 3 e verbose vV Specify how much information to display Use this option multiple times to increase the amount of information For example v verbose vv more verbose vvv debug e version Display version information and exit NOTES The login user must have the appropriate permissions for the utility to check servers and monitor their status e g SHOW SLAVE STATUS SHOW MASTER STATUS The user must also have permissions to execute the failover procedure e g STOP SLAVE START SLAVE WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS CHANGE MASTER TO Lastly the user must have the REPLICATE SLAVE privilege for slaves to connect to their master The same permissions are required by the failover utility for master and slaves in order to run successfully In particular users connected to slaves candidates and master require SUPER GRANT OPTION REPLICATION SLAVE RELOAD DROP CREATE INSERT and SELECT privileges The DROP CREATE INSERT and SELECT privileges are required to register the failover instance on the initial master or the new master after a successful failover Therefore since any slave can become the new master slaves and candidates also require those privileges The utility che
332. on between Utilities and a MySQL DOI OF 2e tt sda ctate audi a ides cates hash Gar adene een asa earn cteat Sass tia mish rad te stata peeses toast a ete eis ideas een 49 3 6 Specialized Operations i r a aana deve a teeta eied ee Wi Sadie eb vind ee a eee GA 53 3 6 1 How Do Record Only Login Events ccccceeeeeeeeee cece eeeeeeeeeeeeeeaeaaeeneeeeeeeeeaeaaeaees 53 3 6 2 How Do Copy Move The Audit Log cceceeeeeeeeeeeeeeeeeeeeeeeeeaaaaeeeeeeeeeeeeaaaaeneeeeeeees 54 3 6 3 How Do Show All INSERT and UPDATE Queries That Failed ccseeeeeeeeeeeeees 55 3 6 4 How Do Display Connections by the User root and Show the Result in CSV Format MySQL Utilities provides a command line set of tools for working with MySQL Servers and databases MySQL Utilities fully supports MySQL Server versions 5 1 and above It is also compatible with MySQL Server 5 0 but not every feature of 5 0 may be supported It does not support MySQL Server versions 4 x In this section we present a number of example administrative tasks Included in each is a description of the need goals example execution and a discussion about the specific options and techniques illustrated Also included is a description of the specific permissions required to execute the utilities demonstrated 3 1 Binary Log Operations The tasks described in this section relate to those that are performed on or with binary log files 11 How To Change The
333. on is specified in this example for the audit log name option only the information of the specified file will be displayed as opposed to the file statistics of all existing files 3 6 3 How Do I Show All INSERT and UPDATE Queries That Failed Useful information can be recorded in the audit log files and also a considerable amount of it However how can someone easily filter this information and search for specific events for instance in order to determine the possible cause of a problem For example suppose that someone reported that some data changes are missing INSERT or UPDATE queries failed and you want to determine what might be the cause of those transaction failures All queries are recorded to the audit log file so you just need to get retrieve all queries of a given type that failed with a MySQL Error and analyze them This can be achieved using common grep command line tools but likely involves the use of very complex regular expression to filter the desired data Fortunately the mysqlauditgrep utility allows to perform this kind of task in a much easier and simple way taking advantage of the knowledge of the structure and semantics of the audit log files Objectives The goal is display all INSERT and UPDATE queries that failed independently of error from the current audit log file 55 How Do Display Connections by the User root and Show the Result in CSV Format It is assumed that the audit 1log file
334. one valid value Mixing IP and hostnames is not recommended The replication specific utilities will attempt to compare hostnames and IP addresses as aliases for checking slave connectivity to the master However if your installation does not support reverse name lookup the comparison could fail Without the ability to do a reverse name lookup the replication utilities could report a false negative that the slave is not connected to the master For example if you setup replication using MASTER_HOST ubuntu net on the slave and later connect to the slave with mysqlrplcheck and have the master specified as master 192 168 0 6 using the valid IP address for ubuntu net you must have the ability to do a reverse name lookup to compare the IP 192 168 0 6 and the hostname ubuntu net to determine if they are the same machine The path to the MySQL client tools should be included in the PATH environment variable in order to use the authentication mechanism with login paths This will allow the utility to use the my_print_defaults tools which is required to read the login path values from the login configuration file mylogin cnf EXAMPLES To show the slaves for a master running on port 3311 on the local host use the following command shell gt mysqlrplshow master root localhost 3311 discover slaves login root master on localhost connected Finding slaves for master localhost 3311 Replication Topology Graph localhost 3
335. onnection method to take the server option values and get a dictionary with the connection values All of the heavy diagnosis and error handling is done for us so we just need to check for exceptions from mysql utilities common options import parse_connection Erys conn parse_connection opt server except parser error Server connection values invalid or cannot be parsed Now that we have the connection parameters we create a class instance of the server using the Server Class from the server module and then connect Once again we check for exceptions from mysgql utilities common server import Server server_options Noein since 8 COnN role B Veronese serverl Server server_options EEY serverl connect except UtilError e print ERROR e errmsg The next item is to get a list of all of the databases on the server We use the new server class instance to retrieve all of the databases on the server ela lise i for db in serverl get_all_databases db_list append db 0 None If you wanted to supply your own list of databases you could use an option like the following You could also add an e1se clause which would enable you to either get all of the databases by omitting the databases option or supply your own list of databases for example databases db1 db2 db3 Danas eisrac mo pita oni ills type string help comma separated list of databases to include in the copy omit for
336. ons POSIX extended 3 6 4 How Do Display Connections by the User root and Show the Result in CSV Format The audit log plugin can be used to record information about different type of events which one might need to monitor or keep a record in a different format For example a security record with the list of all logins performed to the database serve might need to be kept to later track the responsible for some 56 How Do Display Connections by the User root and Show the Result in CSV Format change Moreover the retrieved information might need to be converted to a specific format Such as CSV to feed another application Objectives The goal of this task is to retrieve from the audit log the information of all the connections established by the root user to the MySQL Server and display the resulting information in the comma separated value CSV format Besides the search filter functionalities using different criteria the mysqlauditgrep utility also provides a feature to display the resulting information in different formats including CSV This allows this task to be performed easily with in a single step It is assumed that the audit 1log file exists and is located in the directory MySQL SERVER data Example Execution shell gt mysqlauditgrep user root event type Connect format CSV MySOL SERVER data audit log STATUS NAME TIMESTAMP CONNECTION_ID HOST USER PRIV_USER IP 0 Conoect 201
337. or promote products derived from this 246 Python License software without specific prior written permission THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT INDIRECT INCIDENTAL SPECIAL EXEMPLARY OR CONSEQUENTIAL DAMAGES INCLUDING BUT NOT LIMITED TO PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES LOSS OF USE DATA OR PROFITS OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY WHETHER IN CONTRACT STRICT LIABILITY OR TORT INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE Floating point exception control Copyright c 1996 The Regents of the University of California All rights reserved Permission to use copy modify and distribute this software for any purpose without fee is hereby granted provided that this en tire notice is included in all copies of any software which is or includes a copy or modification of this software and in all copies of the supporting documentation for such software This work was produced at the University of California Lawrence Livermore National Laboratory under contract no
338. ormat gt f lt format gt Specify the input format Permitted format values are sql default grid tab csv raw_csv and vertical import lt import_type gt i lt import_type gt Specify the import format Permitted format values are Table 5 1 mysqldbimport Import Types Import Type Definition definitions default Only import the definitions metadata for the objects in the database list data Only import the table data for the tables in the database list both Import both the definitions metadata and data If you attempt to import objects into an existing database the result depends on the import format If the format is definitions or both an error occurs unless drop first is given If the format is data imported table data is added to existing table data max bulk insert Specify the maximum number of INSERT statements to bulk by default 30000 This option is only used with bulk insert multiprocess 111 OPTIONS Specify the number of processes to concurrently import the specified files Special values 0 number of processes equal to the number of detected CPUs and 1 default no concurrency Multiprocessing works at the files level for any operating systems new storage engine lt new_engine gt The engine to use for all tables created on the destination MySQL server no headers h Input does not contain column headers This option only applies to the csv and t
339. ormation Current binary log file my_log 000287 4 4 log_file my_log 000285 my_log 000286 21 My Server Crashed Need to Know the Structure of a Table How Can Do That my_log 000287 3063 my_log index 48 Total size of binary logs 255 575 bytes or 249 58 KB Server is not an active slave no relay log information InnoDB tablespace information 4 4 innodb_file Pe aT Se elo ere ib_logfile0d Sr BAD MeN ibdatal BIS 792 128 ibdata2 2 S EXO au ale _Il yejigat hen 5 242 880 au 4 Total size of InnoDB files 889 192 448 bytes or 848 00 MB nnoDB freespace 635 437 056 bytes or 606 00 MB Discussion To see all of the logs we use the a11 option which shows all logs and the InnoDB disk usage Notice we used elevated privileges to allow for reading of all of the files and databases in the data directory In this case the data directory is owned by the mysql user and a normal user account does not have read access The a11 option instructs the utility to list all databases even if they contain no data Permissions Required The user must have permissions to read the data directory or use an administrator or super user Sudo account as shown in the example Tips and Tricks You can run mysqldiskusage without privile
340. orted values for this option also includes CREATE ALTER DROP TRUNCATE RENAME GRANT REVOKE SELECT DELETE COMMIT SHOW SET CALL PREPARE EXECUTE DEALLOCATE The status option accepts a comma separated list of non negative integers corresponding to MySQL error codes or intervals marked with a dash For example 1051 1100 1199 1146 In this particular case the range value 1 9999 was used to include all MySQL error codes and display all unsuccessful commands To retrieve only successful command no errors simply use the value 0 for the status option Permissions Required The user must have permissions to read the audit log on disk Tips and Tricks The value specified for the query type option are case insensitive therefore you can mix lower and upper case to specify the list of query types For example insert Update will produce the same result as using INSERT UPDATE Of course the use of non supported values will raise an appropriate error Many other options and search criteria are provided by the mysqlauditgrep utility check them in order to use the more appropriate one to meet your needs Note that the utility provides the pattern option to search entries in the audit log file using regular expressions like common grep tools By default this option will use standard SQL pattern matching used by LIKE comparison operator unless the regexp option is used to allow more powerful standard regular expressi
341. orts an error if the server ID is 0 on either server or the same on the master and slave Set these values before starting this utility Mixing IP and hostnames is not recommended The replication specific utilities will attempt to compare hostnames and IP addresses as aliases for checking slave connectivity to the master However if your installation does not support reverse name lookup the comparison could fail Without the ability to do a reverse name lookup the replication utilities could report a false negative that the slave is not connected to the master For example if you setup replication using MASTER_HOST ubuntu net on the slave and later connect to the slave with mysqlrplcheck and have the master specified as master 192 168 0 6 using the valid IP address for ubuntu net you must have the ability to do a reverse name lookup to compare the IP 192 168 0 6 and the hostname ubuntu net to determine if they are the same machine The path to the MySQL client tools should be included in the PATH environment variable in order to use the authentication mechanism with login paths This will allow the utility to use the my_print_defaults tools which is required to read the login path values from the login configuration file mylogin cnf EXAMPLES To set up replication between two MySQL instances running on different ports of the same host using the default settings use this command shell gt mysqlreplicate master root
342. ot remember the name We know it starts with mysqldb but we are not sure of the rest In this case if we type mysqldb then hit TAB twice the users console will show us a list of all of the utilities that begin with mysqldb Now let s say we want to see a graph of our replication topology but we are not sure what the option for specifying the master In this case we type the command to launch the mysql rplshow utility and type the start of the option m then press TAB twice What we see is there are two options that match that prefix Notice we also see a short description help for each This is a real time saving feature for the users console Notice in the next segment we do not have to type the entire name of the option In this case we typed mast TAB which the users console completed with master This is tab completion for option names Notice the result of the command we entered mysqlirplshow master lt user gt lt password gt localhost 13001 There was an error here We can see the error with the show errors command We see in the error we failed to provide any connection information for the slaves Once we correct that omission the last command shows how the users console executes a utility and displays the results in the same stream as the console much like the mysqli client command line tool Permissions Required There are no special permissions required to run mysqluc however you must have the neces
343. oup This software or hardware and documentation may provide access to or information about content products and services from third parties Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with respect to third party content products and services unless otherwise set forth in an applicable agreement between you and Oracle Oracle Corporation and its affiliates will not be responsible for any loss costs or damages incurred due to your access to or use of third party content products or services except as set forth in an applicable agreement between you and Oracle Documentation Accessibility For information about Oracle s commitment to accessibility visit the Oracle Accessibility Program website at http www oracle com pls topic lookup ctx acc amp id docacc Access to Oracle Support Oracle customers that have purchased support have access to electronic support through My Oracle Support For information visit http www oracle com pls topic lookup ctx acc amp id info or visit http Awww oracle com pls topic lookup ctx acc amp id trs if you are hearing impaired This documentation is NOT distributed under a GPL license Use of this documentation is subject to the following terms You may create a printed copy of this documentation solely for your own personal use Conversion to other formats is allowed as long as the actual content is not altered or edited in any
344. ours eee 56 4 Overview of MySQL Utilities 2 0 0 eect ee teeter ee ee eee a ete te eran ee ee ceed ee sees ease aaaaaaeeeeeeeeeeaeaaaeaes 59 4 1 Binary Log Operations cirri asi cece cece cece cette te ener ee ee eae ete ee eres ee na tentada eenaa hapii aa eaS i Eea 59 MySQL Utilities 4 2 Database Operations iis sessscecss ce oceseeteed debs cyoeebaeue enced aaa ron eee 59 4 3 General Operations isene ce ee cece cece aaa teeters a ease aa Ea R EES 60 4 4 High Availability Operations 2 0 0 2 cece cece cece eee eee eeeee eter ee ee ae aaa eeeeeeeeseaaaaaaeeeeeeeeeeaaaaaanees 61 4 5 Server Operations gegecncetiiasisesecny shies Yaa sd spear enced ces a Gen vauhvanyented cor I AEREE 62 4 6 Specialized Operations sieccccisesatcessevneccsanhondessbedercaathacdenstanereseshenddaataderenatheveesbsseneebeenendess 62 o Manual Pages rere a T ouenestcodeatreavenbarcagecteay 63 5 1 mysqlauditadmin Allows users to perform maintenance action on the audit log 63 5 2 mysqlauditgrep Allows users to search the current or an archived audit log 68 5 3 mysqlbinlogmove Binary log relocate Utility 0 0 0 cece eceeeeeeeeeeeeeeeeeeeaeeeeeeeaeeeeeenees 75 5 4 mysqlbinlogpurge Binary log purge Utility 0 0 eee eect cece cette ee eeeeeeeeeeaeeeeeeaaes 81 5 5 mysqlbinlogrotate Binary log rotate Utility 0 0 eect ee cece aiina 85 5 6 mysqldbcompare Compare Two Databases and Identify Dif
345. over slaves login root Server localhost 3331 is running on localhost master on localhost connected Finding slaves for master localhost 3331 Seuvermlocalnostcc S27 ie EUNA Oni localhost master on localhost FAILED Connection to localhost 3332 has failed Please enter the following information to connect to this server User namer root Password master on localhost connected Finding slaves for master localhost 3332 Server localhost 3333 is running on localhost master on localhost FAILED Connection to localhost 3233 has failed Please enter the following information to connect to this server User name root Password Master on localhost connected Finding slaves for master localhost 3333 Server localhost 3334 is running on localhost master on localhost FAILED Connection to localhost 3334 has failed Please enter the following information to connect to this server User namer root Password master on localhost connected Finding slaves for master localhost 3334 Replication Topology Graph localhost 3331 MASTER T leeellaosiesSss2 S FAVE to lleeellinosicg 3553 EN FAVE ap WANS RER localhost s334 SLAVIT PERMISSIONS REQUIRED The user connected to the master must have the REPLICATION SLAVE privilege The user specified with the discover slaves login option that logs into each slave must have the REPLICATION CLIENT priv
346. pattern audit_log SERVER data audit log 4 4 4 4 STATUS SERVER_ID NAME TIMESTAMP CONNECTION_ID 4 4 4 4 o ae Guery 2072 09 28T71ts26250 10 4 4 4 4 PERMISSIONS REQUIRED The user must have permissions to read the audit log on disk 5 3 mysqlbinlogmove Binary log relocate utility 75 OPTIONS This utility allows binary logs to be relocated to a different location in a simple and easy way In particular it moves existing binary logs to the specified location and updates the necessary server files i e binary log index files From a practical point of view the use of this utility is recommended before you change the binary log base directory to move all binary log files to the target location avoiding errors on the server when started with the new log bin location It is also useful to archive older binary log files to a different location in order to save disk space in the current partition requirement is not needed if only some of binary log files are intended to be Note R In order to relocate all binary log files the MySQL server must be stopped This moved The user must provide the destination directory to move the binary log files as an argument and the server conn
347. pe Eransactions for localhost SS IREE done Execute the utility in dryrun mode to verify which GTIDs would have been skipped on all specified slaves shell gt mysqlslavetrx gtid set af6b22ee 7b0b 11e4 aa8d 606720440b68 6 12 slaves user pass localhost 3311 user pass localhost 3312 dryrun 197 PERMISSIONS REQUIRED WARNING Using a password on the command line interface can be insecure WARNING Executing utility in dry run mode read only GTID set to be skipped for each server localhost 3311 af b22ee 7b0b 11le4 aa8d 606720440b68 6 10 12 localhost 3312 af b22ee 7b0b 1le4 aa8d 606720440b68 6 10 12 dry xun imjecting empty transactions for lleocalhost 3311 dry sun injecting empty transactions for llecalhost 2312 done Skip multiple GTIDs on the specified slaves using the verbose mode shell gt mysqlslavetrx gtid set af6b22ee 7b0b 11e4 aa8d 606720440b68 6 12 slaves user pass localhost 3311 user pass localhost 3312 verbose WARNING Using a password on the command line interface can be insecure GTID set to be skipped for each server localhost 3311 af b22ee 7b0b 1le4 aa8d 606720440b68 6 10 12 localhost 3312 af b22ee 7b0b 1le4 aa8d 606720440b68 6 10 12 injecting empty transactions for localhost o gt MEER af6 b22ee 7b0b 11e4 aa8d 606720440b68 6 af6 b22ee T7b0b 1
348. pe that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU Lesser General Public License for more details You should have received a copy of the GNU Lesser General Public License along with this library if not write to the Free Software Foundation Inc 51 Franklin Street Fifth Floor Boston MA O2ITO 1301 USA Also add information on how to contact you by electronic and paper mail You should also get your employer if you work as a programmer or your HGNC aie EW CO Slem a Veooyredeine chiseilammerc toi che Ililoreuey aie necessary Here is a sample alter the names Yoyodyne Inc hereby disclaims all copyright interest in the library Frob a library for tweaking knobs written by James Random Hacker lt signature of Ty Coon gt i April 1990 Ty Coon President of Vice Thats Eulil wlaeiee ale jee slic 8 2 5 Paramiko License The following software may be included in this product Paramiko You are receiving a copy of Paramiko in both source and object code The terms of the Oracle license do NOT apply to the Paramiko program it is licensed under the following license separately from the Oracle programs you receive If you do not wish to install this program you may delete the Paramiko folder and all its contents This component is licensed under Section 8 2 4 GNU Lesser General Public License Version 2 1 Fe
349. pecifying a user and password or login path to connect to the slaves and the utility will attempt to discover all the slaves connected with the master using the specified login For the above example discover slaves login root could be used The discover slaves login can be very handy especially if there is a huge number of slaves in the topology but bear in mind that the explicit specification of slaves is safer and that discovery can fail to find some servers In particular it is important to note that in order for slaves to be discovered they must be started with the report host and report port options with a appropriate values and they must be correctly connected to the master I O thread running otherwise discovery will fail It is also recommended to use the 1og options to specify a file to register all events warning and errors This is useful to keep a record of what happened for example to later determine when failover occurred and if the process occurred without any errors An important matter to discuss is the order in which the server are select as candidates for failover No distinction is made in terms of the number of transaction to select the most up to date slave to become the new master The reason is very simple this criteria is non deterministic as many circumstances i e network load server maintenance operations can temporarily influence the performance of a slave and could lead to an incorrect selec
350. plugin is available as of MySQL Server versions 5 5 28 and 5 6 10 This utility requires Python version 2 6 or higher but does not support Python 3 The path to the MySQL client tools should be included in the PATH environment variable in order to use the authentication mechanism with login paths This will allow the utility to use the my_print_defaults tools which is required to read the login path values from the login configuration file mylogin cnf This feature exists as of MySQL Server 5 6 6 see mysql_config_editor MySQL Configuration Utility Changes to MySQL Enterprise Audit Log Plug in are not documented in this documentation so your output might be different than the examples here For example a new or removed MySQL Enterprise Audit Log Plug in option might affect the output LIMITATIONS The remote login option is not supported on Microsoft Windows platforms For Microsoft Windows use UNC paths and perform a local copy operation omitting the remote login option EXAMPLES To display the audit log system variables run the following command shell gt mysqlauditadmin show options server root localhost 3310 Showing options after command Audit Log Variables and Options 4 4 Variable_name Value 4 4 audit_log_buffer_size 1048576 audit_log_connection_policy NONE audit_log_current_s
351. point was reached Default 3 seconds license Display license information and exit master lt master_connection gt Connection information for the master server To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket e Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt passwad gt lt host gt lt port gt lt socket gt rpl timeout lt rpl_timeout_in_seconds gt Maximum timeout in seconds to wait for synchronization More precisely the time to wait for the replication process on a slave to reach a sync point GTID set Default 300 seconds Slaves lt slaves_connections gt Connection information for slave servers List multiple slaves in comma separated list To connect to a server it is necessary to specify connection parameters such as user name host nam
352. port role state gtid_mode health 4 4 4 4 4 4 localhost 3307 MASTER UP ON OK localhost 3306 SLAVE UP ON OK localhost 3308 MASTER UP ON OK 4 4 4 4 4 4 The following command uses report values to report health GTID and UUID status shell gt mysqlrplms slave root root localhost 3306 masters root root localhost 3307 root root localhost 3308 n report values health gtid uuid Starting multi source replication Pie sisu Rint Curt Omiciueliters Switching to master localhost 3307 master on localhost connected slave on localhost connected Sh Sh Sh OSE OSE OSE H Current Master Information RECOMMENDATIONS Binary Log File Position Binlog_Do_DB Binlog_Ignore_DB 4 4 4 4 clone bin 000001 594 N A N A 4 4 4 4 GTID Executed Set 00a4e027 a83a 1le3 8bd6 28d244017f 26 1 2 Health Status 4 4 4 4 4 host pore r le state gtid_mode health 4 4 4 4 4 tecalhost 3307 MASTER Us ON OK Tocalhost 3306 SLAVE we
353. pply to all destination tables in the operation For the format and import options the permitted values are not case sensitive In addition values may be specified as any unambiguous prefix of a valid value For example format g specifies the grid format An error occurs if a prefix matches more than one valid value When importing data and including the GTID commands you may encounter an error similar to GTID_PURGED can only be set when GTID_EXECUTED is empty This occurs because the destination server is not in a clean replication state To solve this problem you can issue a RESET MASTER command on the destination prior to executing the import The path to the MySQL client tools should be included in the PATH environment variable in order to use the authentication mechanism with login paths This will allow the utility to use the my_print_defaults tools which is required to read the login path values from the login configuration file mylogin cnf Keep in mind that you can only take advantage of multiprocessing if your system has multiple CPUs available for concurrent execution Also note that multiprocessing is applied at the file level for the mysqldbimport utility which means that only different files can be concurrently imported EXAMPLES To import the metadata from the ut il_test database to the server on the local host using a file in CSV format use this command EF PERMISSIONS REQUIRED shell gt mysqldb
354. prints the equivalent CREATE INDEX or ALTER TABLE for primary keys To display the best or worst non primary key indexes for each table use the best or worst option This causes the output to show the best or worst indexes from tables with 10 or more rows By default each option shows five indexes To override that provide an integer value for the option To change the format of the index lists displayed for the show indexes best and worst options use one of the following values with the format option grid default Display output in grid or table format like that of the mysql client command line tool e CSV Display output in comma separated values format tab Display output in tab separated format sql Print SQL statements rather than a list vertical Display output in single column format like that of the G command for the mysq1 client command line tool Note R The best and worst lists cannot be printed as SQL statements OPTIONS mysqlindexcheck accepts the following command line options e help Display a help message and exit e license Display license information and exit e best lt N gt If stats is given limit index statistics to the best N indexes The default value of N is 5 if omitted format lt index_format gt f lt index_format gt Specify the index list display format for output produced by stats Permitted format values are grid csv tab sql and ve
355. pted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt exclude lt exclude gt x lt exclude gt Exclude one or more objects from the operation using either a specific name such as db1 t1 or a search pattern Use this option multiple times to specify multiple exclusions By default patterns use LIKE matching With the regexp option patterns use REGEXP matching This option does not apply to grants drop first Drop each database to be copied if exists before copying anything into it Without this option an error occurs if you attempt to copy objects into an existing database Note R Before MySQL Utilities 1 4 2 this option was named force locking lt locking gt Choose the lock type for the operation Permitted lock values are no locks do not use any table locks lock all use table locks but no transaction and no consistent read and snapshot consistent read using a single transaction The default is snapshot multiprocess Specify the number of processes to concurrently copy the specified databases Special values 0 number of processes equal to the number of detected CPUs and 1 default no concurrency Multiprocessing works at the database level for Windows and at the table level for Non Windows POSIX systems 97 OPTIONS new storage engine lt new_engine gt The engine to use for all tables created on the destination server quiet q Tur
356. published by the Free Software Foundation 14 If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these write to the author to ask for permission For software which is copyrighted by the Free Software Foundation write to the Free Software Foundation we sometimes make exceptions for this Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally NO WARRANTY 15 BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE THERE IS NO WARRANTY FOR THE LIBRARY TO THE EXTENT PERMITTED BY APPLICABLE LAW EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND OR OTHER PARTIES PROVIDE THE LIBRARY AS IS WITHOUT WARRANTY OF ANY KIND EITHER EXPRESSED OR IMPLIED INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU SHOULD THE LIBRARY PROVE DEFECTIVE YOU ASSUME THE COST OF ALL NECESSARY SERVICING REPAIR OR CORRECTION 16 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER OR ANY OTHER PARTY WHO MAY MODIFY AND OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE BE LIABLE TO YOU FOR DAMAGES INCLUDING ANY GENERAL SPECIAL INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF TH
357. qlrplshow py error The discover slaves login is required to test slave connectivity mysqluc gt mysqlrplshow master lt user gt lt password gt localhost 13001 discover slaves login lt user gt lt password gt master on localhost connected Finding slaves for master localhost 13001 Replication Topology Graph localhost 13001 MASTER t localhost 213002 SLAVE t localhost 213003 SLAVE t localhost 213004 SLAVE localhost 213005 SLAVE mysqluc gt Discussion There is a lot going on here in this example Let s look through the command entries as they occur in the text The first command mysqluc starts the users console Once the console starts you will see a welcome banner followed by a simple prompt mysqluc gt No additional options or parameters are necessary However it should be noted that you can pass commands to the console to execute on start For a complete list of options see MySQL Users Console manual page The next command help shows the help for the users console itself As you can see there are a number of options available You can set user defined variables discover the help for other utilities display the latest error and see the options used to start the console The help utilities command shows you a list of the available utilities and a short description of each Next we decide we want to get help for one of the database utilities but we do n
358. r concurrent execution Also note that multiprocessing is applied at a different level according to the operating system where the mysqldbexport utility is executed due to python limitations In particular it is applied at the database level for Windows i e different databases are concurrently exported and at the table level for Non Windows POSIX systems i e different tables within the same database are concurrently exported EXAMPLES To export the definitions of the database dev from a MySQL server on the local host via port 3306 producing output consisting of CREATE statements use this command 106 EXAMPLES shell gt mysqldbexport server root pass localhost skip GRANTS export DEFINITIONS util_test e int Source on localhost Exporting metadata from util_test DROP DATABASE IF EXISTS util_test CREATE DATABASE util_test USE util_test TABLE util_test t CREATE TABLE El a char 30 DEFAULT NULL ENGINE MEMORY DEFAULT CHARSET latinl TABLE utalstest t2 CREATE TABLE t2 a char 30 DEFAULT NULL ENGINE MyISAM DEFAULT CHARSET latin1l TABLE util_test t3 CREATE TABLE E3 11 NOT NULL AUTO_INCREMENT b char 30 DEFAULT NULL PRIMARY KEY a ENGINE InnoDB AUTO_INCREMENT 4 TABLE util_test t4 CREATE TABLE t4 gt eS dine Gli NOT NULE Se ame CL NOT NULE KEK Teto eS CONSTRAINT ref t3 FOREIGN KEY ENGINE InnoDB DEFAU VIEW ut
359. r in any derivative version provided however that CNRI s License Agreement and CNRI s notice of copyright i e Copyright c 1995 2001 Corporation for National Research Initiatives All Rights Reserved are retained in Python 1 6 1 alone or in any derivative version prepared by Licensee Alternately in lieu of CNRI s License Agreement Licensee may substitute the following text omitting the quotes Python 1 6 1 is made available subject to the terms and conditions in CNRI s License Agreement This Agreement together with 244 Python License Python 1 6 1 may be located on the Internet using the following unique persistent identifier known as a handle 1895 22 1013 This Agreement may also be obtained from a proxy server on the Internet using the following URL http hdl handle net 1895 22 1013 3 In the event Licensee prepares a derivative work that is based on or incorporates Python 1 6 1 or any part thereof and wants to make the derivative work available to others as provided herein then Licensee hereby agrees to include in any such work a brief summary of the changes made to Python 1 6 1 4 CNRI is making Python 1 6 1 available to Licensee on an AS IS basis CNRI MAKES NO REPRESENTATIONS OR WARRANTIES EXPRESS OR MPLIED BY WAY OF EXAMPLE BUT NOT LIMITATION CNRI MAKES NO AND DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1 6 1 WILL NOT NFRI
360. r socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure Use login paths from your my login cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt max position lt position gt Used to detect slave delay The maximum difference between the master s log position and the slave s reported read position of the master A value greater than this means the slave is too far behind the master Default 0 pedantic p Used to stop failover if some inconsistencies are found such as errant transactions on slaves or SQL thread errors during server checks By default the utility only generates warnings if issues are found when checking a slave s status during failover and it will continue its execution unless this option is specified 127 OPTIONS pidfile lt pidfile gt Pidfile for running mysql failover as a daemon This file contains the PID process identifier that uniquely identifies
361. rable to put the old master back in the replication topology Objectives The goal of this task is simply to replace the new master of a replication topology with the previous one that might have been demoted as result of successful automatic failover execution due to some failure It is assumed that the server to be restored as master is healthy and any previous issue that triggered failover have been resolved Let s consider the previous topology after failover now with a new master server2 3312 and three slaves Server3 3313 server4 3314 server 3315 and that we want to promote the initial server server1 3311 to master again Perform this task manually can be delicate as one wrong or missing step can lead to errors and incorrect replication topology or even to the lost of some transaction Once more MySQL Utilities can provide a precious assistance to perform this task in this case requiring the user to follow three simple steps to restore the initial topology as shown below Example Execution There are several steps involved in solving this problem We walk through each in turn You must first stop running the mysql failover utility instance and start the old master to be restored i e server1 3311 Next set the old master Server1 3311 as a slave of the current new master server2 331 2 shell gt mysqlreplicate master root server2 3312 slave root server1 3311 rpl user rpl rpl master on localhost connecte
362. rage Engine 17 3 2 4 How Can Tell If a Table on Server X has the same Structure as the Same Table ON SSIVER EE E E A Ved ida nc E dha weve Puente devel ee AAT 19 3 2 5 How Can Synchronize a Table on Two Servers Where Neither is Up to date 20 3 3 General Operations 2 2 0 0 cece cece cece cece ee eet teers eee cece eae ener anes sede adaateeeeeeeseaaaaaaneeeeeeeeeaea 21 3 3 1 How Can Find Out How Much Space My Data Uses accer 21 3 3 2 My Server Crashed Need to Know the Structure of a Table How Can Do That sees vivian Malden aia hand tiga ira ac te ea 22 3 3 3 Creating a New User With The Same Privileges as Another User eeeee 24 3 3 4 What Options Are Used With Each Utility 0 cece eeee cece ee aeeneeeeeeeeeeeeaeaaeeees 25 3 3 5 I ve Got Too Many Indexes How Do Know Which Ones to Drop scce 28 3 3 6 Need to Find an Object on My Server But All Have is a Partial Name How Do Find All Objects with That Name Prefix 0 ccccceceeeaeceeeeeeeeeeeeeaeaaeaeeeeeeeeeeaeaaaaeenees 29 3 3 7 How Can I Run a Process Every Night To Kill Certain Connections 05 30 3 4 High Availability Operations 20 0 0 cece cece cece cece ee eee eeeee ener esse ae aa ee teeeeeeeeeaeaaeaaeeeeeeeeeaeaaaaeenees 31 3 4 1 How Can Use Replication 2 0 0 0 cecccccecceeeeeeeeee cece aa eeeeeeeeeeeeaaaaeeeeseeeeeeaeaaeaaes 32 3 4 2 How Do Add New Servers to My Topology and Change Master
363. rd priv_test_user priv_test_user2 priv_test_user3 on 6 on 6 Wiel bese E joe user joe_wildcard priv_test_user priv_test_user2 priv_test_user3 Wesipes tos joe user joe_wildcard privi test userei priv_test_user2 priv_test_user3 e Eeee a 21 joe user joe_wildcard priv_test_user 3 priv_test_user2 privi test usero 0u iitiealll seecie aA pIE joe user joe_wildcard priv_test_user 3 priv_test_user2 priv_test_user3 oe done ALL PRIVI ALL ALL PRIVI ALL PRIVI ALG PRIVI ALL PRIVILEGES ALL PRIVILEGES GRANT OPTION ALTER ROUTINE DELETE DROP LEGES PRIVILEGES GRANT OPTION DELETE DROP LEGES ALL PRIVILEGES GRANT OPTION DELETE DROP LEGES ALL PRIVILEGES GRANT OPTION DELETE DROP LEGES ALL PRIVILEGES GRANT OPTION VILEGES VILEGES EXECUTE ALL PR ALL PR EXECUTE EXECUTE ALL PR ALL PRIVILEGES VILEGES EXECUTE SELECT TRIGGER UPDATE GRANT OPTION TRIGGER UPDATE SELECT TRIGGER UPDATE SELECT UPDATE TRIGGER UPDATE SELECT TRIGGER UPDATE SELECT UPDATE SELECT TRIGGER UPDATE GRANT OPTION GRANT OPTION TRIGGER UPDATE Show the grantees and respective SQL grant statements over a list of objects shell gt mysqlgrants server user pass localhost 3310 show raw util_tes
364. re e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket e Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt ssl ca The path to a file that contains a list of trusted SSL CAs ssl cert The name of the SSL certificate file to use for establishing a secure connection 98 NOTES e ssl cert The name of the SSL key file to use for establishing a secure connection e ssl Specifies if the server connection requires use of SSL If an encrypted connection cannot be established the connection attempt fails Default setting is 0 SSL not required verbose v Specify how much information to display Use this option multiple times to increase the amount of information For example v verbose vv more verbose vvv debug e version Display version information and exit NOTES You must provide connection parameters user host password and so forth for an account that has the appropriate privileges to access all objects in the operation On the source to copy all objects from the database the user must have these privileges SELECT for tables SHOW VIEW for views EVENT for events and TRIGG
365. re no default values except on Posix systems when specifying a socket In this case the host option defaults to localhost This means that combining the values specified in the login path with the two optional values port and socket one needs to specify at least a user a hostname and a port or socket Use the mysql_config_editor tool http dev mysql com doc en mysql config editor html to add the connection information as follows shell gt mysql_config_editor set login path instance_13001 host localhost user root port 13001 pass Enter password lt Password is prompted to be inserted in a more secure way gt Next use the following command to confirm that the login path data was correctly added to mylogin cnf the encrypted file shell gt mysql_config_editor print login path instance_13001 instance _13001 user root password x host localhost port 13001 Connection Parameters Once your mylogin cnf file is configured you need only specify the section of the mylogin cnf file for the server connection For example the section created in the previous example is instance_13001 Thus we use server instance_13001 The following shows the execution of a utility specifying the login path section shell gt mysqlserverinfo server instance_13001 format vertical Source on localhost connected kkxkxkxkxkxkxkkkkkkkkkkkkkkkkxkx k e row kkxkxkxkxkxkxkkkkkkkxkxkkkkkkkkxkxx k server loca
366. read access to the audit log file on the server Tips and Tricks The policy value was specified using uppercase in this example however upper and lower cases can be mixed to specify the policy value such as LoGiNs The values for this command will still be read correctly independently of the used cases case insensitive but if an unsupported value is specified an error will be issued In the above example the show options option was additionally used but it is not required This option simply displays the audit log settings variables However when this option is combined with a command that changes one of the audit log variables it display the audit log settings before and after the execution of the command which can be very handy to confirm that the desired change was performed as expected 3 6 2 How Do Copy Move The Audit Log The audit log information can grow quickly and considerably depending on the type of information written to the audit log files and the activity of the MySQL server Therefore it might be a good idea to copy the audit log files to a different location and free some storage on the server The mysqlauditadmin utility also provides this useful functionality Objectives The goal of this task is to copy an existing audit log file to a different location using the mysqlauditadmin utility It is assumed that the utility is executed on the destination host which must be a non Windows system with the scp Sec
367. release 1 5 0 Example lt configuration file path gt lt section gt e Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt max position lt position gt Used to detect slave delay The maximum difference between the master s log position and the slave s reported read position of the master A value greater than this means the slave is too far behind the master Default 0 new master lt connection gt Connection information for the slave to be used to replace the master for switchover Valid only with switchover command To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt e Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket
368. rgument is treated as a connection specifier not as a pattern regexp basic regexp G Perform pattern matches using the REGEXP operator The default is to use LIKE for matching This affects the database and pattern options server lt source gt Connection information for a server Use this option multiple times to search multiple servers To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure Use login paths from your my login cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt sql print sql p Print rather than executing the SQL code that would be executed to find all matching objects This can be useful to save the statement for later execution or to use it as input for other programs ssl ca 149 NOTES The path to a file th
369. ribution of Your modifications or for any such Derivative Works as a whole provided Your use reproduction and distribution of the Work otherwise complies with the conditions stated in this License 5 Submission of Contributions Unless You explicitly state otherwise any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License without any additional terms or conditions Notwithstanding the above nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions 6 Trademarks This License does not grant permission to use the trade names trademarks service marks or product names of the Licensor except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file 7 Disclaimer of Warranty Unless required by applicable law or agreed to in writing Licensor provides the Work and each Contributor provides its Contributions on an AS IS BASIS WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied including without limitation any warranties or conditions of TITLE NON INFRINGEMENT MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of p
370. ributor has been advised of the possibility of such damages 9 Accepting Warranty or Additional Liability While redistributing the Work or Derivative Works thereof You may choose to offer and charge a fee for acceptance of support warranty indemnity or other liability obligations and or rights consistent with this License However in accepting such obligations You may act only on Your own behalf and on Your sole responsibility not on behalf of any other Contributor and only if You agree to indemnify defend and hold each Contributor harmless for any liability incurred by or claims asserted against such Contributor by reason of your accepting any such warranty or additional liability END OF TERMS AND CONDITIONS APPENDIX How to apply the Apache License to your work To apply the Apache License to your work attach the following boilerplate notice with the fields enclosed by brackets replaced with your own identifying information Don t include the brackets The text should be enclosed in the appropriate comment syntax for the file format We also recommend that a file or class name and description of purpose be included on the same printed page as the copyright notice for easier identification within third party archives Copyright yyyy name of copyright owner Licensed under the Apache License Version 2 0 the License you may not use this file except in compliance with the License You may obtain a copy of th
371. rmat values are sql grid tab csv and vertical The default is sql locking lt locking gt Choose the lock type for the operation Permitted lock values are no locks do not use any table locks lock all use table locks but no transaction and no consistent read and snapshot consistent read using a single transaction The default is snapshot multiprocess Specify the number of processes to concurrently export the specified databases Special values O number of processes equal to the number of detected CPUs and 1 default no concurrency Multiprocessing works at the database level for Windows and at the table level for Non Windows POSIX systems no headers h Do not display column headers This option applies only for csv and tab output output file Specify the path and file name to store the generated export output By default the standard output is used no file quiet q Turn off all messages for quiet execution 104 OPTIONS regexp basic regexp G Perform pattern matches using the REGEXP operator The default is to use LIKE for matching rpl lt rpl_mode gt replication lt rpl_mode gt Include replication information Permitted values are master make destination a slave of the source server slave make destination a slave of the same master as the source only works if the source server is a slave and both include the master and slave options where applicable rpl file
372. rmats from mysqldbexport mysqldiff e Compare object definitions e Generate a difference report 4 3 General Operations These utilities are those designed to perform general operations such as reporting and searching mysqldiskusage e Show disk usage for databases e Generate reports in SQL CSV TAB Grid Vertical mysqlfrm e Reads frm files optionally in byte by byte diagnostic mode Generates CREATE statements from table definition data mysqlgrants e Displays grants per object e Produce reports by user user with grants and GRANT statements mysqlindexcheck e Read indexes for one or more tables e Check for redundant and duplicate indexes e Generate reports in SQL CSV TAB Grid Vertical mysqlmetagrep e Search metadata Regexp database search e Generate SQL statement for search query mysqlprocgrep Search process information e Generate SQL statement for search e Kill processes that match query mysqluserclone e Clone a user account to the same or different server 60 High Availability Operations e Show user grants mysqluc e Command line client for running MySQL Utilities e Allows a persistent connection to a MySQL Server e Tab completion for utility names and options Allows calling the commands with shorter names such as using serverinfo instead of mysqlserverinfo 4 4 High Availability Operations These utilities are those designed to support replication and high avail
373. roduce prepare Derivative Works of publicly display publicly perform sublicense and distribute the Work and such Derivative Works in Source or Object form 3 Grant of Patent License Subject to the terms and conditions of this License each Contributor hereby grants to You a perpetual worldwide non exclusive no charge royalty free irrevocable except as stated in this section patent license to make have made use offer to sell sell import and otherwise transfer the Work where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution s alone or by combination of their Contribution s with the Work to which such Contribution s was submitted If You institute patent litigation against any entity including a cross claim or counterclaim in a lawsuit alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed 4 Redistribution You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium with or without modifications and in Source or Object form provided that You meet the following conditions a You must give any other recipients of the Work or Derivative Works a copy of this License and b You must cause any modified fi
374. rows Permitted format values are grid csv tab and vertical The default is grid compact Compacts the output by reducing the number of control lines that are displayed in the diff results This option should be used together with one of the following difference types unified or context It is most effective when used with the unified difference type and the grid format quiet q Do not print anything Return only an exit code of success or failure regexp basic regexp G Perform pattern matches using the REGEXP operator The default is to use LIKE for matching run all tests t Do not halt at the first difference found Process all objects server1 lt source gt Connection information for the first server 90 OPTIONS To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt e Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the
375. rtical The default is grid e report indexes r 144 OPTIONS Reports if a table has neither UNIQUE indexes nor a PRIMARY key server lt source gt Connection information for the server To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure Use login paths from your my login cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt show drops d Display DROP statements for dropping indexes show indexes i Display indexes for each table Skip S Skip tables that do not exist ssl ca The path to a file that contains a list of trusted SSL CAs ssl cert The name of the SSL certificate file to use for establishing a secure connection ssl cert The name of the SSL key file to use for establishing a secure connection Ssl Spe
376. rver2 ALTER TABLE dbx table3 DROP COLUMN notes CHANGE COLUMN misc misc char 30 Se Se SE OSE Compare failed One or more differences found 119 PERMISSIONS REQUIRED PERMISSIONS REQUIRED The user must have SELECT privileges for both objects on both servers as well as SELECT on the mysql database 5 11 mysqldiskusage Show Database Disk Usage This utility displays disk space usage for one or more databases The utility optionally displays disk usage for the binary log slow query log error log general query log relay log and InnoDB tablespaces The default is to only show database disk usage If the command line lists no databases the utility shows the disk space usage for all databases Sizes displayed without a unit indicator such as MB are in bytes The utility determines the location of the data directory by requesting it from the server For a local server the utility obtains size information directly from files in the data directory and InnoDB home directory In this case you must have file system access to read those directories Disk space usage shown includes the sum of all storage engine specific files such as the MYI and MYD files for MyISAM and the tablespace files for InnoDB If the file system read fails or if the server is not local the utility cannot determine exact file sizes It is limited to information that can be obtained from the system tables which therefore should be considered an esti
377. rvers that support global transaction identifiers GTIDs and have gt id_mode ON MySQL server versions 5 6 5 and higher support GTIDs See Replication with Global Transaction Identifiers for more information The user can specify the interval in seconds to use for detecting the master status and generating the health report using the interval option At each interval the utility will check to see if the server is alive via a ping operation followed by a check of the connector to detect if the server is still reachable The ping operation can be controlled with the ping option see below If the master is found to be offline or unreachable the utility will execute one of the following actions based on the failover mode option value The available values are 123 mysqlfailover Automatic replication health monitoring and failover auto default Execute automatic failover to the list of candidates first and if no slaves are viable continue to locate a viable candidate from the list of slaves If no slaves are found to be a viable candidate the utility will generate and error and exit Once a candidate is found the utility will conduct failover to the best slave The command will test each candidate slave listed for the prerequisites Once a candidate slave is elected it is made a slave of each of the other slaves thereby collecting any transactions executed on other slaves but not the candidate In this way the candida
378. s 0 SSL not required verbose v Specify how much information to display Use this option multiple times to increase the amount of information For example v verbose vv more verbose vvv debug version Display version information and exit width lt number gt Change the display width of the test report The default is 75 characters You must provide connection parameters user host password and so forth for an account that has the appropriate privileges to access all objects to be compared The SQL transformation feature has these known limitations When tables with partition differences are encountered the utility generates the ALTER TABLE statement for all other changes but prints a warning and omits the partition differences If the transformation detects table options in the source table specified with the changes for option that are not changed or do not exist in the target table the utility generates the ALTER TABLE statement for all other changes but prints a warning and omits the table option differences Rename for events is not supported This is because mysqldiff compares objects by name In this case depending on the direction of the diff the event is identified as needing to be added or a DROP EVENT statement is generated 117 EXAMPLES e Changes in the definer clause for events are not supported e SQL extensions specific to MySQL Cluster are not supported For the difftyp
379. s been simplified with utilities like mysqlreplicate provisioning the slave copying data and getting replication started properly can be a challenge if done manually 14 How Do Provision a Slave Fortunately we have two utilities mysqldbexport and mysqldbimport that have been designed to work with replication so that when the export is generated you can include the proper replication control statements in the output stream Objectives Perform slave provisioning using mysqldbexport and mysqldbimport Example Execution shell gt mysqldbexport server root root localhost 13001 all export both rpl master rpl user rpl shell gt mysqldbimport server root root localhost 13002 data sql Source on localhost connected Importing definitions from data sql ERROR The import operation contains GTID statements that require the global gtid_executed system variable on the target to be empty no value The gtid_executed value must be reset by issuing a RESET MASTER command on the target prior to attempting the import operation Once the global gtid_executed value is cleared you may retry the import shell gt mysql uroot proot h 127 0 0 1 port 13002 e RESET MASTER shell gt mysqldbimport server root root localhost 13002 data sql Source on localhost connected Importing definitions from data sql CAUTION The following 1 warning messages were included in the import file WARNING A partial
380. s for using mysql frm will vary and depend entirely on how you use it If you use the utility to read frm files in a protected folder like the example above in either mode you must have the ability to run the spawned server with privileges that allow you to read the protected files For example you could use a user account that has root level privileges If you use the utility with a server connection the user you use to connect must have the ability to read system variables at a minimum including read access to the mysql database You should never use the root user to spawn the server nor should you use the mysql user when spawning the server or running the utility 5 14 mysqlgrants Display grants by object Managing privileges can be a challenge Sometimes all a DBA needs to know is which users have access to a given list of objects such as a list of databases tables etc This utility allows DBAs to see which users have what level of access for each object listed Objects supported include databases tables functions and procedures The utility follows the grant hierarchy within MySQL displaying global and object level access GRANT statements Note R This utility was added in MySQL Utilities 1 6 0 The utility allows the users to choose among three reports users user_grants and raw e users 137 OPTIONS displays a list of users who have access to the list of objects e user_grants displays a list of users sorted
381. s from the server if not specified in options print Getting databases close if opt dbs_to_copy is None for db in serverl get_all_databases db_list append db 0 None else oe Gla alia Coie Clos ice _ceioy Sjollake 1 1 S db_list append db None Get list of all users from the server print Getting users user_list if opt users_to_copy is None users serverl exec_query SELECT user host FROM mysql user V WHERE user root and user for user in users user_list append user 0 t user 1 else Oe WINS ake Ce cuss iO Ceo Sjollake 1 7 user_list append user Build options options 212 Specialized Operations new_data opt new_data new_port 3 Opt new_port new_id opt new_id root_pass 3 Vege 4 mysqld_options report host localhost report port s opt new_port Clone the server print Cloning server instance CEY res serverclone clone_server conn options except UtilError e print ERROR e errmsg sys exit Set connection values dest_values user conn get user passwd root host conn get host ToOrEY opt new_port unix_socket os path join opt new_data mysql sock Build dictionary of options options vuiste Unreybiey force True print Copying databases CENS dbcopy copy_db conn dest_values db_list options except UtilError e
382. s not associated with the databases being copied Do not copy users with only global privileges Start replication after all of the users are copied makes this example a clone and replicate scale out solution Stop new client connections to the server during the copy 210 Conclusion Conclusion If you find some primitives missing or would like to see more specific functionality in the library or scripts please contact us with your ideas or better still write them yourselves We welcome all suggestions in code or text To file a feature request or bug report visit http ougs mysql com For discussions visit http forums mysql com list php 155 6 2 MySQL Utilities copy_server py sample Copyright c 2010 2013 Oracle and or its affiliates All rights reserved This program is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by the Free Software Foundation version 2 of the License This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details You should have received a copy of the GNU General Public License along with this program if not write to the Free Software Fonadation Wine Sil Prankliia Sie walieely Wwileer Besicom MWA O2ZLIO 1 30a USA This file contains an
383. s not grant permission to use the trade names trademarks service marks or product names of the Licensor except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file 7 Disclaimer of Warranty Unless required by applicable law or agreed to in writing Licensor provides the Work and each Contributor provides its Contributions on an AS IS BASIS WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied including without limitation any warranties or conditions of TITLE NON INFRINGEMENT MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License 8 Limitation of Liability In no event and under no legal theory whether in tort including negligence contract or otherwise unless required by applicable law such as deliberate and grossly negligent acts or agreed to in writing shall any Contributor be liable to You for damages including any direct indirect special incidental or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work including but not limited to damages for loss of goodwill work stoppage computer failure or malfunction or any and all other commercial damages or losses even if such Cont
384. s not more than the seconds behind threshold option At each interval if the discover slaves option was specified at startup and new slaves are discovered the health report is refreshed e gtid Display the master s list of executed GTIDs contents of the GTID variables GLOBAL GTID_EXECUTED GLOBAL GTID_PURGED and GLOBAL GTID_OWNED Thus you can toggle through the four screens by pressing the c key e UUID Display universally unique identifiers UUIDs for all servers e Log This option displays the contents of the log file which only visible if the 10g option is specified This can be helpful to see when failover occurred and which actions or messages were recorded at the time The user interface is designed to match the size of the terminal window in which it is run A refresh option is provided to permit users to resize their terminal windows or refresh the display at any time However the interface will automatically resize to the terminal window on each interval The interface will display the name of the utility the master s status including binary log file position and filters as well as the date and time of the next interval event The interface will also permit the user to scroll up or down through a list longer than what the terminal window permits When a long list is presented the scroll options become enabled The user can scroll the list up with the up arrow key and down with the down arrow k
385. sary privileges to execute the desired utilities 27 I ve Got Too Many Indexes How Do Know Which Ones to Drop 3 3 5 I ve Got Too Many Indexes How Do I Know Which Ones to Drop MySQL allows its users to create several indexes that might be the same duplicate indexes or partially similar redundant indexes in its structure Although duplicate indexes have no advantages there are some cases where redundant indexes might be helpful However both have disadvantages Duplicate and redundant indexes slow down update and insert operations As a result it is usually a good idea to find and remove them Doing this manually would be a time consuming task especially for big databases and that is why there is a utility to automate this type of task mysql indexcheck Objectives Our goal is to use the mysqlindexcheck utility to help us find duplicate and redundant indexes For that we are going to use the following table as an example CREATE TABLE test_db indexchec emp_id gt INT 11 NOT NULL fiscal number alight ALiL name VARCHAR 50 NOT NUL surname VARCHAR 50 NOT job_title VARCHAR 20 hire_date DATE default N birthday DATE default NU PRIMARY KEY emp id KEY UNIQUE KEY idx_unifnumber UNIQUE KEY idx_uemp_id k_test NOT NULL zad d NULL ULL iti idx_fnumber fiscal nomber Jo C fiscal_number emp_id gt KEY idx_full_name name surname
386. se vv more verbose vvv debug e version Display version information and exit NOTES The login user must have the appropriate permissions to execute SHOW SLAVE STATUS SHOW MASTER STATUS and SHOW VARIABLES on the appropriate servers as well as grant the REPLICATE SLAVE privilege The utility checks permissions for the master slaves and candidates at startup Mixing IP and hostnames is not recommended The replication specific utilities will attempt to compare hostnames and IP addresses as aliases for checking slave connectivity to the master However if your installation does not support reverse name lookup the comparison could fail Without the ability to 169 EXAMPLES do a reverse name lookup the replication utilities could report a false negative that the slave is not connected to the master For example if you setup replication using MASTER_HOST ubuntu net on the slave and later connect to the slave with mysqlrplcheck and have the master specified as master 192 168 0 6 using the valid IP address for ubuntu net you must have the ability to do a reverse name lookup to compare the IP 192 168 0 6 and the hostname ubuntu net to determine if they are the same machine Similarly if you use localhost to connect to the master the health report may not show all of the slaves It is best to use the actual hostname of the master when connecting or setting up replication If the user does not specify the
387. se 1 5 0 Example lt configuration file path gt lt section gt e Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt 83 NOTES e verbose V Specify how much information to display Use this option multiple times to increase the amount of information For example v is verbose vv is more verbose vvv is debug level NOTES If the server specified using the server 82 option is a master server and there are slaves connected mysqlbinlogpurge displays an error and does not purge the binary logs that match the criteria specified LIMITATIONS mysqlbinlogpurge cannot verify slaves that are not actively replicating and will stop and show an error if it finds a slave which is not actively replicating from the master EXAMPLES Purge all binary log files not in use from a master specifying the slaves to check shell gt mysqlbinlogpurge master root root localhost 3310 slaves root root localhost 3311 root root localhost 3312 root root localhost 3313 vv exec_util command python u scripts mysqlbinlogpurge py master root root localhost 3310 slaves root 2 root roote localhost 3313 YV Checking user permission to purge binary logs Master active binlog file mysql bin 000021 Checking slave localhost 3311 O thread is currently reading mysql bin 000021 File position of the I O thread
388. ser must have the SELECT CREATE TEMPORARY TABLES and INSERT privileges for the databases being compared on both connections The user must also have SELECT privilege on the mysql database If the binary log is enabled and the disable binary logging option is used the user must also have the SUPER privilege 5 7 mysqldbcopy Copy Database Objects Between Servers This utility copies a database on a source server to a database on a destination server If the source and destination servers are different the database names can be the same or different If the source and destination servers are the same the database names must be different The utility accepts one or more database pairs on the command line To name a database pair use db_name new_db_name syntax to specify the source and destination names explicitly If the source and destination database names are the same db_name can be used as shorthand for db_name db_name By default the operation copies all objects tables views triggers events procedures functions and database level grants and data to the destination server There are options to turn off copying any or all of the objects as well as not copying the data To exclude specific objects by name use the exclude option with a name in db obj format or you can supply a search pattern For example exclude db1 trigi excludes the single trigger and exclude t rig_ excludes all objects from all databases having
389. ser root password pass host localhost ssl ca C newcerts cacert pem ssl cert C newcerts client cert pem ssl key C newcerts client key pem In this case the file is located at C MySQL instance 3307 cnf and by indicating this path and the group name in the server option the options for the mysqiserverinfo of the previous example takes this form shell gt mysqlserverinfo server c MySQL instance 3307 cnf instance_3307 51 How Can I Use a secure encrypted connection between Utilities and a MySQL Server format vertical Source on localhost connected KKKKKEKKKEKKEKKEKKKKKKKAKK KK KK il row KKEKKKKKKKKEKKKKKKKAKKKKKKKK server localhost 3307 GOmirae sea Iles binary_log loalineuay Ilexep joes amp relay_log relay_log_pos version 3 6 15 datadir C MySQL instance_3307 basedir C MySQL mysql 5 6 15 winx64 plugin_dir C MySQL mysql 5 6 15 winx64 lib plugin general_log OFF general_log_file general_log_file_size log_error C MySQL instance_3307 clone err log_error_file_size 1569 bytes slow_query_log OFF slow_query_log_file slow_query_log_file_size 1 row done Discussion The SSL options ssl ca ssl cert and ssl key are available in the MySQL Utilities that requires a connection to a server or servers as is in the case of the master and slave options Utilities can read the values stored in them as mentioned in the Section 2 2 Note R An options file
390. server data new binlog_dir Moving bin llog filles server bin 000001 server bin 000002 server bin 000003 server bin 000004 server bin 000005 server bin 000006 done Move available relay log files from a running slave shell gt mysqlbinlogmove server user pass localhost 3311 log type relay archive slave binlog_dir Moving relay log files slave relay bin 000001 lave relay bin 000002 lave relay bin 000003 lave relay bin 000004 lave relay bin 000005 lave relay bin 000006 lave relay bin 000007 lave relay bin 000008 lave relay bin 000009 lave relay bin 000010 lave relay bin 000011 lave relay bin 000012 lave relay bin 000013 lave relay bin 000014 lave relay bin 000015 lave relay bin 000016 ANNDDAHAAAAAHAAHNHA AAA NUR Flushing relay logs done Move available binary log and relay log files from a running slave skipping the flush step shell gt mysqlbinlogmove server user pass localhost 3311 log type all skip flush binlogs archive slave binlog_dir Moving bin logi files slave bin 000001 slave bin 000002 slave bin 000003 slave bin 000004 slave bin 000005 Moving relay log files slave relay bin 000001 slave relay bin 000002 slave relay bin 000003 slave relay bin 000004 slave relay bin 000005 79 EXAMPLES lave relay bin 000006 lave relay bin
391. ses of this License Derivative Works shall not include works that remain separable from or merely link or bind by name to the interfaces of the Work and Derivative Works thereof Contribution shall mean any work of authorship including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner For the purposes of this definition submitted means any form of electronic verbal or written communication sent to the Licensor or its representatives including but not limited to communication on electronic mailing lists source code control systems and issue tracking systems that are managed by or on behalf of the Licensor for the purpose of discussing and improving the Work but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as Not a Contribution Contributor shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work 2 Grant of Copyright License Subject to the terms and conditions of this License each Contributor hereby grants to You a perpetual worldwide non exclusive no charge royalty free irrevocable copyright license to rep
392. side comments for later examination If you specify the rp1 file option the utility writes the replication statements to the file specified instead of including them in the export stream If you attempt to export databases on a server with GTIDs enabled GTID_ MODE ON a warning will be generated if the export does not include all databases This is because the GTID statements generated include the GTIDs for all databases and not only those databases in the export The utility will also generate a warning if you export databases on a GTID enabled server but use the skip gtid option To make the most use of GTIDs and export import you should export all of the databases on the server with the a11 option This will generate an export file with all of the databases and the GTIDs executed to that point Importing this file on another server will ensure that server has all of the data as well as all of the GTIDs recorded correctly in its logs OPTIONS mysqldbexport accepts the following command line options e help Display a help message and exit e license Display license information and exit e bulk insert b Use bulk insert statements for data e character set lt charset gt Sets the client character set The default is retrieved from the server variable character_set_client 103 OPTIONS comment rpl Place the replication statements in comment statements Valid only with the rp1 option display lt
393. slave To get the state of the slave threads use the verbose option Permissions Required The user connected to the master must have the REPLICATION SLAVE privilege The user specified with the discover slaves login option that logs into each slave must have the REPLICATION CLIENT privilege Tips and Tricks You can also display multiple tiered topologies by providing the recurse option Notice in the example we used the option discover slaves login This is a shortcut feature built into every utility If you type the first N letters of a utility that uniquely identifies it among the options for said utility the utility accepts it as if you typed the entire string For example the full name of the option we used is discover slaves login 3 4 6 How To Check If Data Is Correctly Replicated Once the replication system is setup and running it is not uncommon that one might want to verify if the data is being correctly replicated on the slaves In normal circumstances the same data is expected on the master and its slaves excluding the use of filtering rules Nevertheless faults at the data level can introduce inconsistent changes on servers without raising any kind of error These data inconsistencies can result from bugs hardware malfunction human errors or unauthorized access It is desirable to detect these issues in order to fix them and ultimately prevent them from happening again Determining the cause of such
394. slaves threads using a single command Objectives Show a map of the slaves connected to a master including the state of each slaves threads IO and SQL We can do this with a single command using the mysql rp1show utility Example Execution shell gt mysqlrplshow master root root localhost 13001 disco root root verbosity master on localhost connected Finding slaves for master localhost 13001 Replication Topology Graph localhost 13001 MASTER ee localhost 13002 10s Yes SOL Yes SLAVE ee locale sic 13003 IO Yes SOL Yes SLAVE M localhost 13004 I0 Yes SQL Yes SLAVE 41 How To Check If Data Is Correctly Replicated lhecallingsteciSO0S IOs Wes SOL Wes SLAVE Discussion Notice the use of the mysql rplshow utility Not only did it show us the slaves attached to the master it also displayed the state of the IO and SQL thread for each slave We used the master server for the master option but for the slaves we provided the option discover slaves login which provides the user name and password for the account used to connect to each slave Without this we would not be able to determine if the slave is attached currently or the state of its threads The discover slaves login option applies to all slaves If you do not have the same user defined on all of your slaves you can use the prompt option to prompt for the user and password for each
395. sm with login paths This will allow the utility to use the my_print_defaults tools which is required to read the login path values from the login configuration file mylogin cnf EXAMPLES To check the prerequisites of a master and slave that currently are actively performing replication use the following command shell gt mysqlrplcheck master root host1 3310 slave root host2 3311 master on hostl connected slave on host2 connected Test Description Status Checking for binary logging on master pass Are there binlog exceptions pass Replication user exists pass Checking server_id values pass Is slave connected to master pass Check master information file pass Checking InnoDB compatibility pass Checking storage engines compatibility pass Checking lower_case_table_names settings pass Checking slave delay seconds behind master pass done As shown in the example you must provide valid login information for both the master and the slave To perform the same command but also display the contents of the master information file on the slave and the values of SHOW SLAVE STATUS as well as additional details use this command shell gt mysqlrplcheck master root host1 3310 slave root host2 3311 show slave status vv master on hostl connected 176 EXAMPLES slave on host2 connected Test Description SECICUS Checking for binary logging on master Are there b
396. specify these with the xec before and xec after options The return code of the script is used to determine success thus each script must report 0 success to be considered successful If a script returns a value other than 0 the result code is presented in an error message The utility also permits the user to specify a script to be used for detecting a downed master or an application level event to trigger failover This can be specified using the xec fail check option The return code for the script is used to invoke failover A return code of 0 indicates failover should not take place A return code other than 0 indicates failover should take place This is checked at the start of each interval if a script is supplied The timeout option is not used in this case and the script is run once at the start of each interval The utility permits the user to log all actions taken during the commands The 10g option requires a valid path and file name of the file to use for logging operations The log is active only when this option is specified The option 1og age specifies the age in days that log entries are kept The default is seven 7 days Older entries are automatically deleted from the log file but only if the 10g option is specified The format of the log file includes the date and time of the event the level of the event informational INFO warning WARN error ERROR critical failure CRITICAL and the message repor
397. st DROP DATABASE IF EXISTS util_test CREATE DATABASE util_test USE wihil best TABLE utalstest stl CREATE TABLE El a char 30 DEFAULT NULL ENGINE MEMORY DEFAULT CHARSET latinl dones Source on localhost connected USE whil test Exporting data from util_test Data for table wkil_ test tl NSERT INTO util_test t1 VALUES O01 Test Basic database example NSERT INTO util_test t1 VALUES 02 Test Basic database example NSERT INTO util_test t1 VALUES 03 Test Basic database example NSERT INTO util_test t1 VALUES 04 Test Basic database example r yos r r NSERT INTO util_test t1l1 VALUES 05 Test Basic database example NSERT INTO util_test tl1 VALUES 06 Test Basic database example NSERT INTO util_test t1 VALUES 07 Test Basic database example doner r r Connecting to the current server s master CHANGE MASTER TO MASTER_HOST localhost MASTER_USER rpl MASTER_PASSWORD rpl MASTER_PORT 3310 MASTER_LOG_FILE clone bin 000001 MASTER_LOG_POS 1739 Starting slave START SLAVE PERMISSIONS REQUIRED The user must have permission to read all databases Since we are using the root account for these examples and you typically would permissions are not generally a problem 5 9 mysqldbimport Import Object Definitions or Data into a Database This utility imports metadata object definitions or data or both for one or more da
398. st1 ioe Vecihi Ve Mase GRANT SHE CRONE idols TOM Usallivawawhost2s ePIC Once PRIVILEGES REQUIRED This utility requires the SELECT privilege on the mysql database 5 15 mysqlindexcheck Identify Potentially Redundant Table Indexes This utility reads the indexes for one or more tables and identifies duplicate and potentially redundant indexes To check all tables in a database only specify the database name To check a specific table name the table in db table format It is possible to mix database and table names You can scan tables in any database except the internal databases mysql INFORMATION_SCHEMA and performance_schema Depending on the index type the utility applies the following rules to compare indexes designated as idx_a and idx_b e BTREE idx_b is redundant to idx_a if and only if all the columns from idx_b are a prefix of idx_a Order and uniqueness count e HASH idx_a and idx_b are redundant if they are duplicates i e if and only if they contain the same columns in the same order e SPATIAL idx_a and idx_b are duplicates if and only if they contain the same column only one column is permitted 143 OPTIONS e FULLTEXT idx_b is redundant to idx_a if and only if all columns in idx_b are included in idx_a Order does not count To see DROP statements drop redundant indexes specify the show drops option To examine the existing indexes use the verbose option which
399. started but using force as initially shell gt mysqlfailover master root server1 3311 slaves root server2 3312 root server3 3313 root server4 3314 server5 3315 log log txt rpl user rpl rpl force Checking privileges MySQL Replication Failover Utility Failover Mode auto Next Interval Sat Jul 27 02 17 12 2013 Master Information Binary Log File Position Binilog_Do_DB Binlog_Iignore_DE master bin 000002 151 GTID Executed Set None Replication Health Status 4 4 4 host port role state gtid_mode health 4 4 4 4 serverl SSalal MASTER UP ON OE server2 Sale SLAVE UP ON OE server3 Ssjabs SLAVE UP ON OK server4 S34 SLAVE UP ON OK server5 3315 SLAVE UP ON ORK 4 4 4 4 Q ewit R nereesia ESlneellela C CTID Liste U WWUDS L log emcees Discussion In reality the main and most important step is the execution of the switchover command with the mysqlrpladmin utility The previous steps can be seen as a preparation for switchover The first step simply makes sure that the server is running and that there is no mysql failover instance still running that could affect the correct execution of switchover The second step sets the old master as a slave of the
400. ster option to specify the existing master and either the s laves option to list all of the slaves in the topology or the discover slaves login option to provide the user name and password to discover any slaves in the topology that are registered and connected to the master The options required for switchover include the master option to specify the existing master the new master option to specify the candidate slave the slave to become the new master and either the s laves option to list the considered slaves in the topology or the discover slaves login option to provide the user name and password to discover any slaves in the topology that are registered and connected to the master The failover command requires only the slaves option to explicitly list all of the slaves in the topology because it is expected that the master is down when this command is used Note E The option to pass in slaves without also passing in master was added in MySQL Utilities 1 6 0 Use the verbose option to see additional information in the health report and additional messages during switchover or failover OPTIONS mysqlrpladmin accepts the following command line options e help Display a help message and exit e license Display license information and exit candidates lt candidate slave connections gt Connection information for candidate slave servers for failover Valid only with failover command List
401. sting that contains the appropriate ALTER commands to conform the object definitions for the object pairs specified If a transformation cannot be formed the utility reports the diff of the object along with a warning statement See important limitations in the NOTES section 114 OPTIONS To specify how to display the diff styled output use one of the following values with the difftype option e unified default Display unified format output context Display context format output e differ Display differ style format output sql Display SQL transformation statement output The changes for option controls the direction of the difference by specifying the object to be transformed in either the difference report default or the transformation report designated with the difftype sql option Consider the following command shell gt mysqldiff serverl root host1 server2 root host2 difftype sql db1 tablel dbx table3 The leftmost database di1 exists on the server designated by the server1 option host 1 The rightmost database dbx exists on the server designated by the server2 option host 2 changes for server1 Produces output that shows how to make the definitions of objects on server1 like the definitions of the corresponding objects on server2 changes for server2 Produces output that shows how to make the definitions of objects on server2 like the definitions of the
402. sum for server localhnost03212 Checking ti table data OK test_rplsync cb ti checksum for server localhost iiie OK test_rplsyic cb tl checksum for server localhnosta32i2 Checking test_db database Checking 0 table data OK test db 0 checksum for server localhost iii OK cestodo 0 checksum for server localhost G 33i12 Checking til table data OK cest db 11 checksum for server localhost Hik OK testdo 1 checksum for server localhost 33i2 done SUMMARY No data consistency issue found To check the data consistency on an active replication system but only between specific slaves 186 EXAMPLES shell gt mysqlrplsync slaves rp1 pass localhost 3311 rpl pass localhost 3312 Checking data consistency Using Slave localhost 3311 as base server for comparison Checking test_rplsync_db database Checking C0 table data OK test rplisync db C0 checksum for server localhost 3312 Checking tl table data OK test_rplsync_do tl checksum for server localhost 3al2 Checking test_db database Checking C0 table data OK test db t0 checksum for server localhost 3312 Checking tl pable data OK test db tl checksum for server localhost 3312 done SUMMARY No data consistency issue found To check the data consistency of a specific database a
403. supplemental regulations As such use duplication disclosure modification and adaptation of the programs including any operating system integrated software any programs installed on the hardware and or documentation shall be subject to license terms and license restrictions applicable to the programs No other rights are granted to the U S Government Legal Notices This software or hardware is developed for general use in a variety of information management applications It is not developed or intended for use in any inherently dangerous applications including applications that may create a risk of personal injury If you use this software or hardware in dangerous applications then you shall be responsible to take all appropriate fail safe backup redundancy and other measures to ensure its safe use Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this software or hardware in dangerous applications Oracle and Java are registered trademarks of Oracle and or its affiliates Other names may be trademarks of their respective owners Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International Inc AMD Opteron the AMD logo and the AMD Opteron logo are trademarks or registered trademarks of Advanced Micro Devices UNIX is a registered trademark of The Open Gr
404. supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt 179 OPTIONS e Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt e Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt max depth lt N gt The maximum recursion depth This option is valid only if recurse is given num retries lt num_retries gt n lt num_retries gt The number of retries permitted for failed slave login attempts This option is valid only if prompt is given prompt p Prompt for the slave user and password if different from the master user and password If you give this option the utility sets num ret ries to 1 if that option is not set explicitly This ensures at least one attempt to retry and prompt for the user name and password should a connection fail quiet q Turn off all messages for quiet execution This option does not suppress errors or warnings recurse r Traverse the list of slaves to find additional master slave connections User this option
405. t Name of script to execute before failover or switchover Script name may include the path force Ignore prerequisite checks or any inconsistencies found such as errant transactions on the slaves or SQL thread errors thus forcing the execution of the specified command This option need to be used carefully as it will not solve any detected issue but only ignores them and displays a warning message format lt format gt f lt format gt Display the replication health output in either grid default tab csv or vertical format log lt log_file gt Specify a log file to use for logging messages log age lt days gt Specify maximum age of log entries in days Entries older than this will be purged on startup Default 7 days master lt connection gt Connection information for the master server To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt 167 OPTIONS e Use a configuration file unencrypted not visible Note available in
406. t binary log file to not purge mysqlbinlogpurge displays the list of binary log files that were purged Use the verbose 84 option to see a list of the remaining available binary log files on the server and to display additional information when mysqlbinlogpurge executes such as status of the I O and SQL threads of each slave OPTIONS mysqlbinlogpurge provides the following command line options version Show the program s version number e help Display the help message bin log index lt binlog_index gt Show the program s license Server lt server_connection gt Connection information for the server To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket e Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt
407. t effectively skipping them This option is useful to verify if the correct transactions will be skipped e gtid set lt gtid set gt Set of Global Transaction Identifiers GTID to skip e help Display a help message and exit e license Display license information and exit e slaves lt slaves_connections gt Connection information for slave servers List multiple slaves in comma separated list To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket e Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt e Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt 196 NOTES e ssl ca The path to a file that contains a list of trusted SSL CAs e ssl cert The name of the SSL certificate file to use for establishing a secure connection e ssl key The name of the SSL key fi
408. t is best to use the actual hostname of the master when connecting or setting up replication The utility will check to see if the slaves are using the option master info repository TABLE If they are not the utility will stop with an error The path to the MySQL client tools should be included in the PATH environment variable in order to use the authentication mechanism with login paths This will allow the utility to use the my_print_defaults tools which is required to read the login path values from the login configuration file mylogin cnf The console creates a special table in the mysql database that is used to keep track of which instance is communicating with the master If you use the force option the console will remove the rows in this table The table is constructed with CREATE TABLE IF NOT EXISTS mysql failover_console host char 30 port char 10 When the console starts a row is inserted containing the hostname and port of the master On startup if a row matches these values the console will not start If you use the force option the row is deleted When running the utility using the daemon nodetach option the pidfile option can be omitted It will be ignored if used When using the external scripts the following parameters are passed in the order shown For example suppose you have a script named run_before sh and you specify that you want it executing before the failover is performed usin
409. t list of object types that can be searched for example options and help texts mysql utilities command grep OBJECT_TYPES Classes class mysql utilities command grep ObjectGrep pattern database_pattern None types OBJECT_TYPES check_body False use_regexp False Search MySQL server instances for objects where the name or content for routines triggers or events matches a given pattern sql string Return the SQL code for executing the search in the form of a SELECT statement Returns SQL code for executing the operation specified by the options Return type string execute connections output sys output connector mysql connector Execute the search on each of the connections in turn and print an aggregate of the result as a grid table Parameters connections Sequence of connection specifiers to send the query to output File object to use for writing the result connector Connector to use for connecting to the servers 6 3 2 mysql utilities command proc Search Processes on Servers This module searches processes on a server and optionally kills either the query or the connection for all matching processes Processes are matched by searching the fields of the INFORMATION_SCHEMA PROCESSLIST table which is available only for servers from MySQL 5 1 7 and later Internally the module operates by constructing a SELECT statement for finding matching processes and then
410. t to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket e Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt daemon lt command gt Run as a daemon The command can be start start daemon stop stop daemon restart stop then start the daemon or nodetach start but do not detach the process This option is only available for POSIX systems discover slaves login lt user password gt At startup query master for all registered slaves and use the user name and password specified to connect Supply the user and password in the form lt user gt lt passwa gt or lt ogin path gt For example discover joe secret will use joe as the user and secret as the password for each discovered slave exec after lt script gt Name
411. t util_test t3 util_test t2 util _test tl util_test pl util_test f1l DATABASE GRANT ALL PRIVILEGES ON GRANT ALL PRIVILEGES ON GRANT EXECUTE GRANT GRANT SELECT UPDATE GRANT DROP GRANT EXECUTE GRANT GRANT Ubi est For joe user oy For joe_wildcard o For For priv_test_user2 For priv_test_user3 EXECUTE o FOr For priv_test_user2 vor priv _testlusers priv_test_user TRiCCHR ON Util tese ia Om priivmcestmusers NGuita SELECD UPDATE ON k TOs privetestauser G 3 TRIGGER ON gt gt priv_test_user TRIGGER ON util_test TO priv_test_user SELECT UPDATE ON TO privitestlouser 3 L INSERT DELETE CREATE DROP GRANT SELECT UPDATE Wal est TO Uhl test 10 on 6 or GRANT UPDATE DELETE ALTER ROUTINE ON TABLE Weal tes tl For joe user GRANT ALL PRIVILEGES ON util_test gt TO Por joe wildcard 0 s GRANT ALL PRIVILEGES ON util_test gt TO on on 6 TO priv test user Cik Due esta mo TOPIV test Usero NaNe REFERENCES joe user ov jJoe_wildcard s oy joe user ov joe_wildcard 140 WITH GRANT INDEX ALTER CREATE VIEW SHUTDOWN EXECUTE ON TO priv_test_user2 s WITH GRANT OPTION SHUTDOWN EXECUTE ON TO priv_test_user2 3 OPTION SHOW VIEW TRIGGER
412. t util_test t3 util_test t2 util_test t1 util_test pl util_test f1 WARNING EXECUTE does not apply to tables and will be ignored for util_test t2 util_test t3 anc WARNING INSERT and SELECT do not apply to routines and will be ignored for util_test f1 and util_t DATABASE util_test TABLE util test tl priv test uger2 6 3 TWAIN ieall jeeste EZ s TABLED eiealll jeecie ies s ROUEN CeeS SE ieil s 142 PRIVILEGES REQUIRED priv_test_user priv_test_user2 ROUTINE Geil test 2 pls priv_test_user S priv_test_user2 priv_test_user3 done The following command will show all of the grants for users that have access to any object in the db1 database by passing in the inherit level option shell gt mysqlgrants server localhostl1 db1l inherit level object show raw Source on localhost connected df Aen elol ee toll T For joel Vingsie il GRANGE IUNSinea OI teloil ielailil Wor Yj e EG inosie i done The following command will show all of the grants for users that have access to the db1 database by passing in the inherit level option shell gt mysqlgrants server localhost1 db1 inherit level database show raw Source on localhost connected TNR GLIE ile il 2 For joe e host GRANT INSERT ON T CEI M CoN TO joe ho
413. tabases from one or more files If an object exists on the destination server with the same name as an imported object it is dropped first before importing the new object To skip objects by type use the skip option with a list of the objects to skip This enables you to extract a particular set of objects say for importing only events by excluding all other types Similarly to skip creation of UPDATE statements for BLOB data specify the skip blobs option To specify the input format use one of the following values with the format option These correspond to the output formats of the mysqldbexport utility sql default Input consists of SQL statements For definitions this consists of the appropriate CREATE and GRANT statements For data this is an INSERT statement or bulk insert if the bulk insert option is specified 109 OPTIONS grid Display output in grid or table format like that of the mysql client command line tool e cSV Input is formatted in comma separated values format raw_csv Input is a simple CSV file containing uniform rows with values separated with commas The file can contain a header the first row that lists the table columns The option table is required to use this format tab Input is formatted in tab separated format vertical Display output in single column format like that of the G command for the mysq1 client command line tool To indicate that input
414. table for given database to perform table level operations tools get_tool_path Search for MySQL tool and return its full path delete_directory Remove directory folder and contents user parse_user_host Parse user passwd host port from User user passwd host Clone user and its grants to another user and perform user level operations 206 General Interface Specifications and Code Practices General Interface Specifications and Code Practices The MySQL Utilities are designed and coded using mainstream coding practices and techniques common to the Python community Effort has been made to adhere to the most widely accepted specifications and techniques This includes limiting the choice of libraries used to the default libraries found in the Python distributions This ensures easier installation enhanced portability and fewer problems with missing libraries Similarly external libraries that resort to platform specific native code are also not used The class method and function signatures are designed to make use of a small number of required parameters and all optional parameters as a single dictionary Consider the following method def do_something_wonderful position objl obj2 options Does something wonderful A fictional method that does something to object 2 based on the location of something in object 1 position in Position in oo 7 oan sui First object to manipulate obj2 in Second object to manipulat
415. te becomes the most up to date slave elect This mode is the same as auto except if no candidates specified in the list of candidate slaves are viable then it does not check the remaining slaves and instead generates an error and then exits fail This mode produces an error and does not failover when the master is downed This mode is used to provide periodic health monitoring without the failover action taken For all options that permit specifying multiple servers the options require a comma separated list of connection parameters in the following form where the password port and socket are optional Slee gt lt lt joassiuvel gt C lt Inogie gt e lt jewiaie S lt Soclkeie or lt lt leen paa gt g lt jsiowie S lt SoOe lkeeic The utility permits users to discover slaves connected to the master In order to use the discover slaves feature all slaves must use the report host and report port startup variables to specify the correct hostname and port of the slave If these are missing or report the incorrect information the slave s health may not be reported correctly or the slave may not be listed at all The discover slaves feature ignores any slaves to which it cannot connect The discover slaves feature is run automatically on each interval The utility permits the user to specify an external script to execute before and after the switchover and failover commands The user can
416. te the file to the remove location Tips and Tricks The name of the audit log file audit 10g by default is defined by the audit_log_file variable displayed by mysqiauditadmin when using the show options option Existing audit log files have a timestamp extension except the one that is currently in use That being said it might be useful to know that it is possible to get information about the existing audit log files using mysqirpladmin for instance to determine which files need to be copied To get this information use the file stats option and the audit log name option specifying the full path of the current audit log file i e without the timestamp extension For example shell gt mysqlauditadmin file stats audit log name MySQL SERVER data audit log 4 4 4 4 File Size Created Last Modified jee S SS SS SSS SS SS SS SS SSS SSS SSS SS SS pee SSS SSses hp re rr nnn 4 audit log IsTss70Gl Saisze7 AVLE man Awg hos eer 20L man Hwg heres 0RR E amene silos 6062 A 2 A 2003 Tha sag A013 emere log 1315S 10405049A s2sl42503 tna Aue 1 be 22329 2003 tna Aag 2 bov22 29 2013 jee S SSS SS SS SS SS SS SS SSS SSS SS SS F sala els ice apa ee sinc esis ales insincie as ames eclosion 4 Note R If an audit log file with the timestamp extensi
417. ted through that system in reliance on consistent application of that system it is up to the author donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License 12 If the distribution and or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries so that distribution is permitted only in or among countries not thus excluded In such case this License incorporates the limitation as if written in the body of this License 13 The Free Software Foundation may publish revised and or new versions of the Lesser General Public License from time to time Such new versions will be similar in spirit to the present version but may differ in detail to address new problems or concerns Each version is given a distinguishing version number If the Library specifies a version number of this License which applies to it and any later version you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation If the Library does not specify a license version number you may choose any version ever
418. ted by the utility The interface provides a number of options for displaying additional information You can choose to view the replication health report default or choose to view the list of GTIDs in use the UUIDs in use or view the log file contents if logging is enabled Each of these reports is described below e health Display the replication health of the topology This report is the default view for the interface By default this includes the host name port role MASTER or SLAVE of the server state of the server UP is connected WARN not connected but can ping DOWN not connected and cannot ping the GTID_MODE and health state 124 mysql failover Automatic replication health monitoring and failover The master health state is based on the following if GTID MODE ON the server must have the binary log enabled and a user must exist with the REPLICATE SLAVE privilege The seconds behind option is used to detect when a slave is behind the master It allows users to set a threshold for reporting purposes only It does not apply to slave candidacy or selection during failover The slave health state is based on the following the IO_THREAD and SQL_THREADS must be running it must be connected to the master there are no errors the slave delay for non GTID enabled scenarios is not more than the threshold provided by the max position and the slave is reading the correct master log file and slave delay i
419. ted to master pass Check master information file pass Checking InnoDB compatibility pass Checking storage engines compatibility pass Checking lower_case_table_names settings pass Checking slave delay seconds behind master FAIL Slave is N seconds behind master done Discussion In the above example we made use of the mysqlreplicate utility to setup a two layer replication topology where the existing server is now the master for the two new servers which will act as slaves Notice how we used the address of the old existing server in the master option and in the slave option we used the addresses of the new servers Also notice the use of the b flag this makes replication start from the first event recorded in the master s binary log Also notice how we used the mysql rplcheck utility to check the health of the replication In this case the failing test Check slave delay is expected since the slaves are catching up with the master When the slaves have read and applied all the transactions from the master s binary log the Check slave delay test will pass Also in case the slave wasn t properly configured and pointing to the master specified the Is slave connect to master test would notify us of that with a FAIL or WARN status Permissions Required As for the required privileges to run these utilities The m_account user needs the following privileges for the mysqlreplicate SELECT and INSERT privileges on
420. ten cancelled rather than interfere with an application Should it happen that you subscribe to this notion and you have a routine that is still being blocked or for some reason hasn t completed by a certain time you need a quick way to generate an event to kill the connection involved This is where the mysqlprocgrep utility can help Objectives The objective is to generate an event that will kill all connections based on a user login msaladin but only if that connection is trying to run a custom administration script named my_admin_thingy Example Execution shell gt mysqlprocgrep sql body match command my_admin_thingy match user msaladin kill connection DECLARE kill_done INT DECLARE kill_cursor CURSOR FOR SELECT Id User Host Db Command Time State Info FROM INFORMATION_SCHEMA PROCESSLIST WHERE COMMAND LIKE my_admin_thingy AND USER LIKE msaladin OPEN kill _ cursor BEGIN DECLARE id BIGINT DECLARE EXIT HANDLER FOR NOT FOUND SET kill_done 1 kill loop LOOP FEICH kill cursor INTO 1d KILL CONNECTION id END LOOP kill_loop END CiOSis leiJLil_cmrs ies Discussion Notice in the example above we did not connect to any server to get this information That is one of the great things about this utility you can generate all manner of SQL statements for finding processes and try them out on a test system before incorporating them into your events triggers and routines We specified the
421. ter a situation where a table or an entire database becomes out of synch We don t simply want to know which rows differ rather we need to know the SQL statements needed to bring the tables into synch Furthermore we aren t sure which table is most out of date so we d like to see the transformation statements for both directions In this case it would be very helpful to know exactly how the tables differ For this we use the mysqldbcompare utility Objectives The goal is to generate the SQL transformation statements to bring two tables into synch Example Execution shell gt mysqldbcompare serverl root root localhost 13001 server2 root root localhost 13002 menagerie a difftype SQL show reverse quiet Checking databases menagerie on serverl and menagerie on server2 Row counts are not the same among menagerie pet and menagerie pet Transformation for changes for serverl1 DELETE FROM menagerie pet WHERE pet_num 10 DELETE FROM menagerie pet WHERE pet_num 12 NSERT INTO menagerie pet pet_num name owner species sex birth death WARIS MIL Wanenlere aAiqineretce ekore Wie TAO a NEA Transformation for reverse changes changes for server2 DELETE FROM menagerie pet WHERE pet_num 11 INSERT INTO menagerie pet pet_num name owner species sex birth
422. th command of the mysqirpladmin utility An alternative set of steps could have been followed to perform the desired task using the failover command from mysqirpladmin instead of switchover In this case the old master should be specified in the candidates list using the option candidates to be chosen as the preferred slave to become the new master no need for the master new master and demote master options However an additional step will be required to set the previous master Server2 3312 as a slave of the old master server1 3311 using the mysqlreplicate utility because failover will not demote the previous master as it assumes that it is not available Notice that unlike switchover that will fail if the server specified by the new master option does not meet the requirements to become master failover will chose another server from the slaves list to become the new master if the one specified in by the candidates option is not suitable It is important to keep this behavior differences in mind when deciding which command to apply 3 4 5 How Can I Find All of the Slaves Attached to My Master Server When you have a topology that has grown over time slaves have been added from time to time it may not be so easy to remember which servers are connected as slaves Most often you want to know the state of those slaves at a glance Rather than connect to each slave individually it would be nice to know what the state of each
423. the Library with the complete machine readable work that uses the Library as object code and or source code so that the user can modify the Library and then relink to produce a modified executable containing the modified Library It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions b Use a suitable shared library mechanism for linking with the Library A suitable mechanism is one that 1 uses at run time a copy of the library already present on the user s computer system rather than copying library functions into the executable and 2 will operate properly with a modified version of the library if the user installs one as long as the modified version is interface compatible with the version that the work was made with c Accompany the work with a written offer valid for at least three years to give the same user the materials specified in Subsection 6a above for a charge no more than the cost of performing this distribution d If distribution of the work is made by offering access to copy 237 GNU Lesser General Public License Version 2 1 February 1999 from a designated place offer equivalent access to copy the above specified materials from the same place e Verify that the user has already received a copy of these materials or that you have already sent this user a copy For an e
424. the connection for all matching processes like the KILL CONNECTION statement kill query Kill the query for all matching processes like the KILL QUERY statement match command lt pattern gt Match all processes where the Command field matches the pattern match db lt pattern gt Match all processes where the Db field matches the pattern match host lt pattern gt Match all processes where the Host field matches the pattern match id lt pattern gt Match all processes where the ID field matches the pattern match info lt pattern gt Match all processes where the Info field matches the pattern match state lt pattern gt Match all processes where the State field matches the pattern match user lt pattern gt Match all processes where the User field matches the pattern print 152 Options Print information about the matching processes This is the default if no kill connection or kill query option is given If a kill option is given print prints information about the processes before killing them regexp basic regexp G Perform pattern matches using the REGEXP operator The default is to use LIKE for matching This affects the match xxx options server lt source gt Connection information for a server Use this option multiple times to search multiple servers To connect to a server it is necessary to specify connection parameters such as user name host name password
425. the database pattern cost to find objects that have cost anywhere in their name We also see the use of the body option to instruct the utility to look inside procedures and functions This can be very handy to locate routines that manipulate data as you can see Notice once we found a routine that had cost mentioned we can examine its body via the SHOW CREATE FUNCTION command to see just how it is using the column cost In this case we see someone has written a function to adjust the cost by 10 Therefore not only can you find objects that have anything named cost you can also discover any hidden logic that may operate on something named cost Permissions Required The user must have the SELECT privilege on the mysql database Tips and Tricks If you are familiar with using regular expressions you can use the regexp option to use regular expressions instead of database patterns For example the regular expression for the search above would be pattern cost basic regex 3 3 7 How Can I Run a Process Every Night To Kill Certain Connections Some database administrators use nightly routines to perform maintenance on their databases or servers Sometimes these routines can be blocked by long running queries or applications that hang onto locks for longer than expected 30 High Availability Operations Naturally priority is given to the application and maintenance routines are of
426. the first difference found Process all objects to find all differences quiet q Do not print anything Return only an exit code of success or failure server1 lt source gt Connection information for the first server To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket e Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt passwad gt lt host gt lt port gt lt socket gt server2 lt source gt Connection information for the second server To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The meth
427. the name of InfoSeek not be used in advertising or publicity pertaining to distribution of the software without specific written prior permission This permission is explicitly restricted to the copying and modification of the software to remain in Python compiled Python or other languages such as C wherein the modified or derived code is exclusively imported into a Python module INFOSEEK CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS IN NO EVENT SHALL INFOSEEK CORPORATION BE LIABLE FOR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE DATA OR PROFITS WHETHER IN AN ACTION OF CONTRACT NEGLIGENCE OR OTHER TORTIOUS ACTION ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE Execution tracing The trace module contains the following notice portions copyright 200 Autonomous Zones Industries Ine ald rights err reserved and offered to the public under the terms of the Python 2 2 license Author Zooko O Whielacronx http zooko com mailto zooko zooko com Copyright 2000 Mojam Media Inc all rights reserved Author Skip Montanaro Copyright 1999 Bioreason Inc all rights reserved Author Andrew Dalke Cepowiengine 19 s LOS7 Muicomeiecis lt eas alll wiles meser veele Author Skip Montanaro Copyright 1991 1995 Stichting Mathematisch
428. the others don t 2 According to Richard Stallman 1 6 1 is not GPL compatible because its license has a choice of law clause According to CNRI however Stallman s lawyer has told CNRI s lawyer that 1 6 1 is not incompatible with the GPL Thanks to the many outside volunteers who have worked under Guido s direction to make these releases possible B TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PYTHON PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 1 This LICENSE AGREEMENT is between the Python Software Foundation PSF and the Individual or Organization Licensee accessing and otherwise using this software Python in source or binary form and its associated documentation 2 Subject to the terms and conditions of this License Agreement PSF hereby grants Licensee a nonexclusive royalty free world wide license to reproduce analyze test perform and or display publicly prepare derivative works distribute and otherwise use Python alone or in any derivative version provided however that PSF s License Agreement and PSF s notice of copyright i e Copyright c 2001 2002 2003 2004 2005 2006 Python Software Foundation All Rights Reserved are retained in Python alone or in any derivative version prepared by Licensee 3 In the event Licensee prepares a derivative work that is based on or incorporates Python or any part thereof and wants to make the derivative work available to others as provid
429. therefore two distinct transaction cannot be applied with the same GTID otherwise an error is issued The mysgqislavetrx utility checks the transactions that can be effectively skipped on each slave at the beginning excluding already executed GTIDs 45 Server Operations Permissions Required The user for the slaves must have the required permissions to inject an empty transaction for a specific GTID i e to set the gt id_next variable More specifically the login user to connect to slaves requires the SUPER privilege Tips and Tricks The mysqislavetrx provides a dry run mode that allows users to verify the GTID that would be skipped in each slave without actually injecting empty transactions The dryrun 196 option must be specified to use this read only mode 3 5 Server Operations The tasks described in this section are those used to perform server wide operations such as cloning a server instance 3 5 1 How Do Make A Temporary Copy of My Server For Testing When diagnosing a problem or needing to experiment with a server for developing new features or test modifications you often need a duplicate of your running server so that you can ensure your solution works for the actual server It would be really convenient if we had a process to make a copy of a running server for such processes Although it is possible and indeed popular to use replication to replicate all of your data to multiple slaves and use one of the sl
430. this utility the test_user needs SELECT privilege on the mysql database as well as for the databases which tables are being checked Tips and Tricks You can use the d option to generate the SQL drop statements needed to remove the indexes The stats option can be used alone or together with either best or worst to show statistics about the indexes Use the show indexes option to show each table together with its indexes 3 3 6 Need to Find an Object on My Server But All I Have is a Partial Name How Do Find All Objects with That Name Prefix One of the challenges for database administrators who manage servers with thousands of objects is the task of finding an object by name Sometimes all you have to go on is the name of a table or perhaps an obscure reference to a partial name This can come about through a diagnosis of a problem connection application or via an incomplete description from a defect report It is also possible you need to simply check to see if certain things exist For example suppose among your databases are parts or inventory data and you want to check to see if there are any functions or 29 How Can I Run a Process Every Night To Kill Certain Connections procedures that operate on a column named cost Moreover you want to see anything related that has cost as part of its name Whatever the case it would be a big time saver if you could search through all of the database objects an
431. those transactions is ce969d18 7b10 11e4 aaae 606720440b68 1 5 Example Execution Execute the mysqislavetrx utility specifying the GTID set of the transaction to skip and the target slaves shell gt mysqlslavetrx gtid set ce969d18 7b10 11e4 aaae 606720440b68 1 5 slaves dba pass slave2 3312 dba pass slave3 3313 WARNING Using a password on the command line interface can be insecure GTID set to be skipped for each server slave2 3312 ce969d18 7b10 1le4 aaae 606720440b68 1 5 slave3 3313 ce969d18 7b10 1le4 aaae 606720440b68 1 5 Injecting empty transactions for slave2s3312 Injecting empty transactions for slaveis 3313 doner Discussion The above example illustrates how to execute the mysqlslavet rx utility to skip the transactions for the specified GTID set on all given slaves To achieve this task we only need to specify the GTID set for the transactions to be skipped with the gtid set 196 option and the list of connection parameters for the target slaves with the slaves 196 option In the above example all of the specific GTIDs were skipped on all target slaves injecting an empty transaction for each one of them However it might happen that some of the GTIDs cannot be skipped on some slaves This can happen if a transaction with the same GTID was previously applied on the target slave The reason is due to the purpose of GTIDs which is to uniquely identify a transaction
432. tilities parser Parse MySQL Log Files Returns Date and time of the last read log entry Return type datetime datetime 218 Chapter 7 MySQL Utilities Testing MUT Table of Contents FA mae MySQL Utilities TeSting sarcinii netinand aana aa a aai aA iaaa 219 7 1 mut MySQL Utilities Testing This utility executes predefined tests to test the MySQL Utilities The tests are located under the mysql test directory and divided into suites stored as folders By default all tests located in the t folder are considered the main suite You can select any number of tests to run select one or more suites to restrict the tests exclude suites and tests and specify the location of the utilities and tests The utility requires the existence of at least one server to clone for testing purposes You must specify at least one server but you may specify multiple servers for tests designed to use additional servers The utility has a special test suite named performance where performance related tests are placed This suite is not included by default and must be specified with the suite option to execute the performance tests OPTIONS mut accepts the following command line options e help Display a help message and exit e do tests lt prefix gt Execute all tests that begin with prefix e force Do not abort when a test fails e record Record the output of the specified test if successful
433. tility See Replication with Global Transaction Identifiers for more information about GTID The utility takes into consideration the use of replication filtering rules on the servers skipping the check for filtered databases and tables according to the defined options Nevertheless the use of replication filters can still lead to data consistency issues depending on how statements are evaluated See How Servers Evaluate Replication Filtering Rules for more information OPTIONS mysqlrplsync accepts the following command line options checksum timeout lt checksum_timeout_in_seconds gt Maximum timeout in seconds to wait for the checksum query to complete Default 3 seconds e discover slaves login lt user_login gt Detect registered slaves at startup and use the user name and password specified to connect in the format lt user gt lt password gt or lt ogin path gt For example discover slaves login joe secret will use joe as the user and secret as the password for each discovered slave e exclude lt databases tables to _exclude gt Fully qualified name for the databases or tables to exclude lt db_name gt lt tb _name gt List multiple data objects in a comma separated list e help 183 OPTIONS Display a help message and exit interval lt interval_in_seconds gt i lt interval_in_seconds gt Interval in seconds for periodically polling the slaves sync status to verify if the sync
434. ting new master as slave Starting slaves Performing START on all slaves Checking slaves for errors Failover complete Failover console will restart in 5 seconds MySQL Replication Failover Utility Failover Mode auto Next Interval Fri Jul 26 LO 25 17 2012 Master Information Binary Log File Position Binlog_Do_DB Binlog_ignore_De master bin 000001 151 GTID Executed Set None Replication Health Status 4 4 4 4 4 4 Nost POLE role state gtid_mode health 4 4 4 4 4 4 server2 S312 MASTER UP ON OK server3 3313 SLAVE UP ON OK server4 SSake SLAVE UP ON OK server5 33I5 SLAVE UP ON OK 4 4 4 4 4 4 O itilic Rorera ieee CEN bista W WUD ec emcees Discussion The above example illustrates how to start the mysql failover utility to check the health of the replication topology and shows the displayed output when failover occurs Basically we simply need to specify the master s connection with the master option the list of slaves with the slaves option and the replication user login and password using the rpl user 37 Restore the Previous Master After Failover options In alternative to the slaves options one can use the discover slaves login s
435. tini which uses 1 byte per character Lets also suppose you are attempting to read a frm file that uses a character set that uses 3 bytes per character Furthermore we have no server to connect In this case the column sizes may be off by a factor of 3 A case in point would be a field such as col_a char 3 would appear in the output of the mysql frm utility as col_a char 9 To mitigate risks such as this and to produce the most accurate CREATE statement in diagnostic mode always use the server option 3 3 3 Creating a New User With The Same Privileges as Another User The MySQL privilege system permits you to create a set of permissions for each user Sometimes the set of permissions are complex and may require multiple GRANT statements to effect Other times the user may acquire privileges over time Regardless of how it came about you may find yourself needing to create a new user that has the same privileges as another user Objectives The goal is to create one or more users whose permissions are identical to an original user on a single server Rather than discover what those privileges are with aSHOW GRANTS FOR statement and copy them into a script modify it copy and paste again for each user etc etc we can use a single command to copy one user to a list of new users We can even set different passwords for each user as we go Let s assume we have a user joe localhost who has a long list of permissions We need to cre
436. tion multiple times to increase the amount of information For example v verbose vv more verbose vvv debug e version Display version information and exit e write command lt file_name gt w lt file_name gt Path name of file in which to write the command used to launch the new server instance EXAMPLES The following command demonstrates how to create a new instance of a running server set the root user password and enable binary logging shell gt mkdir source test123 shell gt mysqlserverclone server root pass localhost new data Users cbell source test123 new port 3310 root password pass mysqld log bin mysql bin Cloning the MySQL server running on localhost Creating new data directory Configuring new instance Locating mysql tools Setting up empty database and mysql tables Starting new instance of the server Testing connection to new instance Success Setting the root password done PERMISSIONS REQUIRED The user must have permission to read all databases Since we are using the root account for these examples and you typically would permissions are not generally a problem You also need permissions to create the new data directory and write data to it 5 25 mysqlserverinfo Display Common Diagnostic Information from a Server 191 OPTIONS This utility displays critical information about a server for use in diagnosing problems Th
437. tion of the most appropriate candidate For example the slave with the best hardware should be in the long run the most appropriate candidate to become the new master but for some unanticipated reason it might actually had less transactions than other servers when the master crashed Therefore a more deterministic criteria based on the order in which the servers are specified is used allowing the user to control the order in which the candidates are selected The first server that will meet the required election criteria consisting on simple sanity checks server reachable and running with the required options GTID ON and binary logging enabled will be chosen More specifically the section of the new master will follow this order first sequentially check the list of servers specified by the candidates option then the servers listed in the s laves option finally check any discovered slave in an unordered way Permissions Required The user must have permissions to configure replication Tips and Tricks In the above example the mysqifailover utility was started in the default console mode but it can also be executed as a daemon For that purpose the daemon option needs to be used more specifically simply add daemon start to the command line When mysql failover is executed as a daemon no output is displayed and all the information is logged to file specified for the 1 og option which is mandatory in this case To stop the exec
438. tion to extending the MySQL Utilities 22 cece eeee cece tees ae eaeeteeeeeeeeeaeaaeneeeeeeees 205 6 2 MySQL Utilities copy_server py sample ccccececeeeeeeeeeeeeeeeeeaaaaeeeeeeeeeeeeaeaaeeneeeeeeeeeaeaaeeaes 211 6 3 Specialized Operations ss sicvecsssc ctl ecdeecsshiciieasseeeeeath aa Eaa aaa increas a Ae aaa aia 213 6 3 1 mysql utilities command grep Search Databases for Objects 0008 213 6 3 2 mysql utilities command proc Search Processes on Servers c ecceee ees 214 0 4 POISONS oa S a a 216 6 4 1 mysql utilities parser Parse MySQL Log Files ccccecceeeeeeeeeeeeeeeeeeeeeeeeeeeeeaeaaes 216 This chapter introduces the architecture for the MySQL Utilities library and demonstrates how to get started building your own utilities 6 1 Introduction to extending the MySQL Utilities Administration and maintenance on the MySQL server can at times be complicated Sometimes tasks require tedious or even repetitive operations that can be time consuming to type and re type For these reasons and more the MySQL Utilities were created to help both beginners and experienced database administrators perform common tasks What are the internals of the MySQL Utilities MySQL Utilities are designed as a collection of easy to use Python scripts that can be combined to provide more powerful features Internally the scripts use the mysql utilities module library to perform its various tasks Since a librar
439. tl checksum for server localhost 3212 Checking t2 table data WARNING Slave not active localhost 3311 Sync skipped OK test rplsync db m C2 checksum for server localhost 3211 OK testi rplsync db m t2 checksum for server localhost 3212 Checking only_on_master_db database DIFF Database only_on_master_db NOT on server localhost 3311 DIFF Database only_on_master_db NOT on server localhost 3312 c 6 ctclomie SUMMARY 8 data consistency issues found Check a replication topology with filtering shell gt mysqlrplsync master user pass localhost 3310 slaves rp1 pass localhost 3311 rp1 pass localhost 3312 verbose Checking users permission to perform consistency check WARNING Replication filters found on checked servers This can lead data consistency issues depending or More information http dev mysql com doc en replication rules html Master localhost 3310 Ipiimlleeclo_clie tesc solene Cisi Slove localhost Gis snl replicate_do_table test_rplsync_db1 tl Slave localhost 3312 replicate_ignore_table test_rplsync_db1 t2 replicate_wild_ignore_table test _rplsync _db1 3 GTID differences between Master and Slaves Slave localhost 231i ise up to daten Slave localhost 2312 is up to date Checking data consistency Using Master localhost 3310 as base server for comparison Checking test_rplsync_db1 database SKIP Table t0 c
440. tly from their cause network connection issue hard drive crash cosmic lightning etc can stop the replication process by making the master no longer accessible by its slaves In this type of situation it is desirable to promote one of the slaves to master while the problem with the old master is being solve as it can take some considerable time It will be even better to have an application to monitor the replicate topology and automatically perform failover minimizing downtime and keeping replication running Objectives The goal is to start the mysql failover utility to monitor a replication topology and perform failover automatically when required When the current master fails manually promoting a slave to the new master can be a very tedious and error prone task as all the remaining slave have to point out to the new master and the new master needs to catch up with all the slaves to make sure that no transactions is lost Fortunately the mysqli failover utility is capable of executing this full process automatically and in a optimized way Let s assume that a replication topology with one master server1 3311 and four slaves server2 3312 server3 3313 server4 3314 server 3315 was previously setup Example Execution Start the mysql failover utility in console mode default shell gt mysqlfailover master root server1 3311 slaves root server2 3312 root server3 3313 root server4 3314 root server5 3315
441. to map a replication topology show list Display a column list of the topology ssl ca The path to a file that contains a list of trusted SSL CAs ssl cert The name of the SSL certificate file to use for establishing a secure connection ssl cert The name of the SSL key file to use for establishing a secure connection Ssl Specifies if the server connection requires use of SSL If an encrypted connection cannot be established the connection attempt fails Default setting is 0 SSL not required verbose v Specify how much information to display If this option is used the IO thread status of each slave is also displayed Use this option multiple times to increase the amount of information For example v verbose vv more verbose vvv debug If you use vvv the output will contain the state of the IO and SQL threads for each slave version Display version information and exit 180 NOTES NOTES The login user must have the REPLICATE SLAVE and REPLICATE CLIENT privileges to successfully execute this utility Specifically the login user must have appropriate permissions to execute SHOW SLAVE STATUS SHOW MASTER STATUS and SHOW SLAVE HOSTS For the format option the permitted values are not case sensitive In addition values may be specified as any unambiguous prefix of a valid value For example format g specifies the grid format An error occurs if a prefix matches more than
442. transaction skip utility This utility allows users to skip multiple transactions on slaves in a single step In particular it injects empty transactions on all specified slaves for each GTID in the specified GTID set Skipping transactions can be useful to recover from erroneous situations that can occur during the replication process However this technique must be applied with extreme caution and full knowledge of its consequences because it might lead to data inconsistencies between the replication servers For example let s consider that a transaction that inserts some data row1 into table t1 fails on slave1 If that transaction is simply skipped to quickly resume replication on slave1 without any additional intervention then row1 will be missing from that slave Moreover row1 will no longer be replicated from the master since the GTID for the skipped transaction will be associated to an empty transaction As a consequence the data for table t1 on slave1 will be inconsistent with the one on the master and other slaves because row1 will be missing For this reason we should make sure that the technique to skip transactions is applied in the right situations and that all additional operations to keep the data consistent are also taken Skipping transactions is also useful to ignore errant transactions on slaves in order to avoid those transactions from being replicated if a failover occurs For example consider that some tr
443. ttans 2 MySQL Utilities is available in a number of repository formats Although you may not see your specific operating system or platform listed we provide general repository formats for most platforms If none of the available repositories are applicable to your platform you can use the source code repository and install MySQL Utilities from the command line The latest MySQL Utilities downloads are available at http dev mysql com downloads utilities 1 6 html The following sections discuss each repository For information specific to Fabric see Installing and Configuring MySQL Fabric 1 1 Prerequisites MySQL Utilities requires Python 2 6 All of the Python code is written to conform to this version of Python For connecting to MySQL MySQL Utilities requires a MySQL Connector Python General Availability GA release version 2 0 4 2 1 2 or later If you do not have Connector Python installed see the download section for Connector Python to download the appropriate repository 1 2 Source Code The source code repository for MySQL Utilities includes all of the utility code as well as the MySQL Utilities library and manual pages It is available as an architecture independent distribution in either Zip archive format zip file or compressed tar archive format tar gz file You can use this repository to install on any platform that has Python 2 6 installed For example you can use the tar gz version of the repository to inst
444. ure CoPy command line program and that must have access to the MySQL remote server and its data directory with the provided credentials user and password It is also assumed that the specified audit log file exists and user has write privileges on the target directory Example Execution shell gt mysqlauditadmin audit log name MySQL SERVER data audit log 13753706179878237 copy copy to ARCHIVE Audit_Logs remote login user1 server1 Copying file from serverl MySQL SERVER data audit log 13753706179878237 to ARCHIVE Audit_Logs userl serverl s password audit log 13753706179878237 100 4716 4 6KB s 00 01 54 How Do Show All INSERT and UPDATE Queries That Failed Discussion The copy operation can be performed with the mysqlauditadmin utility using the copy command and requiring the following options the audit 1log name option to specify the path and filename of the audit log file to copy the copy to option to indicate the destination folder and in this example the remote login option to specify the user and remote host where the file is located the user password will be prompted The remote login option is not required if the source and destination location are on the same server where the utility is executed Moreover this option is not supported in Windows system where UNC paths should be used instead Permissions Required The user must have permissions to read the audit log on disk and wri
445. use the show defaults option This option reads the configuration file on the machine where the utility is run not the machine for the host that the server option specifies To run the utility against several servers specify the server option multiple times In this case the utility attempts to connect to each server and read the information To see the MySQL servers running on the local machine use the show servers option This shows all the servers with their process ID and data directory On Windows the utility shows only the process ID and port OPTIONS mysqlserverinfo accepts the following command line options e help 192 OPTIONS Display a help message and exit license Display license information and exit basedir lt basedir gt The base directory for the server This option is required for starting an offline server Is also used to access server tools such as my_print_defaults that is required to read the login path values from the login configuration file mylogin cnf datadir lt datadir gt The data directory for the server This option is required for starting an offline server format lt format gt f lt format gt Specify the output display format Permitted format values are grid csv tab and vertical The default is grid no headers h Do not display column headers This option applies only for grid csv and tab output port range lt start end gt The port ran
446. user with the mat ch user option using a wildcard in case the user is logged in from a different system We also specified the name of the maintenance routine in the same manner in case it gets renamed with a version number or some such The output of this utility then is the SQL statement we need to use to find and kill the connections that meet these criteria Armed with this we can make a procedure we can call from an event and execute the SQL at a precise time every day Permissions Required The user must have the SELECT permission on the mysql database Tips and Tricks If you are familiar with using regular expressions you can use the regexp option to use regular expressions instead of database patterns 3 4 High Availability Operations The tasks described in this section include those for replication and general to specific high availability tasks such as automatic failover 31 How Can Use Replication 3 4 1 How Can I Use Replication MySQL has built in support for several types of replication Replication is usually employed with the purpose of increasing the performance and or the fault tolerance of a service However setting up replication can be a somewhat complicated and error prone process But fear not MySQL Utilities has tools that can help simplify and even automate several replication related tasks Lets see a possible scenario where replication is used to obtain scalability i e to increase the perfor
447. ut requiring additional privileges Will the default mode display a 100 accurate CREATE statement For most tables and all views yes However there are at least two features that are not stored in the frm file and therefore will not be included These are autoincrement values and foreign keys That being said the CREATE statement produced will be syntactically correct 8 2 Third Party Licenses Use of any of this software is governed by the terms of the licenses that follow MySQL Utilities 1 6 Section 8 2 1 Apache Libcloud e Section 8 2 2 Apache License Version 2 0 January 2004 Section 8 2 3 Doctrine DBAL 2 3 4 Section 8 2 4 GNU Lesser General Public License Version 2 1 February 1999 Section 8 2 5 Paramiko License Section 8 2 6 Python Bindings to the OpenStack Neutron API python neutronclient e Section 8 2 7 Python bindings to the OpenStack Nova API python novaclient 226 Apache Libcloud e Section 8 2 8 Python License e Section 8 2 9 Python License Supplement Windows Only 8 2 1 Apache Libcloud You are receiving a copy of Apache Libcloud code The terms of the Oracle license do NOT apply to the Apache Libcloud program it is licensed under the following license separately from the Oracle programs you receive If you do not wish to install this program you may delete it from the install directory Apache Libcloud Copyright c 201
448. utilities common tools py 205 The MySQL Utilities Library E mysql utilities common format py Each utility script is designed to process the user input and option settings and pass them on to the command module Thus the script contains only such logic for managing and validating options The work of the operation resides in the command module Command modules are designed to be used from other Python applications For example one could call the methods in the serverinfo py module from another Python script This enables developers to create their own interfaces to the utilities It also permits developers to combine several utilities to form a macro level utility tailored to a specified need For example if there is a need to gather server information as well as disk usage it is possible to import the serverinfo py and diskusage py modules and create a new utility that performs both operations Common modules are the heart of the MySQL Utilities library These modules contain classes that abstract MySQL objects devices and mechanisms For example there is a server class that contains operations to be performed on servers such as connecting logging in and running queries The MySQL Utilities Library Although the library is growing the following lists the current common modules and the major classes and methods as of the 1 0 1 release Module Class Method Description database Database Perform database level operatio
449. utility are valid at the time the checks are actually performed for each table This is because in an active system with data continuously changing inconstancy issues might be introduced in the immediate instance after the check is completed Permissions Required The user for the master must have permissions to lock tables perform the checksum and get information about the master status Specifically the user used to connect to the master requires the following privileges SUPER or REPLICATION CLIENT LOCK TABLES and SELECT The user for the slaves must have permissions to start stop the slave perform the checksum and get information about the slave status More specifically the login user to connect to slaves requires the following privileges SUPER and SELECT Tips and Tricks In the above example the mysqirplsync utility was used to check all the data on the servers However it is possible to check only specific databases and tables For that purpose the user only need to specify the target database and tables as arguments when invoking the utility It is also possible to exclude specific database and tables from the check using the exclude 183 option For example exclude test_rplsync_db test_db t0 excludes the database test_rplsync_db and table test_db t0 from the check performed by the utility The utility provides important options to control the execution time of the checksum queries performed on each table
450. ution of the mysqli failover daemon simply invoke the utility using the option daemon stop No other options is required to stop the daemon unless a specific pidfile to store the process PID was specified with the pidfile option to start the daemon and in this case the same option value is also required to stop it Another useful feature is the possibility to run external script along the execution of the utility to perform customized actions The following options can be used to execute different scripts at distinct moments of the mysql failover execution xec fail check to specify a script to run periodically at each predefined interval instead of the default check i e master is reachable and alive to detect the need to failover xec before to specify a script to execute before starting failover exec after to execute a script at the end of failover process exec post failover to run a script after completing the failover process before displaying the health report 3 4 4 Restore the Previous Master After Failover After a successful failover it is sometime required to restore the initial topology and promote the crashed server to master again or even a new server with distinctive hardware characteristics Sometimes failover can be triggered by simple network issue not affecting the health of the initial 38 Restore the Previous Master After Failover master server and after being resolved it might be desi
451. ve_acc users they need the SUPER privilege The repl user used as the argument for the rpl user option is either created automatically or if it exists it needs the REPLICATION SLAVE privilege To run the mysqlrpladmin utility with the health command the m_account used on the master needs an extra SUPER privilege 35 Setup Automatic Failover As for the switchover command all the users need the following privileges SUPER GRANT OPTION SELECT RELOAD DROP CREATE and REPLICATION SLAVE Tips and Tricks We can use the discover slaves login option for mysqlrpladmin in order to detect the slaves automatically instead of manually specifying the slaves The mysqirpladmin utility allows users to specify a script to execute before and after the failover and switchover operations using the xec before and exec after options respectively Note that the script specified using the exec after option only runs in case the switchover failover executes successfully We can use the mysql rpladmin utility to start and stop all the slaves with the start stop commands Using the stop command only stops servers that are actually slaves of the specified master thus preventing us from stopping unwanted servers 3 4 3 Setup Automatic Failover Once your replication topology is setup it is important to consider the possible occurrences of failures in order to maintain the high availability level of your system Several failures independen
452. vileges lt list of required privileges gt Minimum set of privileges that a user must have for any given object server lt source gt Connection information for the server To connect to a server it is necessary to specify connection parameters such as user name host name password and either a port or socket MySQL Utilities provides a number of ways to supply this information All of the methods require specifying your choice via a command line option such as server master slave etc The methods include the following in order of most secure to least secure 138 NOTES e Use login paths from your mylogin cnf file encrypted not visible Example lt ogin path gt lt port gt lt socket gt e Use a configuration file unencrypted not visible Note available in release 1 5 0 Example lt configuration file path gt lt section gt Specify the data on the command line unencrypted visible Example lt user gt lt passwa gt lt host gt lt port gt lt socket gt e ssl ca The path to a file that contains a list of trusted SSL CAs e ssl cert The name of the SSL certificate file to use for establishing a secure connection e ssl key The name of the SSL key file to use for establishing a secure connection e ssl Specifies if the server connection requires use of SSL If an encrypted connection cannot be established the connection attempt fails Default setting is 0 SSL not required
453. way You shall not publish or distribute this documentation in any form or on any media except if you distribute the documentation in a manner similar to how Oracle disseminates it that is electronically for download on a Web site with the software or on a CD ROM or similar medium provided however that the documentation is disseminated together with the software on the same medium Any other use such as any dissemination of printed copies or use of this documentation in whole or in part in another publication requires the prior written consent from an authorized representative of Oracle Oracle and or its affiliates reserve any and all rights to this documentation not expressly granted above vi Chapter 1 How to Install MySQL Utilities Table of Contents Aecilh F ROVSCMSIVGS egrets sap crc trance witccne tre aa atte a cat ce neces bene aac ae eae teen et eaten ere cance eeeencess 1 12 SOUICO GOdE s weccisvenscacsanncced ass Sanddanteheadabeuanddanieaciee rebanddaataleudisssmersbdawerdead aiea T EAA eA 1 1 3 Oracle Linux and Red Hat LINUX 6 00 cccc cece cece ceca cece eeeeeeaeeeseeeseeeeneeeueegeeeeeeuaeeaeeeaeeeseeuaeea 1 14 Debian EMUX sksiccssissivedias corstesseateord hed a aaa iaaa a Aa shoe eaeenaaabesat ea sesayanavodsnued aaas iaaa 2 1 5 Microsoft WINDOWS sinsscasicerecuiiiensdsnesadeusealsvatastaandedsseanadaaauameuseabavdaatGadidedaatnmevea r E 2 KOOS X iania R a e a A winevaatiaied cael swetadaniadederaitdacdsasndetcaphna
454. x id bday ON test _db indexcheck test emp id birthday USING BTREE Discussion As we can see the utility first points out that neither the idx_uemp_id index nor the idx_fnumber are necessary and it points out why The first idx_uemp_id is redundant because the primary key already ensures that emp_id values have to be unique As for idx_fnumber it is also redundant because of idx_ufnumber a UNIQUE type index which also works as a regular index Then it points out that idx_full_name_dup is also not necessary In this case it is a duplicate of the idx_full_name index since it contains the exact same columns on the same order Notice that it also indicates that idx_name idx_surname and even the PRIMARY INDEX on emp_id might be redundant This happens because we are dealing with BTREE type indexes and for this type of indexes an index X is redundant to an index Y if and only if the first n columns in X also appear in Y Given that we are using InnoDB engine it also warns us that idx_uemp_id idx_id_name idx_id_hdate and idx_id_bday might not be needed This happens because in InnoDB secondary indexes contain the primary key columns for the row that are not in the secondary index It must be noted however that these are just indications they must not be followed blindly because redundant indexes can be useful depending on how you use query your tables Permissions Required Regarding the privileges needed to run
455. xclude copying of triggers procedures and functions In this case use the option skip gt TRIGGERS PROCEDURES FUNCTIONS The values are case insensitive and uppercased for emphasis The copy is replication and GTID aware and will take actions to preserve the binary log events during the copy You can set the locking type with the locking option Possible values include no locks do not use any table locks lock all use table locks but no transaction and no consistent read snapshot default consistent read using a single transaction Should the copy fail in the middle the destination databases may be incomplete or inconsistent Should this occur drop the destination database in question repair the cause of the failure and restart the copy 3 2 3 How Can Make a Copy of a Database and Change the Storage Engine Sometimes you may have need to create a copy of a database but change the storage engine of all tables to another engine For example if you are migrating your database to InnoDB a wise choice you can copy the database to a new database on a new server and change the storage engine to InnoDB For this we can use the mysqldbcopy utility Objectives In this example we want to make a copy of the world_innodb database but change the storage engine to MyISAM and rename the database accordingly You can cause all tables in the destination databases to use a different storage engine with the new stora
456. xecutable the required form of the work that uses the Library must include any data and utility programs needed for reproducing the executable from it However as a special exception the materials to be distributed need not include anything that is normally distributed in either source or binary form with the major components compiler kernel and so on of the operating system on which the executable runs unless that component itself accompanies the executable It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system Such a contradiction means you cannot use both them and the Library together in an executable that you distribute 7 You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities not covered by this License and distribute such a combined library provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted and provided that you do these two things a Accompany the combined library with a copy of the same work based on the Library uncombined with any other library facilities This must be distributed under the terms of the Sections above b Give prominent notice with the combined library of the fact that part of it is a work based on the Library and explaining where
457. xpression Define a matching group and matches the regular expression inside the parentheses For example Wa NAME 70 OPTIONS Match a sequence of zero or more a e Mare Match a sequence of one or more a ap Match zero or one a e tapea Match ab or cd laxy Match a x or y s fa fy Match any character in the range a to f that is a b c d e or o Mraky Match any character except a x or y es ea Match exactly five copies of a Malapo Match from two to five copies of a gt labe Match one or more repetitions of abc This is a brief overview of regular expressions that can be used to define this type of patterns The full syntax is described in the Python re module docs supporting the definition of much more complex pattern matching expression OPTIONS mysqlauditgrep accepts the following command line options e end date lt END_ DATE gt End date time to retrieve log entries until the specified date time range If not specified or the value is 0 all entries to the end of the log are displayed Accepted formats yyyy mm ddThh mm ss or yyyy mm dd e event type lt EVENT_TYPE gt Commaz separated list of event types to search in all audit log records matching the specified types Supported values are Audit Binlog Dump Change user Close stmt Connect Out Connect Create DB Daemon Debug Delayed insert Drop DB Execute Fetch Field List Init DB
458. y 0 A20LZ 09 2 JLISs 33339 Query SET session autocommit OFF 7 0 AWLZ 09 2 JLIS SSS 339 Query SHOW VARIABLES LIKE READ_ONLY 7 0 AWLZ 09 2 LISS S33 39 Query SHOW VARIABLES LIKE datadir 7 0 A2WLZ 09 2 JIS Ss 33339 Query SHOW VARIABLES LIKE basedir 7 0 AQL2 O9 2 il 3 e Sse 3h Query SET NAMES latini COLLATE latinl_swedish_ci 8 0 AWLZ 09 2 JLISS 33339 Query SET session autocommit OFF 8 0 AWILZ 09 2 JHISS 33339 Query SHOW VARIABLES LIKE READ_ONLY 8 0 2VL2 O9 27 TI Ss 33839 Query SHOW VARIABLES LIKE basedir 8 0 AWILZ O9 29 Till s 36 3 50 Query SET NAMES latinl COLLATE latinl_swedish_ci 9 0 AWQLZ 09 29 Till 36 3 50 Query SET session autocommit OFF 9 0 AWLE 09 f GANG S0 Query SHOW VARIABLES LIKE READ_ONLY 9 0 AWLZ 09 2 Wills 26 350 Query SET NAMES latinl COLLATE latinl_swedish_ci 0 0 AWLZ O9 29 Till 36 350 Query SET session autocommit OFF 0 0 AWLZ 09 28 SAS Query SHOW VARIABLES LIKE READ_ONLY 0 0 AWILZ O9 23 Till 36 3150 Query SET GLOBAL audit_log_flush ON 0 0 AWLZ 09 29 Will 363150 Query SHOW VARIABLES LIKE audit_log_policy 0 0 2012 09 26 T1126 50 Query SHOW VARIABLES LIKE audit_log_rotate_on_size 0 0 AOLZ O iO wil Ss SVG IL Query show databases 1 1046 AMILZ 10 1O Tis 5 7326 Query show tables test 1 1046 AWLZ 10 OTS 8573 36 Query show tables test 1 PERMISSIONS REQUIRED
459. y mysqldiee compare object definitions among objects where the difference is how dbl objl differs from db2 o0bj2 mysqldbcopy copy databases from one server to another mysqlreplicate establish replication with a master mysqldbexport export metadata and data from databases mysqldbimport import metadata and data from files mysqlmetagrep search metadata mysqlprocgrep search process information mysqldiskusage show disk usage for databases mysqlserverinfo show server information mysqlserverclone start another instance of a running server The following demonstrates launching the console to run several commands using the execute option to including setting a variable for a server connection and executing a utility using variable substitution Note R It may be necessary to escape the on some platforms such as Linux The output below is an excerpt and is representational only shell gt mysqluc e set SERVER root host123 mysqldiskusage server SERVER Source on host123 connected NOTICE Your user account does not have read access to the datadir Data sizes will be calculated and actual file sizes may be omitted Some features may be unavailable Database totals 4 4 db_name total 4 4 world O 4 4 Total database disk usage 1 072 359 052 bytes or 1022 00 MB done The followin
460. y check is performed per table using a checksum table If the calculated checksum differs it indicates the tables are not synchronized Nevertheless since the checksum operation is not collision free there is a very small probability that two different tables can produce the same checksum Mixing IP and hostnames is not recommended The replication specific utilities will attempt to compare hostnames and IP addresses as aliases for checking slave connectivity to the master However if your installation does not support reverse name lookup the comparison could fail Without the ability to do a reverse name lookup the replication utilities could report a false negative that the slave is not connected to the master For example if you setup replication using MASTER_HOST ubuntu net on the slave and later connect to the slave with mysqlrplcheck and have the master specified as master 192 168 0 6 using the valid IP address for ubuntu net you must have the ability to do a reverse name lookup to compare the IP 192 168 0 6 and the hostname ubuntu net to determine if they are the same machine Similarly in order to avoid issues mixing local IP 127 0 0 1 with localhost all the addresses 127 0 0 1 will be internally converted to localhost by the utility The path to the MySQL client tools should be included in the PATH environment variable in order to use the authentication mechanism with login paths This will allow the utility to
461. y of common functions is available it is easy for a database administrator to create scripts for common tasks These utilities are located in the scripts folder of the installation or source tree If you have a task that is not met by these utilities or one that can be met by combining one or more of the utilities or even parts of the utilities you can easily form your own custom solution The following sections present an example of a custom utility discussing first the anatomy of a utility and then what the mysql utilities module library has available Anatomy of a MySQL Utility MySQL Utilities use a three tier module organization At the top is the command script which resides inthe scripts folder of the installation or source tree Included in the script is a command module designed to encapsulate and isolate the bulk of the work performed by the utility The command module resides in the mysql utilities command folder of the source tree Command modules have names similar to the script A command module includes classes and methods from one or more common modules where the abstract objects and method groups are kept The common modules reside in the mysql utilities common folder of the source tree The following illustrates this arrangement using the mysqlserverinfo utility scripts mysqlserverinfo py mysql utilities command serverinfo py Lv mysql utilities common options py a mysql utilities common server py 2 mysql
462. ySQL Utility commands The console will execute each command and display the output All commands to be run by the console must appear inside a quoted string and separated by semi colons Commands outside of the quoted string will be treated as arguments for the mysqluc utility itself and thus ignored for execution commands at the point of failure Commands may also be piped into the Note R In the console an error in the console or related code will stop executing console using a mechanism such as echo lt commands gt mysqluc The console also allows users to set user defined variables for commonly used values in options The syntax is simply set VARNAME VALUE The user can see a list of all variables by entering the show variables command To use the values of these variables in utility commands the user must prefix the value with a For example server SERVER1 will substitute the value of the SERVER1 user defined variable when the utility is executed Note R User defined variables have a session lifetime They are not saved from one execution to another in the users console 199 OPTIONS User defined variables may also be set by passing them as arguments to the mysqluc command For example to set the SERVER1 variable and launch the console the user can launch the console using this command shell gt mysqluc SERVER1 root localhost The user can provide any number of user defined variables but they must contai
463. yone to use this software for any purpose including commercial applications and to alter it and redistribute it freely subject to the following restrictions 1 The origin of this software must not be misrepresented you must not claim that you wrote the original software If you use this software in a product an acknowledgment in the product documentation would be appreciated but is not required 247 Python License 2 Altered source versions must be plainly marked as such and must not be misrepresented as being the original software 3 This notice may not be removed or altered from any source aistribution L Peter Deutsch ghost aladdin com ndependent implementation of MD5 RFC 1321 This code implements the MD5 Algorithm defined in RFC 1321 whose text is available at NETO ry www Veer orgy TEC piel 321 ext The code is derived from the text of the RFC including the test suite section A 5 but excluding the rest of Appendix A It does not include any code or documentation that is identified in the RFC as being copyrighted The original and principal author of md5 h is L Peter Deutsch lt ghost aladdin com gt Other authors are noted in the change history that follows in reverse chronological order 2002 04 13 lpd Removed support for non ANSI compilers removed references to Ghostscript clarified derivation from RFC 1321 now handles byte order either statically or dynamically 1999 11 04 lpd Edited
464. you must have the ability to run the spawned server with privileges that allow you to read the protected files For example you could use a user account that has root level privileges If you use the utility with a server connection the user you use to connect must have the ability to read system variables at a minimum including read access to the mysql database You should never use the root user to spawn the server nor should you use the mysql user when spawning the server or running the utility Tips and Tricks Risks The utility is designed to work on the host where the frm files reside It does not permit connecting to a remote host to read frm files If something goes wrong during the spawning of the server use the verbosity option three times vvv to turn on maximum depth debug statements This will ensure you will see all of the messages from the start of the spawned server from bootstrap onward Look for errors in these statements as to why the spawned server will not start The utility performs a best effort approximation of the CREATE statement when run in diagnostic mode As such if you read a frm file that uses character sets or collations other than the default and you do not use a server option to connect to a server to read the character sets this can result in miscalculated column sizes 23 Creating a New User With The Same Privileges as Another User For example suppose your default character set is la
465. zero or more a a Match a sequence of one or more a a Match zero or one a ab cd Match ab or cd a 5 Match five instances of a a 2 5 Match from two to five instances of a abc Match one or more repetitions of abc OPTIONS mysqlmetagrep accepts the following command line options help Display a help message and exit license Display license information and exit 148 OPTIONS body b Search the body of stored programs procedures functions triggers and events The default is to match only the name character set lt charset gt Sets the client character set The default is retrieved from the server variable character_set_client database lt pattern gt Look only in databases matching this pattern format lt format gt f lt format gt Specify the output display format Permitted format values are grid default csv tab and vertical object types lt types gt search objects lt types gt Search only the object types named in types which is a comma separated list of one or more of the values database trigger user routine column table partition event and view The default is to search in objects of all types pattern lt pattern gt e lt pattern gt The pattern to use when matching This is required when the first non option argument looks like a connection specification rather than a pattern If the pattern option is given the first non option a

Download Pdf Manuals

image

Related Search

Related Contents

www.bialetti.it 800  Samsung SCX-5312F Manuel de l'utilisateur  Xtech XTH-510 headset  ギフトネットコム出展規約  Manual BRAVO500  Samsung 2263DX User Manual  owner's manual bedienungsanleitung mode d'emploi  Interlogix Simon XT  ECE 116 - Jungheinrich  Manuel d`installation et d`utilisation de l`appareil  

Copyright © All rights reserved.
Failed to retrieve file