#include "client_priv.h"#include <signal.h>#include <sys/stat.h>#include <mysql.h>#include <sslopt-vars.h>#include <sslopt-longopts.h>#include <sslopt-case.h>#include <help_start.h>#include <help_end.h>Include dependency graph for mysqladmin.cc:

Go to the source code of this file.
Defines | |
| #define | ADMIN_VERSION "8.41" |
| #define | MAX_MYSQL_VAR 256 |
| #define | SHUTDOWN_DEF_TIMEOUT 3600 |
| #define | MAX_TRUNC_LENGTH 3 |
Enumerations | |
| enum | commands { ADMIN_ERROR, ADMIN_CREATE, ADMIN_DROP, ADMIN_SHUTDOWN, ADMIN_RELOAD, ADMIN_REFRESH, ADMIN_VER, ADMIN_PROCESSLIST, ADMIN_STATUS, ADMIN_KILL, ADMIN_DEBUG, ADMIN_VARIABLES, ADMIN_FLUSH_LOGS, ADMIN_FLUSH_HOSTS, ADMIN_FLUSH_TABLES, ADMIN_PASSWORD, ADMIN_PING, ADMIN_EXTENDED_STATUS, ADMIN_FLUSH_STATUS, ADMIN_FLUSH_PRIVILEGES, ADMIN_START_SLAVE, ADMIN_STOP_SLAVE, ADMIN_FLUSH_THREADS, ADMIN_OLD_PASSWORD } |
Functions | |
| static void | print_version (void) |
| static void | usage (void) |
| static my_bool | sql_connect (MYSQL *mysql, uint wait) |
| static int | execute_commands (MYSQL *mysql, int argc, char **argv) |
| static int | drop_db (MYSQL *mysql, const char *db) |
| static sig_handler | endprog (int signal_number) |
| static void | nice_time (ulong sec, char *buff) |
| static void | print_header (MYSQL_RES *result) |
| static void | print_top (MYSQL_RES *result) |
| static void | print_row (MYSQL_RES *result, MYSQL_ROW cur, uint row) |
| static void | print_relative_row (MYSQL_RES *result, MYSQL_ROW cur, uint row) |
| static void | print_relative_row_vert (MYSQL_RES *result, MYSQL_ROW cur, uint row) |
| static void | print_relative_header () |
| static void | print_relative_line () |
| static void | truncate_names () |
| static my_bool | get_pidfile (MYSQL *mysql, char *pidfile) |
| static my_bool | wait_pidfile (char *pidfile, time_t last_modified, struct stat *pidfile_status) |
| static void | store_values (MYSQL_RES *result) |
| static my_bool | get_one_option (int optid, const struct my_option *opt __attribute__((unused)), char *argument) |
| int | main (int argc, char *argv[]) |
| static sig_handler | endprog (int signal_number __attribute__((unused))) |
| static void | print_row (MYSQL_RES *result, MYSQL_ROW cur, uint row __attribute__((unused))) |
| static void | print_relative_row_vert (MYSQL_RES *result __attribute__((unused)), MYSQL_ROW cur, uint row __attribute__((unused))) |
Variables | |
| char * | host = NULL |
| char * | user = 0 |
| char * | opt_password = 0 |
| char * | default_charset = NULL |
| char | truncated_var_names [MAX_MYSQL_VAR][MAX_TRUNC_LENGTH] |
| char | ex_var_names [MAX_MYSQL_VAR][FN_REFLEN] |
| ulonglong | last_values [MAX_MYSQL_VAR] |
| static int | interval = 0 |
| static my_bool | option_force = 0 |
| static my_bool | interrupted = 0 |
| static my_bool | new_line = 0 |
| static my_bool | opt_compress = 0 |
| static my_bool | opt_relative = 0 |
| static my_bool | opt_verbose = 0 |
| static my_bool | opt_vertical = 0 |
| static my_bool | tty_password = 0 |
| static uint | tcp_port = 0 |
| static uint | option_wait = 0 |
| static uint | option_silent = 0 |
| static uint | nr_iterations |
| static uint | opt_count_iterations = 0 |
| static ulong | opt_connect_timeout |
| static ulong | opt_shutdown_timeout |
| static my_string | unix_port = 0 |
| static uint | opt_protocol = 0 |
| static uint | ex_val_max_len [MAX_MYSQL_VAR] |
| static my_bool | ex_status_printed = 0 |
| static uint | ex_var_count |
| static uint | max_var_length |
| static uint | max_val_length |
| static const char * | command_names [] |
| static TYPELIB | command_typelib |
| static struct my_option | my_long_options [] |
| static const char * | load_default_groups [] = { "mysqladmin","client",0 } |
| #define ADMIN_VERSION "8.41" |
| #define MAX_MYSQL_VAR 256 |
Definition at line 32 of file mysqladmin.cc.
| #define MAX_TRUNC_LENGTH 3 |
| #define SHUTDOWN_DEF_TIMEOUT 3600 |
Definition at line 33 of file mysqladmin.cc.
| enum commands |
Definition at line 95 of file mysqladmin.cc.
00095 { 00096 ADMIN_ERROR, 00097 ADMIN_CREATE, ADMIN_DROP, ADMIN_SHUTDOWN, 00098 ADMIN_RELOAD, ADMIN_REFRESH, ADMIN_VER, 00099 ADMIN_PROCESSLIST, ADMIN_STATUS, ADMIN_KILL, 00100 ADMIN_DEBUG, ADMIN_VARIABLES, ADMIN_FLUSH_LOGS, 00101 ADMIN_FLUSH_HOSTS, ADMIN_FLUSH_TABLES, ADMIN_PASSWORD, 00102 ADMIN_PING, ADMIN_EXTENDED_STATUS, ADMIN_FLUSH_STATUS, 00103 ADMIN_FLUSH_PRIVILEGES, ADMIN_START_SLAVE, ADMIN_STOP_SLAVE, 00104 ADMIN_FLUSH_THREADS, ADMIN_OLD_PASSWORD 00105 #ifdef LATER_HAVE_NDBCLUSTER_DB 00106 ,ADMIN_NDB_MGM 00107 #endif 00108 };
| static int drop_db | ( | MYSQL * | mysql, | |
| const char * | db | |||
| ) | [static] |
Definition at line 1045 of file mysqladmin.cc.
References buf, FN_REFLEN, ME_BELL, my_printf_error(), MYF, mysql, mysql_error(), mysql_query(), option_force, and VOID.
Referenced by execute_commands().
01046 { 01047 char name_buff[FN_REFLEN+20], buf[10]; 01048 if (!option_force) 01049 { 01050 puts("Dropping the database is potentially a very bad thing to do."); 01051 puts("Any data stored in the database will be destroyed.\n"); 01052 printf("Do you really want to drop the '%s' database [y/N] ",db); 01053 fflush(stdout); 01054 VOID(fgets(buf,sizeof(buf)-1,stdin)); 01055 if ((*buf != 'y') && (*buf != 'Y')) 01056 { 01057 puts("\nOK, aborting database drop!"); 01058 return -1; 01059 } 01060 } 01061 sprintf(name_buff,"drop database `%.*s`",FN_REFLEN,db); 01062 if (mysql_query(mysql,name_buff)) 01063 { 01064 my_printf_error(0,"DROP DATABASE %s failed;\nerror: '%s'",MYF(ME_BELL), 01065 db,mysql_error(mysql)); 01066 return 1; 01067 } 01068 printf("Database \"%s\" dropped\n",db); 01069 return 0; 01070 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static sig_handler endprog | ( | int signal_number | __attribute__((unused)) | ) | [static] |
Definition at line 421 of file mysqladmin.cc.
References interrupted.
00422 { 00423 interrupted=1; 00424 }
| static sig_handler endprog | ( | int | signal_number | ) | [static] |
| static int execute_commands | ( | MYSQL * | mysql, | |
| int | argc, | |||
| char ** | argv | |||
| ) | [static] |
Definition at line 506 of file mysqladmin.cc.
References ADMIN_CREATE, ADMIN_DEBUG, ADMIN_DROP, ADMIN_EXTENDED_STATUS, ADMIN_FLUSH_HOSTS, ADMIN_FLUSH_LOGS, ADMIN_FLUSH_PRIVILEGES, ADMIN_FLUSH_STATUS, ADMIN_FLUSH_TABLES, ADMIN_FLUSH_THREADS, ADMIN_KILL, ADMIN_OLD_PASSWORD, ADMIN_PASSWORD, ADMIN_PING, ADMIN_PROCESSLIST, ADMIN_REFRESH, ADMIN_RELOAD, ADMIN_SHUTDOWN, ADMIN_START_SLAVE, ADMIN_STATUS, ADMIN_STOP_SLAVE, ADMIN_VARIABLES, ADMIN_VER, command_typelib, CR_SERVER_GONE_ERROR, drop_db(), error, ex_status_printed, find_type(), FN_REFLEN, func, get_pidfile(), make_scrambled_password(), make_scrambled_password_323(), ME_BELL, my_printf_error(), MYF, mysql, mysql_close(), mysql_dump_debug_info(), mysql_errno(), mysql_error(), mysql_fetch_row(), mysql_free_result(), mysql_get_host_info(), mysql_get_proto_info(), mysql_get_server_info(), mysql_kill(), mysql_num_rows(), mysql_ping(), mysql_query(), mysql_refresh(), mysql_shutdown(), mysql_stat(), mysql_store_result(), ndb_mgmclient_execute(), ndb_mgmclient_handle_create(), ndb_mgmclient_handle_destroy(), new_line, nice_time(), opt_ndb_connectstring, opt_relative, opt_verbose, opt_vertical, option_silent, st_mysql::port, pos(), print_header(), print_relative_header(), print_relative_line(), print_relative_row(), print_relative_row_vert(), print_row(), print_top(), print_version(), randominit(), st_mysql::reconnect, REFRESH_GRANT, REFRESH_LOG, REFRESH_MASTER, REFRESH_READ_LOCK, REFRESH_SLAVE, REFRESH_STATUS, REFRESH_THREADS, sec, SHUTDOWN_DEFAULT, start_time, status, store_values(), str2int(), strchr(), strlen(), truncate_names(), st_mysql::unix_socket, and wait_pidfile().
Referenced by main().
00507 { 00508 const char *status; 00509 /* 00510 MySQL documentation relies on the fact that mysqladmin will 00511 execute commands in the order specified, e.g. 00512 mysqladmin -u root flush-privileges password "newpassword" 00513 to reset a lost root password. 00514 If this behaviour is ever changed, Docs should be notified. 00515 */ 00516 00517 struct rand_struct rand_st; 00518 00519 for (; argc > 0 ; argv++,argc--) 00520 { 00521 switch (find_type(argv[0],&command_typelib,2)) { 00522 case ADMIN_CREATE: 00523 { 00524 char buff[FN_REFLEN+20]; 00525 if (argc < 2) 00526 { 00527 my_printf_error(0,"Too few arguments to create",MYF(ME_BELL)); 00528 return 1; 00529 } 00530 sprintf(buff,"create database `%.*s`",FN_REFLEN,argv[1]); 00531 if (mysql_query(mysql,buff)) 00532 { 00533 my_printf_error(0,"CREATE DATABASE failed; error: '%-.200s'", 00534 MYF(ME_BELL), mysql_error(mysql)); 00535 return -1; 00536 } 00537 argc--; argv++; 00538 break; 00539 } 00540 case ADMIN_DROP: 00541 { 00542 if (argc < 2) 00543 { 00544 my_printf_error(0,"Too few arguments to drop",MYF(ME_BELL)); 00545 return 1; 00546 } 00547 if (drop_db(mysql,argv[1])) 00548 return -1; 00549 argc--; argv++; 00550 break; 00551 } 00552 case ADMIN_SHUTDOWN: 00553 { 00554 char pidfile[FN_REFLEN]; 00555 my_bool got_pidfile= 0; 00556 time_t last_modified= 0; 00557 struct stat pidfile_status; 00558 00559 /* 00560 Only wait for pidfile on local connections 00561 If pidfile doesn't exist, continue without pid file checking 00562 */ 00563 if (mysql->unix_socket && (got_pidfile= !get_pidfile(mysql, pidfile)) && 00564 !stat(pidfile, &pidfile_status)) 00565 last_modified= pidfile_status.st_mtime; 00566 00567 if (mysql_shutdown(mysql, SHUTDOWN_DEFAULT)) 00568 { 00569 my_printf_error(0,"shutdown failed; error: '%s'",MYF(ME_BELL), 00570 mysql_error(mysql)); 00571 return -1; 00572 } 00573 mysql_close(mysql); /* Close connection to avoid error messages */ 00574 argc=1; /* force SHUTDOWN to be the last command */ 00575 if (got_pidfile) 00576 { 00577 if (opt_verbose) 00578 printf("Shutdown signal sent to server; Waiting for pid file to disappear\n"); 00579 00580 /* Wait until pid file is gone */ 00581 if (wait_pidfile(pidfile, last_modified, &pidfile_status)) 00582 return -1; 00583 } 00584 break; 00585 } 00586 case ADMIN_FLUSH_PRIVILEGES: 00587 case ADMIN_RELOAD: 00588 if (mysql_query(mysql,"flush privileges")) 00589 { 00590 my_printf_error(0,"reload failed; error: '%s'",MYF(ME_BELL), 00591 mysql_error(mysql)); 00592 return -1; 00593 } 00594 break; 00595 case ADMIN_REFRESH: 00596 if (mysql_refresh(mysql, 00597 (uint) ~(REFRESH_GRANT | REFRESH_STATUS | 00598 REFRESH_READ_LOCK | REFRESH_SLAVE | 00599 REFRESH_MASTER))) 00600 { 00601 my_printf_error(0,"refresh failed; error: '%s'",MYF(ME_BELL), 00602 mysql_error(mysql)); 00603 return -1; 00604 } 00605 break; 00606 case ADMIN_FLUSH_THREADS: 00607 if (mysql_refresh(mysql,(uint) REFRESH_THREADS)) 00608 { 00609 my_printf_error(0,"refresh failed; error: '%s'",MYF(ME_BELL), 00610 mysql_error(mysql)); 00611 return -1; 00612 } 00613 break; 00614 case ADMIN_VER: 00615 new_line=1; 00616 print_version(); 00617 puts("Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB"); 00618 puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license\n"); 00619 printf("Server version\t\t%s\n", mysql_get_server_info(mysql)); 00620 printf("Protocol version\t%d\n", mysql_get_proto_info(mysql)); 00621 printf("Connection\t\t%s\n",mysql_get_host_info(mysql)); 00622 if (mysql->unix_socket) 00623 printf("UNIX socket\t\t%s\n", mysql->unix_socket); 00624 else 00625 printf("TCP port\t\t%d\n", mysql->port); 00626 status=mysql_stat(mysql); 00627 { 00628 char *pos,buff[40]; 00629 ulong sec; 00630 pos= (char*) strchr(status,' '); 00631 *pos++=0; 00632 printf("%s\t\t\t",status); /* print label */ 00633 if ((status=str2int(pos,10,0,LONG_MAX,(long*) &sec))) 00634 { 00635 nice_time(sec,buff); 00636 puts(buff); /* print nice time */ 00637 while (*status == ' ') status++; /* to next info */ 00638 } 00639 } 00640 putc('\n',stdout); 00641 if (status) 00642 puts(status); 00643 break; 00644 case ADMIN_PROCESSLIST: 00645 { 00646 MYSQL_RES *result; 00647 MYSQL_ROW row; 00648 00649 if (mysql_query(mysql, (opt_verbose ? "show full processlist" : 00650 "show processlist")) || 00651 !(result = mysql_store_result(mysql))) 00652 { 00653 my_printf_error(0,"process list failed; error: '%s'",MYF(ME_BELL), 00654 mysql_error(mysql)); 00655 return -1; 00656 } 00657 print_header(result); 00658 while ((row=mysql_fetch_row(result))) 00659 print_row(result,row,0); 00660 print_top(result); 00661 mysql_free_result(result); 00662 new_line=1; 00663 break; 00664 } 00665 case ADMIN_STATUS: 00666 status=mysql_stat(mysql); 00667 if (status) 00668 puts(status); 00669 break; 00670 case ADMIN_KILL: 00671 { 00672 uint error=0; 00673 char *pos; 00674 if (argc < 2) 00675 { 00676 my_printf_error(0,"Too few arguments to 'kill'",MYF(ME_BELL)); 00677 return 1; 00678 } 00679 pos=argv[1]; 00680 for (;;) 00681 { 00682 if (mysql_kill(mysql,(ulong) atol(pos))) 00683 { 00684 my_printf_error(0,"kill failed on %ld; error: '%s'",MYF(ME_BELL), 00685 atol(pos), mysql_error(mysql)); 00686 error=1; 00687 } 00688 if (!(pos=strchr(pos,','))) 00689 break; 00690 pos++; 00691 } 00692 argc--; argv++; 00693 if (error) 00694 return -1; 00695 break; 00696 } 00697 case ADMIN_DEBUG: 00698 if (mysql_dump_debug_info(mysql)) 00699 { 00700 my_printf_error(0,"debug failed; error: '%s'",MYF(ME_BELL), 00701 mysql_error(mysql)); 00702 return -1; 00703 } 00704 break; 00705 case ADMIN_VARIABLES: 00706 { 00707 MYSQL_RES *res; 00708 MYSQL_ROW row; 00709 00710 new_line=1; 00711 if (mysql_query(mysql,"show /*!40003 GLOBAL */ variables") || 00712 !(res=mysql_store_result(mysql))) 00713 { 00714 my_printf_error(0,"unable to show variables; error: '%s'",MYF(ME_BELL), 00715 mysql_error(mysql)); 00716 return -1; 00717 } 00718 print_header(res); 00719 while ((row=mysql_fetch_row(res))) 00720 print_row(res,row,0); 00721 print_top(res); 00722 mysql_free_result(res); 00723 break; 00724 } 00725 case ADMIN_EXTENDED_STATUS: 00726 { 00727 MYSQL_RES *res; 00728 MYSQL_ROW row; 00729 uint rownr = 0; 00730 void (*func) (MYSQL_RES*, MYSQL_ROW, uint); 00731 00732 new_line = 1; 00733 if (mysql_query(mysql, "show /*!50002 GLOBAL */ status") || 00734 !(res = mysql_store_result(mysql))) 00735 { 00736 my_printf_error(0, "unable to show status; error: '%s'", MYF(ME_BELL), 00737 mysql_error(mysql)); 00738 return -1; 00739 } 00740 if (!opt_vertical) 00741 print_header(res); 00742 else 00743 { 00744 if (!ex_status_printed) 00745 { 00746 store_values(res); 00747 truncate_names(); /* Does some printing also */ 00748 } 00749 else 00750 { 00751 print_relative_line(); 00752 print_relative_header(); 00753 print_relative_line(); 00754 } 00755 } 00756 00757 /* void (*func) (MYSQL_RES*, MYSQL_ROW, uint); */ 00758 if (opt_relative && !opt_vertical) 00759 func = print_relative_row; 00760 else if (opt_vertical) 00761 func = print_relative_row_vert; 00762 else 00763 func = print_row; 00764 00765 while ((row = mysql_fetch_row(res))) 00766 (*func)(res, row, rownr++); 00767 if (opt_vertical) 00768 { 00769 if (ex_status_printed) 00770 { 00771 putchar('\n'); 00772 print_relative_line(); 00773 } 00774 } 00775 else 00776 print_top(res); 00777 00778 ex_status_printed = 1; /* From now on the output will be relative */ 00779 mysql_free_result(res); 00780 break; 00781 } 00782 case ADMIN_FLUSH_LOGS: 00783 { 00784 if (mysql_refresh(mysql,REFRESH_LOG)) 00785 { 00786 my_printf_error(0,"refresh failed; error: '%s'",MYF(ME_BELL), 00787 mysql_error(mysql)); 00788 return -1; 00789 } 00790 break; 00791 } 00792 case ADMIN_FLUSH_HOSTS: 00793 { 00794 if (mysql_query(mysql,"flush hosts")) 00795 { 00796 my_printf_error(0,"refresh failed; error: '%s'",MYF(ME_BELL), 00797 mysql_error(mysql)); 00798 return -1; 00799 } 00800 break; 00801 } 00802 case ADMIN_FLUSH_TABLES: 00803 { 00804 if (mysql_query(mysql,"flush tables")) 00805 { 00806 my_printf_error(0,"refresh failed; error: '%s'",MYF(ME_BELL), 00807 mysql_error(mysql)); 00808 return -1; 00809 } 00810 break; 00811 } 00812 case ADMIN_FLUSH_STATUS: 00813 { 00814 if (mysql_query(mysql,"flush status")) 00815 { 00816 my_printf_error(0,"refresh failed; error: '%s'",MYF(ME_BELL), 00817 mysql_error(mysql)); 00818 return -1; 00819 } 00820 break; 00821 } 00822 case ADMIN_OLD_PASSWORD: 00823 case ADMIN_PASSWORD: 00824 { 00825 char buff[128],crypted_pw[64]; 00826 time_t start_time; 00827 /* Do initialization the same way as we do in mysqld */ 00828 start_time=time((time_t*) 0); 00829 randominit(&rand_st,(ulong) start_time,(ulong) start_time/2); 00830 00831 if (argc < 2) 00832 { 00833 my_printf_error(0,"Too few arguments to change password",MYF(ME_BELL)); 00834 return 1; 00835 } 00836 if (argv[1][0]) 00837 { 00838 char *pw= argv[1]; 00839 bool old= (find_type(argv[0], &command_typelib, 2) == 00840 ADMIN_OLD_PASSWORD); 00841 #ifdef __WIN__ 00842 uint pw_len= strlen(pw); 00843 if (pw_len > 1 && pw[0] == '\'' && pw[pw_len-1] == '\'') 00844 printf("Warning: single quotes were not trimmed from the password by" 00845 " your command\nline client, as you might have expected.\n"); 00846 #endif 00847 /* 00848 If we don't already know to use an old-style password, see what 00849 the server is using 00850 */ 00851 if (!old) 00852 { 00853 if (mysql_query(mysql, "SHOW VARIABLES LIKE 'old_passwords'")) 00854 { 00855 my_printf_error(0, "Could not determine old_passwords setting from server; error: '%s'", 00856 MYF(ME_BELL),mysql_error(mysql)); 00857 return -1; 00858 } 00859 else 00860 { 00861 MYSQL_RES *res= mysql_store_result(mysql); 00862 if (!res) 00863 { 00864 my_printf_error(0, 00865 "Could not get old_passwords setting from " 00866 "server; error: '%s'", 00867 MYF(ME_BELL),mysql_error(mysql)); 00868 return -1; 00869 } 00870 if (!mysql_num_rows(res)) 00871 old= 1; 00872 else 00873 { 00874 MYSQL_ROW row= mysql_fetch_row(res); 00875 old= !strncmp(row[1], "ON", 2); 00876 } 00877 mysql_free_result(res); 00878 } 00879 } 00880 if (old) 00881 make_scrambled_password_323(crypted_pw, pw); 00882 else 00883 make_scrambled_password(crypted_pw, pw); 00884 } 00885 else 00886 crypted_pw[0]=0; /* No password */ 00887 sprintf(buff,"set password='%s',sql_log_off=0",crypted_pw); 00888 00889 if (mysql_query(mysql,"set sql_log_off=1")) 00890 { 00891 my_printf_error(0, "Can't turn off logging; error: '%s'", 00892 MYF(ME_BELL),mysql_error(mysql)); 00893 return -1; 00894 } 00895 if (mysql_query(mysql,buff)) 00896 { 00897 if (mysql_errno(mysql)!=1290) 00898 { 00899 my_printf_error(0,"unable to change password; error: '%s'", 00900 MYF(ME_BELL),mysql_error(mysql)); 00901 return -1; 00902 } 00903 else 00904 { 00905 /* 00906 We don't try to execute 'update mysql.user set..' 00907 because we can't perfectly find out the host 00908 */ 00909 my_printf_error(0,"\n" 00910 "You cannot use 'password' command as mysqld runs\n" 00911 " with grant tables disabled (was started with" 00912 " --skip-grant-tables).\n" 00913 "Use: \"mysqladmin flush-privileges password '*'\"" 00914 " instead", MYF(ME_BELL)); 00915 return -1; 00916 } 00917 } 00918 argc--; argv++; 00919 break; 00920 } 00921 00922 case ADMIN_START_SLAVE: 00923 if (mysql_query(mysql, "START SLAVE")) 00924 { 00925 my_printf_error(0, "Error starting slave: %s", MYF(ME_BELL), 00926 mysql_error(mysql)); 00927 return -1; 00928 } 00929 else 00930 puts("Slave started"); 00931 break; 00932 case ADMIN_STOP_SLAVE: 00933 if (mysql_query(mysql, "STOP SLAVE")) 00934 { 00935 my_printf_error(0, "Error stopping slave: %s", MYF(ME_BELL), 00936 mysql_error(mysql)); 00937 return -1; 00938 } 00939 else 00940 puts("Slave stopped"); 00941 break; 00942 00943 case ADMIN_PING: 00944 mysql->reconnect=0; /* We want to know of reconnects */ 00945 if (!mysql_ping(mysql)) 00946 { 00947 if (option_silent < 2) 00948 puts("mysqld is alive"); 00949 } 00950 else 00951 { 00952 if (mysql_errno(mysql) == CR_SERVER_GONE_ERROR) 00953 { 00954 mysql->reconnect=1; 00955 if (!mysql_ping(mysql)) 00956 puts("connection was down, but mysqld is now alive"); 00957 } 00958 else 00959 { 00960 my_printf_error(0,"mysqld doesn't answer to ping, error: '%s'", 00961 MYF(ME_BELL),mysql_error(mysql)); 00962 return -1; 00963 } 00964 } 00965 mysql->reconnect=1; /* Automatic reconnect is default */ 00966 break; 00967 #ifdef LATER_HAVE_NDBCLUSTER_DB 00968 case ADMIN_NDB_MGM: 00969 { 00970 if (argc < 2) 00971 { 00972 my_printf_error(0,"Too few arguments to ndb-mgm",MYF(ME_BELL)); 00973 return 1; 00974 } 00975 { 00976 Ndb_mgmclient_handle cmd= 00977 ndb_mgmclient_handle_create(opt_ndb_connectstring); 00978 ndb_mgmclient_execute(cmd, --argc, ++argv); 00979 ndb_mgmclient_handle_destroy(cmd); 00980 } 00981 argc= 0; 00982 } 00983 break; 00984 #endif 00985 default: 00986 my_printf_error(0,"Unknown command: '%-.60s'",MYF(ME_BELL),argv[0]); 00987 return 1; 00988 } 00989 } 00990 return 0; 00991 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static my_bool get_one_option | ( | int | optid, | |
| const struct my_option *opt | __attribute__((unused)), | |||
| char * | argument | |||
| ) | [static] |
Definition at line 223 of file mysqladmin.cc.
References atoi(), charsets_dir, DBUG_PUSH, error, exit, find_type(), MY_ALLOW_ZERO_PTR, MY_FAE, my_free, my_strdup(), MYF, MYSQL_PROTOCOL_PIPE, OPT_AUTO_CLOSE, OPT_CHARSETS_DIR, opt_count_iterations, OPT_MYSQL_PROTOCOL, opt_password, opt_protocol, option_silent, option_wait, print_version(), sql_protocol_typelib, start(), tty_password, and usage().
00225 { 00226 int error = 0; 00227 00228 switch(optid) { 00229 #ifdef __NETWARE__ 00230 case OPT_AUTO_CLOSE: 00231 setscreenmode(SCR_AUTOCLOSE_ON_EXIT); 00232 break; 00233 #endif 00234 case 'c': 00235 opt_count_iterations= 1; 00236 break; 00237 case 'p': 00238 if (argument) 00239 { 00240 char *start=argument; 00241 my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR)); 00242 opt_password=my_strdup(argument,MYF(MY_FAE)); 00243 while (*argument) *argument++= 'x'; /* Destroy argument */ 00244 if (*start) 00245 start[1]=0; /* Cut length of argument */ 00246 tty_password= 0; 00247 } 00248 else 00249 tty_password=1; 00250 break; 00251 case 's': 00252 option_silent++; 00253 break; 00254 case 'W': 00255 #ifdef __WIN__ 00256 opt_protocol = MYSQL_PROTOCOL_PIPE; 00257 #endif 00258 break; 00259 case '#': 00260 DBUG_PUSH(argument ? argument : "d:t:o,/tmp/mysqladmin.trace"); 00261 break; 00262 #include <sslopt-case.h> 00263 case 'V': 00264 print_version(); 00265 exit(0); 00266 break; 00267 case 'w': 00268 if (argument) 00269 { 00270 if ((option_wait=atoi(argument)) <= 0) 00271 option_wait=1; 00272 } 00273 else 00274 option_wait= ~(uint)0; 00275 break; 00276 case '?': 00277 case 'I': /* Info */ 00278 error++; 00279 break; 00280 case OPT_CHARSETS_DIR: 00281 #if MYSQL_VERSION_ID > 32300 00282 charsets_dir = argument; 00283 #endif 00284 break; 00285 case OPT_MYSQL_PROTOCOL: 00286 { 00287 if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0) 00288 { 00289 fprintf(stderr, "Unknown option to protocol: %s\n", argument); 00290 exit(1); 00291 } 00292 break; 00293 } 00294 } 00295 if (error) 00296 { 00297 usage(); 00298 exit(1); 00299 } 00300 return 0; 00301 }
Here is the call graph for this function:

Definition at line 1283 of file mysqladmin.cc.
References ME_BELL, my_printf_error(), MYF, mysql, mysql_error(), mysql_fetch_row(), mysql_free_result(), mysql_query(), mysql_store_result(), and strmov().
Referenced by execute_commands().
01284 { 01285 MYSQL_RES* result; 01286 01287 if (mysql_query(mysql, "SHOW VARIABLES LIKE 'pid_file'")) 01288 { 01289 my_printf_error(0,"query failed; error: '%s'",MYF(ME_BELL), 01290 mysql_error(mysql)); 01291 } 01292 result = mysql_store_result(mysql); 01293 if (result) 01294 { 01295 MYSQL_ROW row=mysql_fetch_row(result); 01296 if (row) 01297 strmov(pidfile, row[1]); 01298 mysql_free_result(result); 01299 return row == 0; /* Error if row = 0 */ 01300 } 01301 return 1; /* Error */ 01302 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int main | ( | int | argc, | |
| char * | argv[] | |||
| ) |
Definition at line 304 of file mysqladmin.cc.
References ADMIN_PING, command_typelib, CR_MAX_ERROR, CR_MIN_ERROR, default_charset, endprog(), err, error, execute_commands(), exit, find_type(), free_defaults(), get_one_option(), get_tty_password(), handle_options(), interrupted, interval, load_default_groups, load_defaults(), MY_ALLOW_ZERO_PTR, my_end(), my_free, MY_INIT, my_long_options, MYF, mysql, mysql_close(), mysql_errno(), mysql_init(), MYSQL_OPT_COMPRESS, MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_PROTOCOL, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, mysql_options(), MYSQL_SET_CHARSET_NAME, MYSQL_SHARED_MEMORY_BASE_NAME, mysql_ssl_set(), new_line, nr_iterations, NullS, opt_compress, opt_connect_timeout, opt_count_iterations, opt_password, opt_protocol, option_force, option_wait, sleep, sql_connect(), tty_password, usage(), user, and VOID.
00305 { 00306 int error= 0, ho_error; 00307 MYSQL mysql; 00308 char **commands, **save_argv; 00309 00310 MY_INIT(argv[0]); 00311 mysql_init(&mysql); 00312 load_defaults("my",load_default_groups,&argc,&argv); 00313 save_argv = argv; /* Save for free_defaults */ 00314 if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) 00315 { 00316 free_defaults(save_argv); 00317 exit(ho_error); 00318 } 00319 00320 if (argc == 0) 00321 { 00322 usage(); 00323 exit(1); 00324 } 00325 commands = argv; 00326 if (tty_password) 00327 opt_password = get_tty_password(NullS); 00328 00329 VOID(signal(SIGINT,endprog)); /* Here if abort */ 00330 VOID(signal(SIGTERM,endprog)); /* Here if abort */ 00331 00332 if (opt_compress) 00333 mysql_options(&mysql,MYSQL_OPT_COMPRESS,NullS); 00334 if (opt_connect_timeout) 00335 { 00336 uint tmp=opt_connect_timeout; 00337 mysql_options(&mysql,MYSQL_OPT_CONNECT_TIMEOUT, (char*) &tmp); 00338 } 00339 #ifdef HAVE_OPENSSL 00340 if (opt_use_ssl) 00341 mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, 00342 opt_ssl_capath, opt_ssl_cipher); 00343 mysql_options(&mysql,MYSQL_OPT_SSL_VERIFY_SERVER_CERT, 00344 (char*)&opt_ssl_verify_server_cert); 00345 #endif 00346 if (opt_protocol) 00347 mysql_options(&mysql,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol); 00348 #ifdef HAVE_SMEM 00349 if (shared_memory_base_name) 00350 mysql_options(&mysql,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name); 00351 #endif 00352 if (default_charset) 00353 mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset); 00354 if (sql_connect(&mysql, option_wait)) 00355 { 00356 unsigned int err= mysql_errno(&mysql); 00357 if (err >= CR_MIN_ERROR && err <= CR_MAX_ERROR) 00358 error= 1; 00359 else 00360 { 00361 /* Return 0 if all commands are PING */ 00362 for (; argc > 0; argv++, argc--) 00363 { 00364 if (find_type(argv[0], &command_typelib, 2) != ADMIN_PING) 00365 { 00366 error= 1; 00367 break; 00368 } 00369 } 00370 } 00371 } 00372 else 00373 { 00374 while (!interrupted && (!opt_count_iterations || nr_iterations)) 00375 { 00376 new_line = 0; 00377 if ((error=execute_commands(&mysql,argc,commands))) 00378 { 00379 if (error > 0) 00380 break; /* Wrong command error */ 00381 if (!option_force) 00382 { 00383 if (option_wait && !interrupted) 00384 { 00385 mysql_close(&mysql); 00386 if (!sql_connect(&mysql, option_wait)) 00387 { 00388 sleep(1); /* Don't retry too rapidly */ 00389 continue; /* Retry */ 00390 } 00391 } 00392 error=1; 00393 break; 00394 } 00395 } 00396 if (interval) 00397 { 00398 sleep(interval); 00399 if (new_line) 00400 puts(""); 00401 if (opt_count_iterations) 00402 nr_iterations--; 00403 } 00404 else 00405 break; 00406 } 00407 mysql_close(&mysql); 00408 } 00409 my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR)); 00410 my_free(user,MYF(MY_ALLOW_ZERO_PTR)); 00411 #ifdef HAVE_SMEM 00412 my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR)); 00413 #endif 00414 free_defaults(save_argv); 00415 my_end(0); 00416 exit(error ? 1 : 0); 00417 return 0; 00418 }
Here is the call graph for this function:

| static void nice_time | ( | ulong | sec, | |
| char * | buff | |||
| ) | [static] |
Definition at line 1073 of file mysqladmin.cc.
References int10_to_str(), and strmov().
01074 { 01075 ulong tmp; 01076 01077 if (sec >= 3600L*24) 01078 { 01079 tmp=sec/(3600L*24); 01080 sec-=3600L*24*tmp; 01081 buff=int10_to_str(tmp, buff, 10); 01082 buff=strmov(buff,tmp > 1 ? " days " : " day "); 01083 } 01084 if (sec >= 3600L) 01085 { 01086 tmp=sec/3600L; 01087 sec-=3600L*tmp; 01088 buff=int10_to_str(tmp, buff, 10); 01089 buff=strmov(buff,tmp > 1 ? " hours " : " hour "); 01090 } 01091 if (sec >= 60) 01092 { 01093 tmp=sec/60; 01094 sec-=60*tmp; 01095 buff=int10_to_str(tmp, buff, 10); 01096 buff=strmov(buff," min "); 01097 } 01098 strmov(int10_to_str(sec, buff, 10)," sec"); 01099 }
Here is the call graph for this function:

| static void print_header | ( | MYSQL_RES * | result | ) | [static] |
Definition at line 1102 of file mysqladmin.cc.
References st_mysql_field::max_length, mysql_fetch_field(), mysql_field_seek(), st_mysql_field::name, and print_top().
Referenced by execute_commands(), list_dbs(), and list_tables().
01103 { 01104 MYSQL_FIELD *field; 01105 01106 print_top(result); 01107 mysql_field_seek(result,0); 01108 putchar('|'); 01109 while ((field = mysql_fetch_field(result))) 01110 { 01111 printf(" %-*s|",(int) field->max_length+1,field->name); 01112 } 01113 putchar('\n'); 01114 print_top(result); 01115 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void print_relative_header | ( | ) | [static] |
Definition at line 1220 of file mysqladmin.cc.
References ex_val_max_len, ex_var_count, and truncated_var_names.
Referenced by execute_commands().
01221 { 01222 uint i; 01223 01224 putchar('|'); 01225 for (i = 0; i < ex_var_count; i++) 01226 printf(" %-*s|", ex_val_max_len[i] + 1, truncated_var_names[i]); 01227 putchar('\n'); 01228 }
Here is the caller graph for this function:

| static void print_relative_line | ( | ) | [static] |
Definition at line 1231 of file mysqladmin.cc.
References ex_val_max_len, and ex_var_count.
Referenced by execute_commands().
01232 { 01233 uint i; 01234 01235 putchar('+'); 01236 for (i = 0; i < ex_var_count; i++) 01237 { 01238 uint j; 01239 for (j = 0; j < ex_val_max_len[i] + 2; j++) 01240 putchar('-'); 01241 putchar('+'); 01242 } 01243 putchar('\n'); 01244 }
Here is the caller graph for this function:

Definition at line 1158 of file mysqladmin.cc.
References last_values, llstr(), st_mysql_field::max_length, mysql_fetch_field(), mysql_field_seek(), NULL, and strtoull.
Referenced by execute_commands().
01159 { 01160 ulonglong tmp; 01161 char buff[22]; 01162 MYSQL_FIELD *field; 01163 01164 mysql_field_seek(result, 0); 01165 field = mysql_fetch_field(result); 01166 printf("| %-*s|", (int) field->max_length + 1, cur[0]); 01167 01168 field = mysql_fetch_field(result); 01169 tmp = cur[1] ? strtoull(cur[1], NULL, 10) : (ulonglong) 0; 01170 printf(" %-*s|\n", (int) field->max_length + 1, 01171 llstr((tmp - last_values[row]), buff)); 01172 last_values[row] = tmp; 01173 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void print_relative_row_vert | ( | MYSQL_RES *result | __attribute__((unused)), | |
| MYSQL_ROW | cur, | |||
| uint row | __attribute__((unused)) | |||
| ) | [static] |
Definition at line 1176 of file mysqladmin.cc.
References ex_status_printed, ex_val_max_len, last_values, llstr(), NULL, strlen(), and strtoull.
01179 { 01180 uint length; 01181 ulonglong tmp; 01182 char buff[22]; 01183 01184 if (!row) 01185 putchar('|'); 01186 01187 tmp = cur[1] ? strtoull(cur[1], NULL, 10) : (ulonglong) 0; 01188 printf(" %-*s|", ex_val_max_len[row] + 1, 01189 llstr((tmp - last_values[row]), buff)); 01190 01191 /* Find the minimum row length needed to output the relative value */ 01192 if ((length=(uint) strlen(buff) > ex_val_max_len[row]) && ex_status_printed) 01193 ex_val_max_len[row] = length; 01194 last_values[row] = tmp; 01195 }
Here is the call graph for this function:

| static void print_row | ( | MYSQL_RES * | result, | |
| MYSQL_ROW | cur, | |||
| uint row | __attribute__((unused)) | |||
| ) | [static] |
Definition at line 1140 of file mysqladmin.cc.
References st_mysql_field::max_length, mysql_fetch_field(), mysql_field_seek(), and mysql_num_fields().
01142 { 01143 uint i,length; 01144 MYSQL_FIELD *field; 01145 01146 putchar('|'); 01147 mysql_field_seek(result,0); 01148 for (i=0 ; i < mysql_num_fields(result); i++) 01149 { 01150 field = mysql_fetch_field(result); 01151 length=field->max_length; 01152 printf(" %-*s|",length+1,cur[i] ? (char*) cur[i] : ""); 01153 } 01154 putchar('\n'); 01155 }
Here is the call graph for this function:

Referenced by execute_commands(), list_dbs(), and list_tables().
Here is the caller graph for this function:

| static void print_top | ( | MYSQL_RES * | result | ) | [static] |
Definition at line 1118 of file mysqladmin.cc.
References st_mysql_field::max_length, mysql_fetch_field(), mysql_field_seek(), st_mysql_field::name, and strlen().
Referenced by execute_commands(), and print_header().
01119 { 01120 uint i,length; 01121 MYSQL_FIELD *field; 01122 01123 putchar('+'); 01124 mysql_field_seek(result,0); 01125 while((field = mysql_fetch_field(result))) 01126 { 01127 if ((length=(uint) strlen(field->name)) > field->max_length) 01128 field->max_length=length; 01129 else 01130 length=field->max_length; 01131 for (i=length+2 ; i--> 0 ; ) 01132 putchar('-'); 01133 putchar('+'); 01134 } 01135 putchar('\n'); 01136 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void print_version | ( | void | ) | [static] |
Definition at line 995 of file mysqladmin.cc.
References ADMIN_VERSION, MACHINE_TYPE, my_progname, MYSQL_SERVER_VERSION, NETWARE_SET_SCREEN_MODE, and SYSTEM_TYPE.
Referenced by execute_commands(), get_one_option(), and usage().
00996 { 00997 printf("%s Ver %s Distrib %s, for %s on %s\n",my_progname,ADMIN_VERSION, 00998 MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); 00999 NETWARE_SET_SCREEN_MODE(1); 01000 }
Here is the caller graph for this function:

Definition at line 427 of file mysqladmin.cc.
References CR_CONN_HOST_ERROR, CR_CONNECTION_ERROR, CR_UNKNOWN_HOST, host, info, LOCAL_HOST, ME_BELL, my_printf_error(), MYF, mysql, mysql_errno(), mysql_error(), mysql_port, mysql_real_connect(), mysql_unix_port, NullS, opt_password, option_force, option_silent, sleep, tcp_port, unix_port, and user.
00428 { 00429 my_bool info=0; 00430 00431 for (;;) 00432 { 00433 if (mysql_real_connect(mysql,host,user,opt_password,NullS,tcp_port, 00434 unix_port, 0)) 00435 { 00436 mysql->reconnect= 1; 00437 if (info) 00438 { 00439 fputs("\n",stderr); 00440 (void) fflush(stderr); 00441 } 00442 return 0; 00443 } 00444 00445 if (!wait) 00446 { 00447 if (!option_silent) 00448 { 00449 if (!host) 00450 host= (char*) LOCAL_HOST; 00451 my_printf_error(0,"connect to server at '%s' failed\nerror: '%s'", 00452 MYF(ME_BELL), host, mysql_error(mysql)); 00453 if (mysql_errno(mysql) == CR_CONNECTION_ERROR) 00454 { 00455 fprintf(stderr, 00456 "Check that mysqld is running and that the socket: '%s' exists!\n", 00457 unix_port ? unix_port : mysql_unix_port); 00458 } 00459 else if (mysql_errno(mysql) == CR_CONN_HOST_ERROR || 00460 mysql_errno(mysql) == CR_UNKNOWN_HOST) 00461 { 00462 fprintf(stderr,"Check that mysqld is running on %s",host); 00463 fprintf(stderr," and that the port is %d.\n", 00464 tcp_port ? tcp_port: mysql_port); 00465 fprintf(stderr,"You can check this by doing 'telnet %s %d'\n", 00466 host, tcp_port ? tcp_port: mysql_port); 00467 } 00468 } 00469 return 1; 00470 } 00471 if (wait != (uint) ~0) 00472 wait--; /* One less retry */ 00473 if ((mysql_errno(mysql) != CR_CONN_HOST_ERROR) && 00474 (mysql_errno(mysql) != CR_CONNECTION_ERROR)) 00475 { 00476 fprintf(stderr,"Got error: %s\n", mysql_error(mysql)); 00477 if (!option_force) 00478 return 1; 00479 } 00480 else if (!option_silent) 00481 { 00482 if (!info) 00483 { 00484 info=1; 00485 fputs("Waiting for MySQL server to answer",stderr); 00486 (void) fflush(stderr); 00487 } 00488 else 00489 { 00490 putc('.',stderr); 00491 (void) fflush(stderr); 00492 } 00493 } 00494 sleep(5); 00495 } 00496 }
Here is the call graph for this function:

| static void store_values | ( | MYSQL_RES * | result | ) | [static] |
Definition at line 1198 of file mysqladmin.cc.
References ex_val_max_len, ex_var_count, ex_var_names, last_values, st_mysql_field::max_length, max_val_length, max_var_length, mysql_fetch_field(), mysql_fetch_row(), NULL, strmov(), and strtoull.
Referenced by execute_commands().
01199 { 01200 uint i; 01201 MYSQL_ROW row; 01202 MYSQL_FIELD *field; 01203 01204 field = mysql_fetch_field(result); 01205 max_var_length = field->max_length; 01206 field = mysql_fetch_field(result); 01207 max_val_length = field->max_length; 01208 01209 for (i = 0; (row = mysql_fetch_row(result)); i++) 01210 { 01211 strmov(ex_var_names[i], row[0]); 01212 last_values[i]=strtoull(row[1],NULL,10); 01213 ex_val_max_len[i]=2; /* Default print width for values */ 01214 } 01215 ex_var_count = i; 01216 return; 01217 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void truncate_names | ( | ) | [static] |
Definition at line 1247 of file mysqladmin.cc.
References ex_var_count, ex_var_names, int10_to_str(), last_values, llstr(), MAX_TRUNC_LENGTH, max_val_length, max_var_length, NAME_LEN, strfill(), and truncated_var_names.
Referenced by execute_commands().
01248 { 01249 uint i; 01250 char *ptr,top_line[MAX_TRUNC_LENGTH+4+NAME_LEN+22+1],buff[22]; 01251 01252 ptr=top_line; 01253 *ptr++='+'; 01254 ptr=strfill(ptr,max_var_length+2,'-'); 01255 *ptr++='+'; 01256 ptr=strfill(ptr,MAX_TRUNC_LENGTH+2,'-'); 01257 *ptr++='+'; 01258 ptr=strfill(ptr,max_val_length+2,'-'); 01259 *ptr++='+'; 01260 *ptr=0; 01261 puts(top_line); 01262 01263 for (i = 0 ; i < ex_var_count; i++) 01264 { 01265 uint sfx=1,j; 01266 printf("| %-*s|", max_var_length + 1, ex_var_names[i]); 01267 ptr = ex_var_names[i]; 01268 /* Make sure no two same truncated names will become */ 01269 for (j = 0; j < i; j++) 01270 if (*truncated_var_names[j] == *ptr) 01271 sfx++; 01272 01273 truncated_var_names[i][0]= *ptr; /* Copy first var char */ 01274 int10_to_str(sfx, truncated_var_names[i]+1,10); 01275 printf(" %-*s|", MAX_TRUNC_LENGTH + 1, truncated_var_names[i]); 01276 printf(" %-*s|\n", max_val_length + 1, llstr(last_values[i],buff)); 01277 } 01278 puts(top_line); 01279 return; 01280 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void usage | ( | void | ) | [static] |
Definition at line 1003 of file mysqladmin.cc.
References load_default_groups, my_long_options, my_print_help(), my_print_variables(), my_progname, print_defaults(), and print_version().
01004 { 01005 print_version(); 01006 puts("Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB"); 01007 puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license\n"); 01008 puts("Administration program for the mysqld daemon."); 01009 printf("Usage: %s [OPTIONS] command command....\n", my_progname); 01010 my_print_help(my_long_options); 01011 my_print_variables(my_long_options); 01012 print_defaults("my",load_default_groups); 01013 puts("\nWhere command is a one or more of: (Commands may be shortened)\n\ 01014 create databasename Create a new database\n\ 01015 debug Instruct server to write debug information to log\n\ 01016 drop databasename Delete a database and all its tables\n\ 01017 extended-status Gives an extended status message from the server\n\ 01018 flush-hosts Flush all cached hosts\n\ 01019 flush-logs Flush all logs\n\ 01020 flush-status Clear status variables\n\ 01021 flush-tables Flush all tables\n\ 01022 flush-threads Flush the thread cache\n\ 01023 flush-privileges Reload grant tables (same as reload)\n\ 01024 kill id,id,... Kill mysql threads"); 01025 #if MYSQL_VERSION_ID >= 32200 01026 puts("\ 01027 password new-password Change old password to new-password, MySQL 4.1 hashing.\n\ 01028 old-password new-password Change old password to new-password in old format.\n"); 01029 #endif 01030 puts("\ 01031 ping Check if mysqld is alive\n\ 01032 processlist Show list of active threads in server\n\ 01033 reload Reload grant tables\n\ 01034 refresh Flush all tables and close and open logfiles\n\ 01035 shutdown Take server down\n\ 01036 status Gives a short status message from the server\n\ 01037 start-slave Start slave\n\ 01038 stop-slave Stop slave\n\ 01039 variables Prints variables available\n\ 01040 version Get version info from server"); 01041 }
Here is the call graph for this function:

| static my_bool wait_pidfile | ( | char * | pidfile, | |
| time_t | last_modified, | |||
| struct stat * | pidfile_status | |||
| ) | [static] |
Definition at line 1308 of file mysqladmin.cc.
References count, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, error, FN_REFLEN, interrupted, my_close(), my_open(), MYF, opt_shutdown_timeout, opt_verbose, sleep, and system_filename().
Referenced by execute_commands().
01310 { 01311 char buff[FN_REFLEN]; 01312 int error= 1; 01313 uint count= 0; 01314 DBUG_ENTER("wait_pidfile"); 01315 01316 system_filename(buff, pidfile); 01317 do 01318 { 01319 int fd; 01320 if ((fd= my_open(buff, O_RDONLY, MYF(0))) < 0) 01321 { 01322 error= 0; 01323 break; 01324 } 01325 (void) my_close(fd,MYF(0)); 01326 if (last_modified && !stat(pidfile, pidfile_status)) 01327 { 01328 if (last_modified != pidfile_status->st_mtime) 01329 { 01330 /* File changed; Let's assume that mysqld did restart */ 01331 if (opt_verbose) 01332 printf("pid file '%s' changed while waiting for it to disappear!\nmysqld did probably restart\n", 01333 buff); 01334 error= 0; 01335 break; 01336 } 01337 } 01338 if (count++ == opt_shutdown_timeout) 01339 break; 01340 sleep(1); 01341 } while (!interrupted); 01342 01343 if (error) 01344 { 01345 DBUG_PRINT("warning",("Pid file didn't disappear")); 01346 fprintf(stderr, 01347 "Warning; Aborted waiting on pid file: '%s' after %d seconds\n", 01348 buff, count-1); 01349 } 01350 DBUG_RETURN(error); 01351 }
Here is the call graph for this function:

Here is the caller graph for this function:

const char* command_names[] [static] |
Initial value:
{
"create", "drop", "shutdown",
"reload", "refresh", "version",
"processlist", "status", "kill",
"debug", "variables", "flush-logs",
"flush-hosts", "flush-tables", "password",
"ping", "extended-status", "flush-status",
"flush-privileges", "start-slave", "stop-slave",
"flush-threads","old-password",
NullS
}
Definition at line 109 of file mysqladmin.cc.
TYPELIB command_typelib [static] |
Initial value:
{ array_elements(command_names)-1,"commands", command_names, NULL}
Definition at line 124 of file mysqladmin.cc.
Referenced by execute_commands(), get_query_type(), and main().
| char * default_charset = NULL |
Definition at line 37 of file mysqladmin.cc.
my_bool ex_status_printed = 0 [static] |
Definition at line 66 of file mysqladmin.cc.
Referenced by execute_commands(), and print_relative_row_vert().
uint ex_val_max_len[MAX_MYSQL_VAR] [static] |
Definition at line 65 of file mysqladmin.cc.
Referenced by print_relative_header(), print_relative_line(), print_relative_row_vert(), and store_values().
uint ex_var_count [static] |
Definition at line 67 of file mysqladmin.cc.
Referenced by print_relative_header(), print_relative_line(), store_values(), and truncate_names().
| char ex_var_names[MAX_MYSQL_VAR][FN_REFLEN] |
| char* host = NULL |
Definition at line 36 of file mysqladmin.cc.
Referenced by acl_load(), change_security_context(), check_acl_user(), check_grant_routine(), check_node_vs_replicas(), checkTCPConstraints(), cleanup(), compare_hostname(), CommandInterpreter::connect(), fill_schema_column_privileges(), fill_schema_processlist(), fill_schema_schema_privileges(), fill_schema_table_privileges(), fill_schema_user_privileges(), handle_grant_struct(), handle_grant_table(), main(), mysql_revoke_all(), mysql_show_grants(), run_task(), safe_connect(), show_routine_grants(), sql_connect(), and update_hostname().
my_bool interrupted = 0 [static] |
Definition at line 42 of file mysqladmin.cc.
Referenced by endprog(), main(), net_real_write(), and wait_pidfile().
int interval = 0 [static] |
Definition at line 41 of file mysqladmin.cc.
Referenced by calculate_interval_lengths(), date_add_interval(), Item_date_add_interval::get_date(), get_interval_id(), get_interval_value(), get_next_time(), main(), make_field(), mysql_prepare_table(), and unhex_type2().
| ulonglong last_values[MAX_MYSQL_VAR] |
Definition at line 40 of file mysqladmin.cc.
Referenced by print_relative_row(), print_relative_row_vert(), store_values(), and truncate_names().
const char* load_default_groups[] = { "mysqladmin","client",0 } [static] |
Definition at line 220 of file mysqladmin.cc.
uint max_val_length [static] |
uint max_var_length [static] |
struct my_option my_long_options[] [static] |
Definition at line 127 of file mysqladmin.cc.
uint nr_iterations [static] |
my_bool opt_compress = 0 [static] |
Definition at line 43 of file mysqladmin.cc.
ulong opt_connect_timeout [static] |
Definition at line 47 of file mysqladmin.cc.
uint opt_count_iterations = 0 [static] |
| char * opt_password = 0 |
Definition at line 36 of file mysqladmin.cc.
uint opt_protocol = 0 [static] |
Definition at line 57 of file mysqladmin.cc.
my_bool opt_relative = 0 [static] |
ulong opt_shutdown_timeout [static] |
my_bool opt_verbose = 0 [static] |
Definition at line 43 of file mysqladmin.cc.
my_bool opt_vertical = 0 [static] |
my_bool option_force = 0 [static] |
uint option_silent = 0 [static] |
Definition at line 45 of file mysqladmin.cc.
Referenced by execute_commands(), get_one_option(), and sql_connect().
uint option_wait = 0 [static] |
| char truncated_var_names[MAX_MYSQL_VAR][MAX_TRUNC_LENGTH] |
Definition at line 38 of file mysqladmin.cc.
Referenced by print_relative_header(), and truncate_names().
my_bool tty_password = 0 [static] |
Definition at line 44 of file mysqladmin.cc.
| char * user = 0 |
Definition at line 36 of file mysqladmin.cc.
1.4.7

