⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mysql.cc

📁 这是linux下运行的mysql软件包,可用于linux 下安装 php + mysql + apach 的网络配置
💻 CC
📖 第 1 页 / 共 5 页
字号:
#ifdef HAVE_READLINE  initialize_readline((char*) my_progname);  if (!status.batch && !quick && !opt_html && !opt_xml)  {    /* read-history from file, default ~/.mysql_history*/    if (getenv("MYSQL_HISTFILE"))      histfile=my_strdup(getenv("MYSQL_HISTFILE"),MYF(MY_WME));    else if (getenv("HOME"))    {      histfile=(char*) my_malloc((uint) strlen(getenv("HOME"))				 + (uint) strlen("/.mysql_history")+2,				 MYF(MY_WME));      if (histfile)	sprintf(histfile,"%s/.mysql_history",getenv("HOME"));    }    if (histfile)    {      if (verbose)	tee_fprintf(stdout, "Reading history-file %s\n",histfile);      read_history(histfile);      if (!(histfile_tmp= (char*) my_malloc((uint) strlen(histfile) + 5,					    MYF(MY_WME))))      {	fprintf(stderr, "Couldn't allocate memory for temp histfile!\n");	exit(1);      }      sprintf(histfile_tmp, "%s.TMP", histfile);    }  }#endif  sprintf(buff, "%s",#ifndef NOT_YET	  "Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.\n");#else	  "Type 'help [[%]function name[%]]' to get help on usage of function.\n");#endif  put_info(buff,INFO_INFO);  status.exit_status= read_and_execute(!status.batch);  if (opt_outfile)    end_tee();  mysql_end(0);#ifndef _lint  DBUG_RETURN(0);				// Keep compiler happy#endif}sig_handler mysql_end(int sig){  mysql_close(&mysql);#ifdef HAVE_READLINE  if (!status.batch && !quick && !opt_html && !opt_xml)  {    /* write-history */    if (verbose)      tee_fprintf(stdout, "Writing history-file %s\n",histfile);    if (!write_history(histfile_tmp))      my_rename(histfile_tmp, histfile, MYF(MY_WME));  }  batch_readline_end(status.line_buff);  completion_hash_free(&ht);  free_root(&hash_mem_root,MYF(0));#endif  if (sig >= 0)    put_info(sig ? "Aborted" : "Bye", INFO_RESULT);  glob_buffer.free();  old_buffer.free();  processed_prompt.free();  my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));  my_free(opt_mysql_unix_port,MYF(MY_ALLOW_ZERO_PTR));  my_free(histfile,MYF(MY_ALLOW_ZERO_PTR));  my_free(histfile_tmp,MYF(MY_ALLOW_ZERO_PTR));  my_free(current_db,MYF(MY_ALLOW_ZERO_PTR));  my_free(current_host,MYF(MY_ALLOW_ZERO_PTR));  my_free(current_user,MYF(MY_ALLOW_ZERO_PTR));  my_free(full_username,MYF(MY_ALLOW_ZERO_PTR));  my_free(part_username,MYF(MY_ALLOW_ZERO_PTR));  my_free(default_prompt,MYF(MY_ALLOW_ZERO_PTR));#ifdef HAVE_SMEM  my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));#endif  my_free(current_prompt,MYF(MY_ALLOW_ZERO_PTR));  mysql_server_end();  free_defaults(defaults_argv);  my_end(info_flag ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);  exit(status.exit_status);}static struct my_option my_long_options[] ={  {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0,   0, 0, 0, 0, 0},  {"help", 'I', "Synonym for -?", 0, 0, 0, GET_NO_ARG, NO_ARG, 0,   0, 0, 0, 0, 0},#ifdef __NETWARE__  {"autoclose", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.",   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},#endif  {"auto-rehash", OPT_AUTO_REHASH,   "Enable automatic rehashing. One doesn't need to use 'rehash' to get table and field completion, but startup and reconnecting may take a longer time. Disable with --disable-auto-rehash.",   (gptr*) &rehash, (gptr*) &rehash, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},  {"no-auto-rehash", 'A',   "No automatic rehashing. One has to use 'rehash' to get table and field completion. This gives a quicker start of mysql and disables rehashing on reconnect. WARNING: options deprecated; use --disable-auto-rehash instead.",   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},  {"batch", 'B',   "Don't use history file. Disable interactive behavior. (Enables --silent)", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},  {"character-sets-dir", OPT_CHARSETS_DIR,   "Directory where character sets are.", (gptr*) &charsets_dir,   (gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},  {"default-character-set", OPT_DEFAULT_CHARSET,   "Set the default character set.", (gptr*) &default_charset,   (gptr*) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},  {"compress", 'C', "Use compression in server/client protocol.",   (gptr*) &opt_compress, (gptr*) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0,   0, 0, 0},#ifdef DBUG_OFF  {"debug", '#', "This is a non-debug version. Catch this and exit",   0,0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0},#else  {"debug", '#', "Output debug log", (gptr*) &default_dbug_option,   (gptr*) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},#endif  {"database", 'D', "Database to use.", (gptr*) &current_db,   (gptr*) &current_db, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},  {"delimiter", OPT_DELIMITER, "Delimiter to be used.", (gptr*) &delimiter_str,   (gptr*) &delimiter_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},  {"execute", 'e', "Execute command and quit. (Disables --force and history file)", 0,   0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},  {"vertical", 'E', "Print the output of a query (rows) vertically.",   (gptr*) &vertical, (gptr*) &vertical, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,   0},  {"force", 'f', "Continue even if we get an sql error.",   (gptr*) &ignore_errors, (gptr*) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0,   0, 0, 0, 0},  {"no-named-commands", 'g',   "Named commands are disabled. Use \\* form only, or use named commands only in the beginning of a line ending with a semicolon (;) Since version 10.9 the client now starts with this option ENABLED by default! Disable with '-G'. Long format commands still work from the first line. WARNING: option deprecated; use --disable-named-commands instead.",   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},  {"named-commands", 'G',   "Enable named commands. Named commands mean this program's internal commands; see mysql> help . When enabled, the named commands can be used from any line of the query, otherwise only from the first line, before an enter. Disable with --disable-named-commands. This option is disabled by default.",   (gptr*) &named_cmds, (gptr*) &named_cmds, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,   0, 0},  {"ignore-spaces", 'i', "Ignore space after function names.", 0, 0, 0,   GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},  {"local-infile", OPT_LOCAL_INFILE, "Enable/disable LOAD DATA LOCAL INFILE.",   (gptr*) &opt_local_infile,   (gptr*) &opt_local_infile, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},  {"no-beep", 'b', "Turn off beep on error.", (gptr*) &opt_nobeep,   (gptr*) &opt_nobeep, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},   {"host", 'h', "Connect to host.", (gptr*) &current_host,   (gptr*) &current_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},  {"html", 'H', "Produce HTML output.", (gptr*) &opt_html, (gptr*) &opt_html,   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},  {"xml", 'X', "Produce XML output", (gptr*) &opt_xml, (gptr*) &opt_xml, 0,   GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},  {"line-numbers", OPT_LINE_NUMBERS, "Write line numbers for errors.",   (gptr*) &line_numbers, (gptr*) &line_numbers, 0, GET_BOOL,   NO_ARG, 1, 0, 0, 0, 0, 0},    {"skip-line-numbers", 'L', "Don't write line number for errors. WARNING: -L is deprecated, use long version of this option instead.", 0, 0, 0, GET_NO_ARG,   NO_ARG, 0, 0, 0, 0, 0, 0},#ifdef USE_POPEN  {"no-pager", OPT_NOPAGER,   "Disable pager and print to stdout. See interactive help (\\h) also. WARNING: option deprecated; use --disable-pager instead.",   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},#endif  {"no-tee", OPT_NOTEE, "Disable outfile. See interactive help (\\h) also. WARNING: option deprecated; use --disable-tee instead", 0, 0, 0, GET_NO_ARG,   NO_ARG, 0, 0, 0, 0, 0, 0},  {"unbuffered", 'n', "Flush buffer after each query.", (gptr*) &unbuffered,   (gptr*) &unbuffered, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},  {"column-names", OPT_COLUMN_NAMES, "Write column names in results.",   (gptr*) &column_names, (gptr*) &column_names, 0, GET_BOOL,   NO_ARG, 1, 0, 0, 0, 0, 0},  {"skip-column-names", 'N',   "Don't write column names in results. WARNING: -N is deprecated, use long version of this options instead.",   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},  {"set-variable", 'O',   "Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value.",   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},  {"sigint-ignore", OPT_SIGINT_IGNORE, "Ignore SIGINT (CTRL-C)",   (gptr*) &opt_sigint_ignore,  (gptr*) &opt_sigint_ignore, 0, GET_BOOL,   NO_ARG, 0, 0, 0, 0, 0, 0},  {"one-database", 'o',   "Only update the default database. This is useful for skipping updates to other database in the update log.",   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},#ifdef USE_POPEN  {"pager", OPT_PAGER,   "Pager to use to display results. If you don't supply an option the default pager is taken from your ENV variable PAGER. Valid pagers are less, more, cat [> filename], etc. See interactive help (\\h) also. This option does not work in batch mode.",   0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},#endif  {"password", 'p',   "Password to use when connecting to server. If password is not given it's asked from the tty.",   0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},#ifdef __WIN__  {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,   NO_ARG, 0, 0, 0, 0, 0, 0},#endif  {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port,   (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0,   0},  {"prompt", OPT_PROMPT, "Set the mysql prompt to this value.",   (gptr*) &current_prompt, (gptr*) &current_prompt, 0, GET_STR_ALLOC,   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},  {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).",   0, 0, 0, GET_STR,  REQUIRED_ARG, 0, 0, 0, 0, 0, 0},  {"quick", 'q',   "Don't cache result, print it row by row. This may slow down the server if the output is suspended. Doesn't use history file.",   (gptr*) &quick, (gptr*) &quick, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},  {"raw", 'r', "Write fields without conversion. Used with --batch.",   (gptr*) &opt_raw_data, (gptr*) &opt_raw_data, 0, GET_BOOL, NO_ARG, 0, 0, 0,   0, 0, 0},  {"reconnect", OPT_RECONNECT, "Reconnect if the connection is lost. Disable with --disable-reconnect. This option is enabled by default.",    (gptr*) &opt_reconnect, (gptr*) &opt_reconnect, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},  {"silent", 's', "Be more silent. Print results with a tab as separator, each row on new line.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0,   0, 0},#ifdef HAVE_SMEM  {"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,   "Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name,    0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},#endif  {"socket", 'S', "Socket file to use for connection.",   (gptr*) &opt_mysql_unix_port, (gptr*) &opt_mysql_unix_port, 0, GET_STR_ALLOC,   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},#include "sslopt-longopts.h"  {"table", 't', "Output in table format.", (gptr*) &output_tables,   (gptr*) &output_tables, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},  {"debug-info", 'T', "Print some debug info at exit.", (gptr*) &info_flag,   (gptr*) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},  {"tee", OPT_TEE,   "Append everything into outfile. See interactive help (\\h) also. Does not work in batch mode.",   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},#ifndef DONT_ALLOW_USER_CHANGE  {"user", 'u', "User for login if not current user.", (gptr*) &current_user,   (gptr*) &current_user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},#endif  {"safe-updates", 'U', "Only allow UPDATE and DELETE that uses keys.",   (gptr*) &safe_updates, (gptr*) &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0,   0, 0, 0, 0},  {"i-am-a-dummy", 'U', "Synonym for option --safe-updates, -U.",   (gptr*) &safe_updates, (gptr*) &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0,   0, 0, 0, 0},  {"verbose", 'v', "Write more. (-v -v -v gives the table output format).", 0,   0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},  {"version", 'V', "Output version information and exit.", 0, 0, 0,   GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},  {"wait", 'w', "Wait and retry if connection is down.", 0, 0, 0, GET_NO_ARG,   NO_ARG, 0, 0, 0, 0, 0, 0},  {"connect_timeout", OPT_CONNECT_TIMEOUT,   "Number of seconds before connection timeout.",   (gptr*) &opt_connect_timeout,   (gptr*) &opt_connect_timeout, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 3600*12, 0,   0, 1},  {"max_allowed_packet", OPT_MAX_ALLOWED_PACKET,   "Max packet length to send to, or receive from server",   (gptr*) &opt_max_allowed_packet, (gptr*) &opt_max_allowed_packet, 0, GET_ULONG,   REQUIRED_ARG, 16 *1024L*1024L, 4096, (longlong) 2*1024L*1024L*1024L,   MALLOC_OVERHEAD, 1024, 0},  {"net_buffer_length", OPT_NET_BUFFER_LENGTH,   "Buffer for TCP/IP and socket communication",   (gptr*) &opt_net_buffer_length, (gptr*) &opt_net_buffer_length, 0, GET_ULONG,   REQUIRED_ARG, 16384, 1024, 512*1024*1024L, MALLOC_OVERHEAD, 1024, 0},  {"select_limit", OPT_SELECT_LIMIT,   "Automatic limit for SELECT when using --safe-updates",   (gptr*) &select_limit,   (gptr*) &select_limit, 0, GET_ULONG, REQUIRED_ARG, 1000L, 1, ~0L, 0, 1, 0},  {"max_join_size", OPT_MAX_JOIN_SIZE,   "Automatic limit for rows in a join when using --safe-updates",   (gptr*) &max_join_size,   (gptr*) &max_join_size, 0, GET_ULONG, REQUIRED_ARG, 1000000L, 1, ~0L, 0, 1,   0},  {"secure-auth", OPT_SECURE_AUTH, "Refuse client connecting to server if it"    " uses old (pre-4.1.1) protocol", (gptr*) &opt_secure_auth,    (gptr*) &opt_secure_auth, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},  {"show-warnings", OPT_SHOW_WARNINGS, "Show warnings after every statement.",    (gptr*) &show_warnings, (gptr*) &show_warnings, 0, GET_BOOL, NO_ARG,     0, 0, 0, 0, 0, 0},  { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}};static void usage(int version){  /* Divert all help information on NetWare to logger screen. */#ifdef __NETWARE__#define printf	consoleprintf#endif#if defined(USE_LIBEDIT_INTERFACE)  const char* readline= "";#else  const char* readline= "readline";#endif#ifdef HAVE_READLINE  printf("%s  Ver %s Distrib %s, for %s (%s) using %s %s\n",	 my_progname, VER, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE,         readline, rl_library_version);#else  printf("%s  Ver %s Distrib %s, for %s (%s)\n", my_progname, VER,	MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);#endif  if (version)    return;  printf("\Copyright (C) 2002 MySQL AB\n\This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n\and you are welcome to modify and redistribute it under the GPL license\n");  printf("Usage: %s [OPTIONS] [database]\n", my_progname);  my_print_help(my_long_options);  print_defaults("my", load_default_groups);  my_print_variables(my_long_options);  NETWARE_SET_SCREEN_MODE(1);#ifdef __NETWARE__#undef printf#endif}static my_boolget_one_option(int optid, const struct my_option *opt __attribute__((unused)),	       char *argument){  switch(optid) {#ifdef __NETWARE__  case OPT_AUTO_CLOSE:    setscreenmode(SCR_AUTOCLOSE_ON_EXIT);    break;#endif  case OPT_CHARSETS_DIR:    strmov(mysql_charsets_dir, argument);    charsets_dir = mysql_charsets_dir;    break;  case  OPT_DEFAULT_CHARSET:    default_charset_used= 1;    break;  case OPT_DELIMITER:    if (argument == disabled_my_option)      strmov(delimiter, DEFAULT_DELIMITER);    else      strmake(delimiter, argument, sizeof(delimiter) - 1);    delimiter_length= (uint)strlen(delimiter);    delimiter_str= delimiter;    break;  case OPT_LOCAL_INFILE:    using_opt_local_infile=1;    break;  case OPT_TEE:    if (argument == disabled_my_option)    {      if (opt_outfile)	end_tee();    }    else      init_tee(argument);    break;  case OPT_NOTEE:    printf("WARNING: option deprecated; use --disable-tee instead.\n");    if (opt_outfile)      end_tee();    break;  case OPT_PAGER:    if (argument == disabled_my_option)      opt_nopager= 1;    else    {      opt_nopager= 0;      if (argument && strlen(argument))      {	default_pager_set= 1;	strmov(pager, argument);	strmov(default_pager, pager);      }      else if (default_pager_set)	strmov(pager, default_pager);      else	opt_nopager= 1;    }    break;  case OPT_NOPAGER:    printf("WARNING: option deprecated; use --disable-pager instead.\n");    opt_nopager= 1;  case OPT_MYSQL_PROTOCOL:  {    if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0)    {      fprintf(stderr, "Unknown option to protocol: %s\n", argument);      exit(1);    }    break;  }  break;  case 'A':    rehash= 0;    break;  case 'N':    column_names= 0;    break;  case 'e':    status.batch= 1;    status.add_to_history= 0;    if (!status.line_buff)      ignore_errors= 0;                         // do it for the first -e only    if (!(status.line_buff= batch_readline_command(status.line_buff, argument)))      return 1;    break;  case 'o':    if (argument == disabled_my_option)      one_database= 0;    else      one_database= skip_updates= 1;    break;  case 'p':    if (argument == disabled_my_option)      argument= (char*) "";			// Don't require password    if (argument)    {      char *start= argument;      my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));      opt_password= my_strdup(argument, MYF(MY_FAE));      while (*argument) *argument++= 'x';		// Destroy argument      if (*start)	start[1]=0 ;      tty_password= 0;    }    else      tty_password= 1;    break;  case '#':    DBUG_PUSH(argument ? argument : default_dbug_option);    info_flag= 1;    break;  case 's':    if (argument == disabled_my_option)      opt_silent= 0;    else      opt_silent++;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -