mysql常用命令学习
1.\c取消当前准备执行的sql语句.
mysql> select user,host,password from mysql.user;\c
+--------+-----------+----------+
| user | host | password |
+--------+-----------+----------+
| root | localhost | |
| root | mytest2 | |
| root | 127.0.0.1 | |
| mytest | localhost | |
+--------+-----------+----------+
4 rows in set (0.00 sec)
mysql> select user,host,password from mysql.user\c
2.语句结束符\d
mysql> delimiter $
mysql> select user from mysql.user;
-> $
+--------+
| user |
+--------+
| root |
| mytest |
| root |
| root |
+--------+
4 rows in set (0.00 sec)
mysql> delimiter ;
mysql> select user from mysql.user;
+--------+
| user |
+--------+
| root |
| mytest |
| root |
| root |
+--------+
4 rows in set (0.00 sec)
mysql> \d $
mysql> select user from mysql.user;
-> $
+--------+
| user |
+--------+
| root |
| mytest |
| root |
| root |
+--------+
4 rows in set (0.00 sec)
mysql> \d ;
mysql> select user from mysql.user;
+--------+
| user |
+--------+
| root |
| mytest |
| root |
| root |
+--------+
4 rows in set (0.00 sec)
3.重新连接服务器\r
mysql> \r
Connection id: 9
Current database: mytest
4.强制语句结束符\g
mysql> \d $
mysql> select user from mysql.user\g
+--------+
| user |
+--------+
| root |
| mytest |
| root |
| root |
+--------+
4 rows in set (0.00 sec)
5.强制语句结束符\G,结果竖排显示
mysql> \d $
mysql> select user from mysql.user\G
*************************** 1. row ***************************
user: root
*************************** 2. row ***************************
user: mytest
*************************** 3. row ***************************
user: root
*************************** 4. row ***************************
user: root
4 rows in set (0.00 sec)
6.执行系统shell命令
mysql> \! ls -l
总计 4
-rw-rw---- 1 mysql mysql 61 07-27 10:05 db.opt
7.语句执行结束后,显示警告信息
mysql> \W
Show warnings enabled.
8.语句执行结束后,不显示警告信息.
mysql> \w
Show warnings disabled.
9.禁用新建对象的名称补全功能:-A,--no-auto-rehash,--disable-autorehash
10.启用新建对象的名称补全功能:\#,rehash
11.将mysql的执行结果以html或xml格式显示
[root@mytest2 mytest]# mysql --xml -e ‘select user from mysql.user‘
<?xml version="1.0"?>
<resultset statement="select user from mysql.user
" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<row>
<field name="user">root</field>
</row>
<row>
<field name="user">mytest</field>
</row>
<row>
<field name="user">root</field>
</row>
<row>
<field name="user">root</field>
</row>
</resultset>
[root@mytest2 mytest]# mysql --html -e ‘select user from mysql.user‘
<TABLE BORDER=1><TR><TH>user</TH></TR><TR><TD>root</TD></TR><TR><TD>mytest</TD></TR><TR><TD>root</TD></TR><TR><TD>root</TD></TR></TABLE>[root@mytest2 mytest]#
[root@mytest2 mytest]# mysql -H -e "select user from mysql.user where user=‘mytest‘"
<TABLE BORDER=1><TR><TH>user</TH></TR><TR><TD>mytest</TD></TR></TABLE>[root@mytest2 mytest]#
[root@mytest2 mytest]# mysql -X -e "select user from mysql.user where user=‘mytest‘"
<?xml version="1.0"?>
<resultset statement="select user from mysql.user where user=‘mytest‘
" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<row>
<field name="user">mytest</field>
</row>
</resultset>
[root@mytest2 mytest]#
12.mysqladmin命令学习
[root@mytest2 mytest]# mysqladmin --help
mysqladmin Ver 8.42 Distrib 5.5.38, for Linux on x86_64
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Administration program for the mysqld daemon.
Usage: mysqladmin [OPTIONS] command command....
-c, --count=# Number of iterations to make. This works with -i
(--sleep) only.
--debug-check Check memory and open file usage at exit.
--debug-info Print some debug info at exit.
-f, --force Don‘t ask for confirmation on drop database; with
multiple commands, continue even if an error occurs.
-C, --compress Use compression in server/client protocol.
--character-sets-dir=name
Directory for character set files.
--default-character-set=name
Set the default character set.
-?, --help Display this help and exit.
-h, --host=name Connect to host.
-b, --no-beep Turn off beep on error.
-p, --password[=name]
Password to use when connecting to server. If password is
not given it‘s asked from the tty.
-P, --port=# Port number to use for connection or 0 for default to, in
order of preference, my.cnf, $MYSQL_TCP_PORT,
/etc/services, built-in default (3306).
--protocol=name The protocol to use for connection (tcp, socket, pipe,
memory).
-r, --relative Show difference between current and previous values when
used with -i. Currently only works with extended-status.
-s, --silent Silently exit if one can‘t connect to server.
-S, --socket=name The socket file to use for connection.
-i, --sleep=# Execute commands repeatedly with a sleep between.
--ssl Enable SSL for connection (automatically enabled with
other flags).
--ssl-ca=name CA file in PEM format (check OpenSSL docs, implies
--ssl).
--ssl-capath=name CA directory (check OpenSSL docs, implies --ssl).
--ssl-cert=name X509 cert in PEM format (implies --ssl).
--ssl-cipher=name SSL cipher to use (implies --ssl).
--ssl-key=name X509 key in PEM format (implies --ssl).
--ssl-verify-server-cert
Verify server‘s "Common Name" in its cert against
hostname used when connecting. This option is disabled by
default.
-u, --user=name User for login if not current user.
-v, --verbose Write more information.
-V, --version Output version information and exit.
-E, --vertical Print output vertically. Is similar to --relative, but
prints output vertically.
-w, --wait[=#] Wait and retry if connection is down.
--connect-timeout=#
--shutdown-timeout=#
--plugin-dir=name Directory for client-side plugins.
--default-auth=name Default authentication client-side plugin to use.
--enable-cleartext-plugin
Enable/disable the clear text authentication plugin.
Variables (--variable-name=value)
and boolean options {FALSE|TRUE} Value (after reading options)
--------------------------------- ----------------------------------------
count 0
debug-check FALSE
debug-info FALSE
force FALSE
compress FALSE
character-sets-dir (No default value)
default-character-set auto
host (No default value)
no-beep FALSE
port 3306
relative FALSE
socket /tmp/mysql.sock
sleep 0
ssl FALSE
ssl-ca (No default value)
ssl-capath (No default value)
ssl-cert (No default value)
ssl-cipher (No default value)
ssl-key (No default value)
ssl-verify-server-cert FALSE
user (No default value)
verbose FALSE
vertical FALSE
connect-timeout 43200
shutdown-timeout 3600
plugin-dir (No default value)
default-auth (No default value)
enable-cleartext-plugin FALSE
Default options are read from the following files in the given order:
/etc/mysql/my.cnf /etc/my.cnf ~/.my.cnf
The following groups are read: mysqladmin client
The following options may be given as the first argument:
--print-defaults Print the program argument list and exit.
--no-defaults Don‘t read default options from any option file.
--defaults-file=# Only read default options from the given file #.
--defaults-extra-file=# Read this file after the global files are read.
Where command is a one or more of: (Commands may be shortened)
create databasename Create a new database
debug Instruct server to write debug information to log
drop databasename Delete a database and all its tables
extended-status Gives an extended status message from the server
flush-hosts Flush all cached hosts
flush-logs Flush all logs
flush-status Clear status variables
flush-tables Flush all tables
flush-threads Flush the thread cache
flush-privileges Reload grant tables (same as reload)
kill id,id,... Kill mysql threads
password [new-password] Change old password to new-password in current format
old-password [new-password] Change old password to new-password in old format
ping Check if mysqld is alive
processlist Show list of active threads in server
reload Reload grant tables
refresh Flush all tables and close and open logfiles
shutdown Take server down
status Gives a short status message from the server
start-slave Start slave
stop-slave Stop slave
variables Prints variables available
version Get version info from server
12.1 mysqladmin ping 对方服务器.
[root@mytest2 mytest]# mysqladmin -h 127.0.0.1 ping
mysqld is alive
12.2 mysqladmin创建删除数据库.
[root@mytest2 mytest]# mysql -e ‘show databases;‘
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| mytest |
| performance_schema |
| test |
+--------------------+
[root@mytest2 mytest]# mysqladmin create newdb
[root@mytest2 mytest]# mysql -e ‘show databases;‘
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| mytest |
| newdb |
| performance_schema |
| test |
+--------------------+
[root@mytest2 mytest]# mysqladmin drop newdb
Dropping the database is potentially a very bad thing to do.
Any data stored in the database will be destroyed.
Do you really want to drop the ‘newdb‘ database [y/N] y
Database "newdb" dropped
[root@mytest2 mytest]# mysql -e ‘show databases;‘
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| mytest |
| performance_schema |
| test |
+--------------------+
[root@mytest2 mytest]#
12.3 显示进程列表
[root@mytest2 scripts]# mysqladmin processlist
+----+------+-----------+----+---------+------+-------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------+----+---------+------+-------+------------------+
| 30 | root | localhost | | Sleep | 34 | | |
| 31 | root | localhost | | Query | 0 | | show processlist |
+----+------+-----------+----+---------+------+-------+------------------+
mysql> show processlist;
+----+------+-----------+------+---------+------+-------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------+------+---------+------+-------+------------------+
| 30 | root | localhost | NULL | Query | 0 | NULL | show processlist |
+----+------+-----------+------+---------+------+-------+------------------+
1 row in set (0.00 sec)
12.4显示数据库状态
[root@mytest2 scripts]# mysqladmin status
Uptime: 9711 Threads: 2 Questions: 132 Slow queries: 0 Opens: 39 Flush tables: 1 Open tables: 31 Queries per second avg: 0.013
mysql> status
--------------
mysql Ver 14.14 Distrib 5.5.38, for Linux (x86_64) using readline 5.1
Connection id: 30
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ‘‘
Using delimiter: ;
Server version: 5.5.38-log Source distribution
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /tmp/mysql.sock
Uptime: 2 hours 41 min 37 sec
Threads: 1 Questions: 131 Slow queries: 0 Opens: 39 Flush tables: 1 Open tables: 31 Queries per second avg: 0.013
--------------
12.5每隔2秒显示数据库状态信息
[root@mytest2 scripts]# mysqladmin status --sleep 2
Uptime: 9815 Threads: 2 Questions: 134 Slow queries: 0 Opens: 39 Flush tables: 1 Open tables: 31 Queries per second avg: 0.013
Uptime: 9817 Threads: 2 Questions: 135 Slow queries: 0 Opens: 39 Flush tables: 1 Open tables: 31 Queries per second avg: 0.013
Uptime: 9819 Threads: 2 Questions: 136 Slow queries: 0 Opens: 39 Flush tables: 1 Open tables: 31 Queries per second avg: 0.013
Uptime: 9821 Threads: 2 Questions: 137 Slow queries: 0 Opens: 39 Flush tables: 1 Open tables: 31 Queries per second avg: 0.013
Uptime: 9823 Threads: 2 Questions: 138 Slow queries: 0 Opens: 39 Flush tables: 1 Open tables: 31 Queries per second avg: 0.014
12.6每隔2秒显示数据库状态,显示3次后退出
[root@mytest2 scripts]# mysqladmin status --sleep 2 --count 3
Uptime: 9979 Threads: 2 Questions: 140 Slow queries: 0 Opens: 39 Flush tables: 1 Open tables: 31 Queries per second avg: 0.014
Uptime: 9981 Threads: 2 Questions: 141 Slow queries: 0 Opens: 39 Flush tables: 1 Open tables: 31 Queries per second avg: 0.014
Uptime: 9983 Threads: 2 Questions: 142 Slow queries: 0 Opens: 39 Flush tables: 1 Open tables: 31 Queries per second avg: 0.014
12.7显示mysql的状态变量及值(运行时的当前值)
[root@mytest2 scripts]# mysqladmin extended-status
+------------------------------------------+-------------+
| Variable_name | Value |
+------------------------------------------+-------------+
| Aborted_clients | 0 |
| Aborted_connects | 0 |
| Binlog_cache_disk_use | 0 |
| Binlog_cache_use | 0 |
| Binlog_stmt_cache_disk_use | 0 |
| Binlog_stmt_cache_use | 0 |
| Bytes_received | 6135 |
| Bytes_sent | 57665 |
| Com_admin_commands | 2 |
| Com_assign_to_keycache | 0 |
| Com_alter_db | 0 |
| Com_alter_db_upgrade | 0 |
| Com_alter_event | 0 |
| Com_alter_function | 0 |
| Com_alter_procedure | 0 |
| Com_alter_server | 0 |
| Com_alter_table | 0 |
| Com_alter_tablespace | 0 |
| Com_analyze | 0 |
| Com_begin | 0 |
| Com_binlog | 0 |
| Com_call_procedure | 0 |
| Com_change_db | 1 |
| Com_change_master | 0 |
| Com_check | 0 |
| Com_checksum | 0 |
| Com_commit | 0 |
| Com_create_db | 3 |
| Com_create_event | 0 |
| Com_create_function | 0 |
| Com_create_index | 0 |
| Com_create_procedure | 0 |
| Com_create_server | 0 |
| Com_create_table | 1 |
| Com_create_trigger | 0 |
| Com_create_udf | 0 |
| Com_create_user | 1 |
| Com_create_view | 0 |
| Com_dealloc_sql | 0 |
| Com_delete | 0 |
| Com_delete_multi | 0 |
| Com_do | 0 |
| Com_drop_db | 2 |
| Com_drop_event | 0 |
| Com_drop_function | 0 |
| Com_drop_index | 0 |
| Com_drop_procedure | 0 |
| Com_drop_server | 0 |
| Com_drop_table | 1 |
| Com_drop_trigger | 0 |
| Com_drop_user | 3 |
| Com_drop_view | 0 |
| Com_empty_query | 0 |
| Com_execute_sql | 0 |
| Com_flush | 0 |
| Com_grant | 0 |
| Com_ha_close | 0 |
| Com_ha_open | 0 |
| Com_ha_read | 0 |
| Com_help | 3 |
| Com_insert | 0 |
| Com_insert_select | 0 |
| Com_install_plugin | 0 |
| Com_kill | 0 |
| Com_load | 0 |
| Com_lock_tables | 0 |
| Com_optimize | 0 |
| Com_preload_keys | 0 |
| Com_prepare_sql | 0 |
| Com_purge | 0 |
| Com_purge_before_date | 0 |
| Com_release_savepoint | 0 |
| Com_rename_table | 0 |
| Com_rename_user | 0 |
| Com_repair | 0 |
| Com_replace | 0 |
| Com_replace_select | 0 |
| Com_reset | 0 |
| Com_resignal | 0 |
| Com_revoke | 0 |
| Com_revoke_all | 0 |
| Com_rollback | 0 |
| Com_rollback_to_savepoint | 0 |
| Com_savepoint | 0 |
| Com_select | 49 |
| Com_set_option | 6 |
| Com_signal | 0 |
| Com_show_authors | 0 |
| Com_show_binlog_events | 1 |
| Com_show_binlogs | 0 |
| Com_show_charsets | 0 |
| Com_show_collations | 0 |
| Com_show_contributors | 0 |
| Com_show_create_db | 0 |
| Com_show_create_event | 0 |
| Com_show_create_func | 0 |
| Com_show_create_proc | 0 |
| Com_show_create_table | 0 |
| Com_show_create_trigger | 0 |
| Com_show_databases | 5 |
| Com_show_engine_logs | 0 |
| Com_show_engine_mutex | 0 |
| Com_show_engine_status | 0 |
| Com_show_events | 0 |
| Com_show_errors | 0 |
| Com_show_fields | 0 |
| Com_show_function_status | 0 |
| Com_show_grants | 0 |
| Com_show_keys | 0 |
| Com_show_master_status | 1 |
| Com_show_open_tables | 0 |
| Com_show_plugins | 0 |
| Com_show_privileges | 0 |
| Com_show_procedure_status | 0 |
| Com_show_processlist | 3 |
| Com_show_profile | 0 |
| Com_show_profiles | 0 |
| Com_show_relaylog_events | 0 |
| Com_show_slave_hosts | 0 |
| Com_show_slave_status | 0 |
| Com_show_status | 16 |
| Com_show_storage_engines | 0 |
| Com_show_table_status | 0 |
| Com_show_tables | 1 |
| Com_show_triggers | 0 |
| Com_show_variables | 3 |
| Com_show_warnings | 0 |
| Com_slave_start | 0 |
| Com_slave_stop | 0 |
| Com_stmt_close | 0 |
| Com_stmt_execute | 0 |
| Com_stmt_fetch | 0 |
| Com_stmt_prepare | 0 |
| Com_stmt_reprepare | 0 |
| Com_stmt_reset | 0 |
| Com_stmt_send_long_data | 0 |
| Com_truncate | 0 |
| Com_uninstall_plugin | 0 |
| Com_unlock_tables | 0 |
| Com_update | 0 |
| Com_update_multi | 0 |
| Com_xa_commit | 0 |
| Com_xa_end | 0 |
| Com_xa_prepare | 0 |
| Com_xa_recover | 0 |
| Com_xa_rollback | 0 |
| Com_xa_start | 0 |
| Compression | OFF |
| Connections | 38 |
| Created_tmp_disk_tables | 0 |
| Created_tmp_files | 5 |
| Created_tmp_tables | 14 |
| Delayed_errors | 0 |
| Delayed_insert_threads | 0 |
| Delayed_writes | 0 |
| Flush_commands | 1 |
| Handler_commit | 0 |
| Handler_delete | 3 |
| Handler_discover | 0 |
| Handler_prepare | 0 |
| Handler_read_first | 18 |
| Handler_read_key | 16 |
| Handler_read_last | 0 |
| Handler_read_next | 60 |
| Handler_read_prev | 0 |
| Handler_read_rnd | 0 |
| Handler_read_rnd_next | 1393 |
| Handler_rollback | 0 |
| Handler_savepoint | 0 |
| Handler_savepoint_rollback | 0 |
| Handler_update | 2 |
| Handler_write | 1287 |
| Innodb_buffer_pool_pages_data | 145 |
| Innodb_buffer_pool_bytes_data | 2375680 |
| Innodb_buffer_pool_pages_dirty | 0 |
| Innodb_buffer_pool_bytes_dirty | 0 |
| Innodb_buffer_pool_pages_flushed | 18 |
| Innodb_buffer_pool_pages_free | 8045 |
| Innodb_buffer_pool_pages_misc | 1 |
| Innodb_buffer_pool_pages_total | 8191 |
| Innodb_buffer_pool_read_ahead_rnd | 0 |
| Innodb_buffer_pool_read_ahead | 0 |
| Innodb_buffer_pool_read_ahead_evicted | 0 |
| Innodb_buffer_pool_read_requests | 576 |
| Innodb_buffer_pool_reads | 145 |
| Innodb_buffer_pool_wait_free | 0 |
| Innodb_buffer_pool_write_requests | 58 |
| Innodb_data_fsyncs | 13 |
| Innodb_data_pending_fsyncs | 0 |
| Innodb_data_pending_reads | 0 |
| Innodb_data_pending_writes | 0 |
| Innodb_data_read | 4558848 |
| Innodb_data_reads | 155 |
| Innodb_data_writes | 21 |
| Innodb_data_written | 596992 |
| Innodb_dblwr_pages_written | 18 |
| Innodb_dblwr_writes | 2 |
| Innodb_have_atomic_builtins | ON |
| Innodb_log_waits | 0 |
| Innodb_log_write_requests | 7 |
| Innodb_log_writes | 4 |
| Innodb_os_log_fsyncs | 8 |
| Innodb_os_log_pending_fsyncs | 0 |
| Innodb_os_log_pending_writes | 0 |
| Innodb_os_log_written | 5120 |
| Innodb_page_size | 16384 |
| Innodb_pages_created | 1 |
| Innodb_pages_read | 144 |
| Innodb_pages_written | 18 |
| Innodb_row_lock_current_waits | 0 |
| Innodb_row_lock_time | 0 |
| Innodb_row_lock_time_avg | 0 |
| Innodb_row_lock_time_max | 0 |
| Innodb_row_lock_waits | 0 |
| Innodb_rows_deleted | 0 |
| Innodb_rows_inserted | 0 |
| Innodb_rows_read | 0 |
| Innodb_rows_updated | 0 |
| Innodb_truncated_status_writes | 0 |
| Key_blocks_not_flushed | 0 |
| Key_blocks_unused | 13389 |
| Key_blocks_used | 7 |
| Key_read_requests | 50 |
| Key_reads | 7 |
| Key_write_requests | 7 |
| Key_writes | 4 |
| Last_query_cost | 0.000000 |
| Max_used_connections | 2 |
| Not_flushed_delayed_rows | 0 |
| Open_files | 30 |
| Open_streams | 0 |
| Open_table_definitions | 38 |
| Open_tables | 31 |
| Opened_files | 105 |
| Opened_table_definitions | 39 |
| Opened_tables | 39 |
| Performance_schema_cond_classes_lost | 0 |
| Performance_schema_cond_instances_lost | 0 |
| Performance_schema_file_classes_lost | 0 |
| Performance_schema_file_handles_lost | 0 |
| Performance_schema_file_instances_lost | 0 |
| Performance_schema_locker_lost | 0 |
| Performance_schema_mutex_classes_lost | 0 |
| Performance_schema_mutex_instances_lost | 0 |
| Performance_schema_rwlock_classes_lost | 0 |
| Performance_schema_rwlock_instances_lost | 0 |
| Performance_schema_table_handles_lost | 0 |
| Performance_schema_table_instances_lost | 0 |
| Performance_schema_thread_classes_lost | 0 |
| Performance_schema_thread_instances_lost | 0 |
| Prepared_stmt_count | 0 |
| Qcache_free_blocks | 0 |
| Qcache_free_memory | 0 |
| Qcache_hits | 0 |
| Qcache_inserts | 0 |
| Qcache_lowmem_prunes | 0 |
| Qcache_not_cached | 0 |
| Qcache_queries_in_cache | 0 |
| Qcache_total_blocks | 0 |
| Queries | 150 |
| Questions | 136 |
| Rpl_status | AUTH_MASTER |
| Select_full_join | 0 |
| Select_full_range_join | 0 |
| Select_range | 0 |
| Select_range_check | 0 |
| Select_scan | 36 |
| Slave_heartbeat_period | 0.000 |
| Slave_open_temp_tables | 0 |
| Slave_received_heartbeats | 0 |
| Slave_retried_transactions | 0 |
| Slave_running | OFF |
| Slow_launch_threads | 0 |
| Slow_queries | 0 |
| Sort_merge_passes | 0 |
| Sort_range | 0 |
| Sort_rows | 0 |
| Sort_scan | 0 |
| Ssl_accept_renegotiates | 0 |
| Ssl_accepts | 0 |
| Ssl_callback_cache_hits | 0 |
| Ssl_cipher | |
| Ssl_cipher_list | |
| Ssl_client_connects | 0 |
| Ssl_connect_renegotiates | 0 |
| Ssl_ctx_verify_depth | 0 |
| Ssl_ctx_verify_mode | 0 |
| Ssl_default_timeout | 0 |
| Ssl_finished_accepts | 0 |
| Ssl_finished_connects | 0 |
| Ssl_session_cache_hits | 0 |
| Ssl_session_cache_misses | 0 |
| Ssl_session_cache_mode | NONE |
| Ssl_session_cache_overflows | 0 |
| Ssl_session_cache_size | 0 |
| Ssl_session_cache_timeouts | 0 |
| Ssl_sessions_reused | 0 |
| Ssl_used_session_cache_entries | 0 |
| Ssl_verify_depth | 0 |
| Ssl_verify_mode | 0 |
| Ssl_version | |
| Table_locks_immediate | 105 |
| Table_locks_waited | 0 |
| Tc_log_max_pages_used | 0 |
| Tc_log_page_size | 0 |
| Tc_log_page_waits | 0 |
| Threads_cached | 0 |
| Threads_connected | 2 |
| Threads_created | 37 |
| Threads_running | 1 |
| Uptime | 10178 |
| Uptime_since_flush_status | 10178 |
+------------------------------------------+-------------+
[root@mytest2 scripts]#
12.8显示mysql服务器变量()
[root@mytest2 scripts]# mysqladmin variables
12.9 让mysqld重读授权表.
[root@mytest2 scripts]# mysqladmin flush-privileges
12.10重置大多数的服务器状态变量
[root@mytest2 scripts]# mysqladmin flush-status
12.11实现二进制日志及中继日志的滚动
[root@mytest2 scripts]# mysql -e ‘show master status‘
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000002 | 1472 | | |
+------------------+----------+--------------+------------------+
[root@mytest2 scripts]# mysqladmin flush-logs
[root@mytest2 scripts]# mysql -e ‘show master status‘
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000003 | 107 | | |
+------------------+----------+--------------+------------------+
[root@mytest2 scripts]#
12.12关闭mysql数据库
[root@mytest2 scripts]# mysqladmin shutdown
[root@mytest2 scripts]# netstat -tnlp |grep 3306
[root@mytest2 scripts]# mysqld_safe --user=mysql &
[1] 2538
[root@mytest2 scripts]# 140727 13:07:04 mysqld_safe Logging to ‘/data/mysql/mytest2.err‘.
140727 13:07:04 mysqld_safe Starting mysqld daemon with databases from /data/mysql
[root@mytest2 scripts]# netstat -tnlp |grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2840/mysqld
12.13显示mysql的版本号及状态信息
[root@mytest2 scripts]# mysqladmin version
mysqladmin Ver 8.42 Distrib 5.5.38, for Linux on x86_64
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Server version 5.5.38-log
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /tmp/mysql.sock
Uptime: 1 min 32 sec
Threads: 1 Questions: 2 Slow queries: 0 Opens: 33 Flush tables: 1 Open tables: 26 Queries per second avg: 0.021
12.14启动从服务器复制线程.
[root@mytest2 scripts]# mysqladmin start-slave
12.15关闭从服务器的复制线程.
[root@mytest2 scripts]# mysqladmin stop-slave
本文出自 “webseven” 博客,请务必保留此出处http://webseven.blog.51cto.com/4388012/1530923