Chapter 5. Database Administration

Table of Contents

5.1. Overview of Server-Side Programs
5.2. mysqld — The MySQL Server
5.2.1. Option and Variable Reference
5.2.2. Command Options
5.2.3. System Variables
5.2.4. Using System Variables
5.2.5. Status Variables
5.2.6. SQL Modes
5.2.7. The Shutdown Process
5.2.8. Server-Side Help
5.3. MySQL Server Startup Programs
5.3.1. mysqld_safe — MySQL Server Startup Script
5.3.2. mysql.server — MySQL Server Startup Script
5.3.3. mysqld_multi — Manage Multiple MySQL Servers
5.4. mysqlmanager — The MySQL Instance Manager
5.4.1. MySQL Instance Manager Command Options
5.4.2. MySQL Instance Manager Configuration Files
5.4.3. Starting the MySQL Server with MySQL Instance Manager
5.4.4. Instance Manager User and Password Management
5.4.5. MySQL Server Instance Status Monitoring
5.4.6. Connecting to MySQL Instance Manager
5.4.7. MySQL Instance Manager Commands
5.5. Installation-Related Programs
5.5.1. comp_err — Compile MySQL Error Message File
5.5.2. make_win_bin_dist — Package MySQL Distribution as ZIP Archive
5.5.3. mysql_fix_privilege_tables — Upgrade MySQL System Tables
5.5.4. mysql_install_db — MySQL Data Directory Initialization Script
5.5.5. mysql_secure_installation — Improve MySQL Installation Security
5.5.6. mysql_tzinfo_to_sql — Load the Time Zone Tables
5.5.7. mysql_upgrade — Check Tables for MySQL Upgrade
5.6. General Security Issues
5.6.1. General Security Guidelines
5.6.2. Making MySQL Secure Against Attackers
5.6.3. Security-Related mysqld Options
5.6.4. Security Issues with LOAD DATA LOCAL
5.6.5. How to Run MySQL as a Normal User
5.7. The MySQL Access Privilege System
5.7.1. What the Privilege System Does
5.7.2. How the Privilege System Works
5.7.3. Privileges Provided by MySQL
5.7.4. Connecting to the MySQL Server
5.7.5. Access Control, Stage 1: Connection Verification
5.7.6. Access Control, Stage 2: Request Verification
5.7.7. When Privilege Changes Take Effect
5.7.8. Causes of Access denied Errors
5.7.9. Password Hashing as of MySQL 4.1
5.8. MySQL User Account Management
5.8.1. MySQL Usernames and Passwords
5.8.2. Adding New User Accounts to MySQL
5.8.3. Removing User Accounts from MySQL
5.8.4. Limiting Account Resources
5.8.5. Assigning Account Passwords
5.8.6. Keeping Your Password Secure
5.8.7. Using Secure Connections
5.9. Backup and Recovery
5.9.1. Database Backups
5.9.2. Example Backup and Recovery Strategy
5.9.3. Point-in-Time Recovery
5.9.4. Table Maintenance and Crash Recovery
5.10. MySQL Localization and International Usage
5.10.1. The Character Set Used for Data and Sorting
5.10.2. Setting the Error Message Language
5.10.3. Adding a New Character Set
5.10.4. The Character Definition Arrays
5.10.5. String Collating Support
5.10.6. Multi-Byte Character Support
5.10.7. Problems With Character Sets
5.10.8. MySQL Server Time Zone Support
5.10.9. MySQL Server Locale Support
5.11. MySQL Server Logs
5.11.1. Selecting General Query and Slow Query Log Output Destinations
5.11.2. The Error Log
5.11.3. The General Query Log
5.11.4. The Binary Log
5.11.5. The Slow Query Log
5.11.6. Server Log Maintenance
5.12. Running Multiple MySQL Servers on the Same Machine
5.12.1. Running Multiple Servers on Windows
5.12.2. Running Multiple Servers on Unix
5.12.3. Using Client Programs in a Multiple-Server Environment
5.13. The MySQL Query Cache
5.13.1. How the Query Cache Operates
5.13.2. Query Cache SELECT Options
5.13.3. Query Cache Configuration
5.13.4. Query Cache Status and Maintenance

This chapter covers topics that deal with administering a MySQL installation:

5.1. Overview of Server-Side Programs

The MySQL server, mysqld, is the main program that does most of the work in a MySQL installation. The server is accompanied by several related scripts that perform setup operations when you install MySQL or that assist you in starting and stopping the server. This section provides an overview of the server and related programs. The following sections provide more detailed information about each of these programs.

Each MySQL program takes many different options. Most programs provide a --help option that you can use to get a description of the program's different options. For example, try mysqld --help.

You can override default option values for MySQL programs by specifying options on the command line or in an option file. Section 4.3, “Specifying Program Options”.

The following list briefly describes the MySQL server and server-related programs:

There are several other programs that are related to MySQL installation or upgrading:

5.2. mysqld — The MySQL Server

mysqld is the MySQL server. The following discussion covers these MySQL server configuration topics:

  • Startup options that the server supports

  • Server system variables

  • Server status variables

  • How to set the server SQL mode

  • The server shutdown process

Note: Not all storage engines are supported by all MySQL server binaries and configurations. To find out how to determine which storage engines are supported by your MySQL server installation, see Section 13.5.4.13, “SHOW ENGINES Syntax”.

5.2.1. Option and Variable Reference

The following table provides a list of all the command line options, server and status variables applicable within mysqld.

The table lists command line options (Cmd-line), options valid in configuration files (Option file), server system variables (Server Var), and status variables (Status var) in one unified list, with notification of where each option/variable is valid. If a server option set on the command line or in an option file differs from the name of the corresponding server system or status variable, the variable name is noted immediately below the corresponding option. For status variables, the scope of the variable is shown (Scope) as either global, session, or both. Please see the corresponding sections for details on setting and using the options and variables. Where appropriate, a direct link to further information on the item as available.

Note

This table is part of an ongoing process to expand and simplify the information provided on these elements. Further improvements to the table, and corresponding descriptions will be applied over the coming months.

NameCmd-lineOption fileServer VarStatus VarVar ScopeDynamic
abort-slave-event-countYY    
Aborted_clients   Ybothno
Aborted_connects   Ybothno
allow-suspicious-udfsYY    
ansiYY    
auto-increment-incrementYY  bothno
- Variable: auto_increment_increment  Y bothno
auto-increment-offsetYY  bothno
- Variable: auto_increment_offset  Y bothno
autocommitYYY sessionyes
automatic_sp_privilegesYYY bothno
back_logYYY bothno
basedirYYY bothno
bdb-data-direct  Y bothno
bdb-log-direct  Y bothno
big-tablesYY   yes
- Variable: big_tables  Y  yes
bind-addressYY    
binlog-do-dbYY    
binlog-ignore-dbYY    
binlog-row-event-max-sizeYY    
Binlog_cache_disk_use   Ybothno
binlog_cache_sizeYYY bothyes
Binlog_cache_use   Ybothno
binlog_formatYYY bothno
bootstrapYY    
bulk_insert_buffer_sizeYYY bothyes
Bytes_received   Ybothno
Bytes_sent   Ybothno
character-set-client-handshakeY     
character-set-filesystemYY  bothno
- Variable: character_set_filesystem  Y bothno
character-set-serverYY  bothyes
- Variable: character_set_server  Y bothyes
character-sets-dirYY  bothno
- Variable: character_sets_dir  Y bothno
character_set_client  Y bothyes
character_set_connection  Y bothyes
character_set_database  Y bothyes
character_set_results  Y bothyes
character_set_system  Y bothyes
chrootYY    
collation_connectionYYY bothyes
collation_databaseYYY bothyes
collation_serverYYY bothyes
Com_admin_commands   Ybothno
Com_alter_db   Ybothno
Com_alter_event   Ybothno
Com_alter_table   Ybothno
Com_analyze   Ybothno
Com_backup_table   Ybothno
Com_begin   Ybothno
Com_change_db   Ybothno
Com_change_master   Ybothno
Com_check   Ybothno
Com_checksum   Ybothno
Com_commit   Ybothno
Com_create_db   Ybothno
Com_create_event   Ybothno
Com_create_function   Ybothno
Com_create_index   Ybothno
Com_create_table   Ybothno
Com_create_user   Ybothno
Com_dealloc_sql   Ybothno
Com_delete   Ybothno
Com_delete_multi   Ybothno
Com_do   Ybothno
Com_drop_db   Ybothno
Com_drop_event   Ybothno
Com_drop_function   Ybothno
Com_drop_index   Ybothno
Com_drop_table   Ybothno
Com_drop_user   Ybothno
Com_execute_sql   Ybothno
Com_flush   Ybothno
Com_grant   Ybothno
Com_ha_close   Ybothno
Com_ha_open   Ybothno
Com_ha_read   Ybothno
Com_help   Ybothno
Com_insert   Ybothno
Com_insert_select   Ybothno
Com_kill   Ybothno
Com_load   Ybothno
Com_lock_tables   Ybothno
Com_optimize   Ybothno
Com_preload_keys   Ybothno
Com_prepare_sql   Ybothno
Com_purge   Ybothno
Com_purge_before_date   Ybothno
Com_rename_table   Ybothno
Com_repair   Ybothno
Com_replace   Ybothno
Com_replace_select   Ybothno
Com_reset   Ybothno
Com_restore_table   Ybothno
Com_revoke   Ybothno
Com_revoke_all   Ybothno
Com_rollback   Ybothno
Com_savepoint   Ybothno
Com_select   Ybothno
Com_set_option   Ybothno
Com_show_binlog_events   Ybothno
Com_show_binlogs   Ybothno
Com_show_charsets   Ybothno
Com_show_collations   Ybothno
Com_show_column_types   Ybothno
Com_show_create_db   Ybothno
Com_show_create_event   Ybothno
Com_show_create_table   Ybothno
Com_show_databases   Ybothno
Com_show_engine_logs   Ybothno
Com_show_engine_mutex   Ybothno
Com_show_engine_status   Ybothno
Com_show_errors   Ybothno
Com_show_events   Ybothno
Com_show_fields   Ybothno
Com_show_grants   Ybothno
Com_show_keys   Ybothno
Com_show_master_status   Ybothno
Com_show_new_master   Ybothno
Com_show_open_tables   Ybothno
Com_show_plugins   Ybothno
Com_show_privileges   Ybothno
Com_show_processlist   Ybothno
Com_show_slave_hosts   Ybothno
Com_show_slave_status   Ybothno
Com_show_status   Ybothno
Com_show_storage_engines   Ybothno
Com_show_tables   Ybothno
Com_show_triggers   Ybothno
Com_show_variables   Ybothno
Com_show_warnings   Ybothno
Com_slave_start   Ybothno
Com_slave_stop   Ybothno
Com_stmt_close   Ybothno
Com_stmt_execute   Ybothno
Com_stmt_fetch   Ybothno
Com_stmt_prepare   Ybothno
Com_stmt_reset   Ybothno
Com_stmt_send_long_data   Ybothno
Com_truncate   Ybothno
Com_unlock_tables   Ybothno
Com_update   Ybothno
Com_update_multi   Ybothno
Com_xa_commit   Ybothno
Com_xa_end   Ybothno
Com_xa_prepare   Ybothno
Com_xa_recover   Ybothno
Com_xa_rollback   Ybothno
Com_xa_start   Ybothno
completion_typeYYY bothyes
Compression   Ybothno
concurrent-insertYY  bothyes
- Variable: concurrent_insert  Y bothyes
connect_timeoutYYY bothyes
Connections   Ybothno
consoleYY    
core-fileYY    
Created_tmp_disk_tables   Ybothno
Created_tmp_files   Ybothno
Created_tmp_tables   Ybothno
datadirYYY bothno
date_formatY Y bothyes
datetime_formatY Y bothyes
debugYY    
default-storage-engineYY    
default-table-typeYY    
default-time-zoneYY    
- Variable: time_zone      
default_week_formatYYY bothyes
defaults-extra-fileY     
defaults-fileY     
defaults-group-suffixY     
delay-key-writeYY  bothyes
- Variable: delay_key_write  Y bothyes
Delayed_errors   Ybothno
delayed_insert_limitYYY bothyes
Delayed_insert_threads   Ybothno
delayed_insert_timeoutYYY bothyes
delayed_queue_sizeYYY bothyes
Delayed_writes   Ybothno
des-key-fileYYY  no
disconnect-slave-event-countYY    
div_precision_incrementYYY bothyes
enable-lockingY     
enable-pstackYY    
engine-condition-pushdownYY  bothyes
- Variable: engine_condition_pushdown  Y bothyes
error_count   Ysessionyes
event-schedulerYY   yes
- Variable: event_scheduler  Y  yes
exit-infoYY    
expire_logs_daysYYY bothyes
external-lockingYY    
flushYYY bothyes
Flush_commands   Ybothno
flush_timeYYY bothyes
foreign_key_checksY Y sessionyes
ft_boolean_syntaxYYY bothyes
ft_max_word_lenYYY bothyes
ft_min_word_lenYYY globalyes
ft_query_expansion_limitYYY bothyes
ft_stopword_fileYYY bothyes
gdbYY    
general-logYY  globalno
- Variable: general_log  Y globalno
general_log_file  Y globalno
group_concat_max_lenYYY bothyes
Handler_commit   Ybothno
Handler_delete   Ybothno
Handler_discover   Ybothno
Handler_prepare   Ybothno
Handler_read_first   Ybothno
Handler_read_key   Ybothno
Handler_read_next   Ybothno
Handler_read_prev   Ybothno
Handler_read_rnd   Ybothno
Handler_read_rnd_next   Ybothno
Handler_rollback   Ybothno
Handler_savepoint   Ybothno
Handler_savepoint_rollback   Ybothno
Handler_update   Ybothno
Handler_write   Ybothno
have_archive   Ybothno
have_blackhole_engine   Ybothno
have_compress   Ybothno
have_crypt   Ybothno
have_csv   Ybothno
have_dynamic_loading   Ybothno
have_example_engine   Ybothno
have_federated_engine   Ybothno
have_geometry   Ybothno
have_innodb   Ybothno
have_isam   Ybothno
have_merge_engine   Ybothno
have_ndbcluster   Ybothno
have_openssl   Ybothno
have_partition_engine   Yglobalno
have_partitioning   Yglobalno
have_query_cache   Ybothno
have_raid   Ybothno
have_row_based_replication   Yglobalno
have_rtree_keys   Ybothno
have_symlink   Ybothno
helpY     
hostname  Y globalno
identityYYY sessionyes
init-fileYY  bothno
- Variable: init_file  Y bothno
init_connectYYY bothno
init_slaveYYY bothno
innodbYY    
innodb-doublewriteYY  bothno
- Variable: innodb_doublewrite  Y bothno
innodb_additional_mem_pool_sizeYYY bothno
innodb_autoextend_incrementYYY bothyes
innodb_buffer_pool_awe_mem_mbYYY bothno
Innodb_buffer_pool_pages_data   Ybothno
Innodb_buffer_pool_pages_dirty   Ybothno
Innodb_buffer_pool_pages_flushed   Ybothno
Innodb_buffer_pool_pages_free   Ybothno
Innodb_buffer_pool_pages_latched   Ybothno
Innodb_buffer_pool_pages_misc   Ybothno
Innodb_buffer_pool_pages_total   Ybothno
Innodb_buffer_pool_read_ahead_rnd   Ybothno
Innodb_buffer_pool_read_ahead_seq   Ybothno
Innodb_buffer_pool_read_requests   Ybothno
Innodb_buffer_pool_reads   Ybothno
innodb_buffer_pool_sizeYYY bothno
Innodb_buffer_pool_wait_free   Ybothno
Innodb_buffer_pool_write_requests   Ybothno
innodb_checksumsYYY bothyes
innodb_commit_concurrencyYYY bothyes
innodb_concurrency_ticketsYYY bothyes
innodb_data_file_pathYYY bothno
Innodb_data_fsyncs   Ybothno
innodb_data_home_dirYYY bothno
Innodb_data_pending_fsyncs   Ybothno
Innodb_data_pending_reads   Ybothno
Innodb_data_pending_writes   Ybothno
Innodb_data_read   Ybothno
Innodb_data_reads   Ybothno
Innodb_data_writes   Ybothno
Innodb_data_written   Ybothno
Innodb_dblwr_pages_written   Ybothno
Innodb_dblwr_writes   Ybothno
innodb_fast_shutdownYYY bothno
innodb_file_io_threadsYYY bothno
innodb_file_per_tableYYY bothno
innodb_flush_log_at_trx_commitYYY bothno
innodb_flush_methodYYY bothno
innodb_force_recoveryYYY bothno
innodb_lock_wait_timeoutYYY bothno
innodb_locks_unsafe_for_binlogYYY bothno
innodb_log_arch_dirYYY bothno
innodb_log_archiveYYY bothno
innodb_log_buffer_sizeYYY bothno
innodb_log_file_sizeYYY bothno
innodb_log_files_in_groupYYY bothno
innodb_log_group_home_dirYYY bothno
Innodb_log_waits   Ybothno
Innodb_log_write_requests   Ybothno
Innodb_log_writes   Ybothno
innodb_max_dirty_pages_pctYYY bothyes
innodb_max_purge_lagYYY bothyes
innodb_mirrored_log_groupsYYY bothno
innodb_open_filesYYY bothno
Innodb_os_log_fsyncs   Ybothno
Innodb_os_log_pending_fsyncs   Ybothno
Innodb_os_log_pending_writes   Ybothno
Innodb_os_log_written   Ybothno
Innodb_page_size   Ybothno
Innodb_pages_created   Ybothno
Innodb_pages_read   Ybothno
Innodb_pages_written   Ybothno
innodb_rollback_on_timeoutYYY  no
Innodb_row_lock_current_waits   Ybothno
Innodb_row_lock_time   Ybothno
Innodb_row_lock_time_avg   Ybothno
Innodb_row_lock_time_max   Ybothno
Innodb_row_lock_waits   Ybothno
Innodb_rows_deleted   Ybothno
Innodb_rows_inserted   Ybothno
Innodb_rows_read   Ybothno
Innodb_rows_updated   Ybothno
innodb_stats_on_metadataYYY  no
innodb_status_fileYYY  no
innodb_support_xaYYY bothyes
innodb_sync_spin_loopsYYY bothyes
innodb_table_locksYYY bothyes
innodb_thread_concurrencyYYY bothyes
innodb_thread_sleep_delayYYY bothyes
insert_idYYY sessionyes
interactive_timeoutYYY bothyes
join_buffer_sizeYYY bothyes
Key_blocks_not_flushed   Ybothno
Key_blocks_unused   Ybothno
Key_blocks_used   Ybothno
key_buffer_sizeYYY bothyes
key_cache_age_thresholdYYY bothno
key_cache_block_sizeYYY bothno
key_cache_division_limitYYY bothno
Key_read_requests   Ybothno
Key_reads   Ybothno
Key_write_requests   Ybothno
Key_writes   Ybothno
languageYYY bothno
large-pagesYY  bothno
- Variable: large_pages  Y bothno
last_insert_idYYY sessionyes
Last_query_cost   Ysessionno
lc_time_names  Y bothyes
license  Y bothno
local-infileYY  globalyes
- Variable: local_infile  Y globalyes
logYYY bothno
log-binYY  bothno
- Variable: log_bin  Y bothno
log-bin-indexYYY  no
log-bin-trust-function-creatorsYY   yes
- Variable: log_bin_trust_function_creators  Y  yes
log-errorYY  bothno
- Variable: log_error  Y bothno
log-isamYYY  no
log-queries-not-using-indexesYY  bothyes
- Variable: log_queries_not_using_indexes  Y bothyes
log-short-formatYY    
log-slave-updatesYY  bothno
- Variable: log_slave_updates  Y bothno
log-slow-admin-statementsYY    
log-slow-queriesYY  bothno
- Variable: log_slow_queries  Y bothno
log-tcYY    
log-tc-sizeYY    
log-warningsYY  bothyes
- Variable: log_warnings  Y bothyes
log_outputYYY globalyes
long_query_timeYYY bothyes
low-priority-updatesYY   yes
- Variable: low_priority_updates  Y  yes
lower_case_table_namesYYY  no
master-connect-retryYY    
master-hostYY    
master-info-fileYY    
master-passwordYY    
master-portYY    
master-retry-countYY    
master-sslYY    
master-ssl-caYY    
master-ssl-capathYY    
master-ssl-certYY    
master-ssl-cipherYY    
master-ssl-keyYY    
master-userYY    
max-binlog-dump-eventsYY    
max_allowed_packetYYY bothyes
max_binlog_cache_sizeYYY globalyes
max_binlog_sizeYYY globalyes
max_connect_errorsYYY globalyes