日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
15個常用的MySQL使用管理命令示例

以下的文章主要向大家描述的是15個MySQL使用管理命令的描述,我前兩天在相關(guān)網(wǎng)站看見15個MySQL數(shù)據(jù)庫使用管理命令的資料,覺得挺好,就拿出來供大家分享,望大家瀏覽之后會有所收獲。

專注于為中小企業(yè)提供網(wǎng)站設(shè)計、網(wǎng)站建設(shè)服務(wù),電腦端+手機端+微信端的三站合一,更高效的管理,為中小企業(yè)竹溪免費做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動了成百上千企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設(shè)實現(xiàn)規(guī)模擴充和轉(zhuǎn)變。

 
 
 
  1. How to change the MySQL root user password?
  2. # MySQLadmin -u root -ptmppassword password 'newpassword'
  3. # MySQL -u root -pnewpassword
  4. Welcome to the MySQL monitor. Commands end with ; or \g.
  5. Your MySQL connection id is 8
  6. Server version: 5.1.25-rc-community MySQL Community Server (GPL)
  7. Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
  8. MySQL>
  9. How to check whether MySQL Server is up and running?
  10. # MySQLadmin -u root -p ping
  11. Enter password:
  12. MySQLd is alive3. How do I find out what version of MySQL I am running?
  13. Apart from giving the ‘Server version’, this command also displays the current status of the MySQL server.
  14. # MySQLadmin -u root -ptmppassword version
  15. MySQLadmin Ver 8.42 Distrib 5.1.25-rc, for redhat-linux-gnu on i686
  16. Copyright (C) 2000-2006 MySQL AB
  17. This software comes with ABSOLUTELY NO WARRANTY. This is free software,
  18. and you are welcome to modify and redistribute it under the GPL license
  19. Server version 5.1.25-rc-community
  20. Protocol version 10
  21. Connection Localhost via UNIX socket
  22. UNIX socket /var/lib/MySQL/MySQL.sock
  23. Uptime: 107 days 6 hours 11 min 44 sec
  24. Threads: 1 Questions: 231976 Slow queries: 0 Opens: 17067
  25. Flush tables: 1 Open tables: 64 Queries per second avg: 0.254. What is the current status of MySQL server?
  26. # MySQLadmin -u root -ptmppassword status
  27. Uptime: 9267148
  28. Threads: 1 Questions: 231977 Slow queries: 0 Opens: 17067
  29. Flush tables: 1 Open tables: 64 Queries per second avg: 0.25The status command displays the following information:
  30. Uptime: Uptime of the MySQL server in seconds 
  31. Threads: Total number of clients connected to the server. 
  32. Questions: Total number of queries the server has executed since the startup. 
  33. Slow queries: Total number of queries whose execution time waas more than long_query_time variable’s value. 
  34. Opens: Total number of tables opened by the server. 
  35. Flush tables: How many times the tables were flushed. 
  36. Open tables: Total number of open tables in the database. 
  37. 5. How to view all the MySQL Server status variable and it’s current value?
  38. # MySQLadmin -u root -ptmppassword extended-status
  39. +-----------------------------------+-----------+
  40. | Variable_name | Value |
  41. +-----------------------------------+-----------+
  42. | Aborted_clients | 579 |
  43. | Aborted_connects | 8 |
  44. | Binlog_cache_disk_use | 0 |
  45. | Binlog_cache_use | 0 |
  46. | Bytes_received | 41387238 |
  47. | Bytes_sent | 308401407 |
  48. | Com_admin_commands | 3524 |
  49. | Com_assign_to_keycache | 0 |
  50. | Com_alter_db | 0 |
  51. | Com_alter_db_upgrade | 0 |6. How to display all MySQL server system variables and the values?
  52. # MySQLadmin -u root -ptmppassword variables
  53. +---------------------------------+---------------------------------+
  54. | Variable_name | Value |
  55. +---------------------------------+---------------------------------+
  56. | auto_increment_increment | 1 |
  57. | basedir | / |
  58. | big_tables | OFF |
  59. | binlog_format | MIXED |
  60. | bulk_insert_buffer_size | 8388608 |
  61. | character_set_client | latin1 |
  62. | character_set_database | latin1 |
  63. | character_set_filesystem | binary |
  64. skip.....
  65. | time_format | %H:%i:%s |
  66. | time_zone | SYSTEM |
  67. | timed_mutexes | OFF |
  68. | tmpdir | /tmp |
  69. | tx_isolation | REPEATABLE-READ |
  70. | unique_checks | ON |
  71. | updatable_views_with_limit | YES |
  72. | version | 5.1.25-rc-community |
  73. | version_comment | MySQL Community Server (GPL) |
  74. | version_compile_machine | i686 |
  75. | version_compile_os | redhat-linux-gnu |
  76. | wait_timeout | 28800 |
  77. +---------------------------------+---------------------------------+
    7. How to display all the running process/queries in the MySQL database?
  78. # MySQLadmin -u root -ptmppassword processlist
  79. +----+------+-----------+----+---------+------+-------+------------------+
  80. | Id | User | Host | db | Command | Time | State | Info |
  81. +----+------+-----------+----+---------+------+-------+------------------+
  82. | 20 | root | localhost | | Sleep | 36 | | |
  83. | 23 | root | localhost | | Query | 0 | | show processlist |
  84. +----+------+-----------+----+---------+------+-------+------------------+You can use this command effectively to debug any performance issue and identify the query that is causing problems, by running the command automatically every 1 second as shown below.
  85. # MySQLadmin -u root -ptmppassword -i 1 processlist
  86. +----+------+-----------+----+---------+------+-------+------------------+
  87. | Id | User | Host | db | Command | Time | State | Info |
  88. +----+------+-----------+----+---------+------+-------+------------------+
  89. | 20 | root | localhost | | Sleep | 36 | | |
  90. | 23 | root | localhost | | Query | 0 | | show processlist |
  91. +----+------+-----------+----+---------+------+-------+------------------+
  92. +----+------+-----------+----+---------+------+-------+------------------+
  93. | Id | User | Host | db | Command | Time | State | Info |
  94. +----+------+-----------+----+---------+------+-------+------------------+
  95. | 24 | root | localhost | | Query | 0 | | show processlist |
  96. +----+------+-----------+----+---------+------+-------+------------------+8. How to create a MySQL Database?
  97. # MySQLadmin -u root -ptmppassword create testdb
  98. # MySQL -u root -ptmppassword
  99. Welcome to the MySQL monitor. Commands end with ; or \g.
  100. Your MySQL connection id is 705
  101. Server version: 5.1.25-rc-community MySQL Community Server (GPL)
  102. Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
  103. MySQL> show databases;
  104. +--------------------+
  105. | Database |
  106. +--------------------+
  107. | information_schema |
  108. | MySQL |
  109. | sugarcrm |
  110. | testdb |
  111. +--------------------+
  112. 4 rows in set (0.00 sec)
  113. Note: To display all tables in a database, total number of columns, row, column types, indexes etc., use the MySQLshow command that we discussed in our previous articles.
  114. 9. How to Delete/Drop an existing MySQL database?
  115. # MySQLadmin -u root -ptmppassword drop testdb
  116. Dropping the database is potentially a very bad thing to do.
  117. Any data stored in the database will be destroyed.
  118. Do you really want to drop the 'testdb' database [y/N] y
  119. Database “testdb” dropped
  120. # MySQL -u root -ptmppassword
  121. Welcome to the MySQL monitor. Commands end with ; or \g.
  122. Your MySQL connection id is 707
  123. Server version: 5.1.25-rc-community MySQL Community Server (GPL)
  124. Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
  125. MySQL> show databases;
  126. +——————–+
  127. | Database |
  128. +——————–+
  129. | information_schema |
  130. | MySQL |
  131. | sugarcrm |
  132. +——————–+
  133. 3 rows in set (0.00 sec)10. How to reload/refresh the privilege or the grants tables?
  134. # MySQLadmin -u root -ptmppassword reload;Refresh command will flush all the tables and close/open log files.
  135. # MySQLadmin -u root -ptmppassword refresh11. What is the safe method to shutdown the MySQL server?
  136. # MySQLadmin -u root -ptmppassword shutdown
  137. # MySQL -u root -ptmppassword
  138. ERROR 2002 (HY000): Can't connect to local MySQL server
  139. through socket '/var/lib/MySQL/MySQL.sock'Note: You can also use “/etc/rc.d/init.d/MySQLd stop” to shutdown the server. To start the server, execute “/etc/rc.d/init.d/MySQL start”
  140. 12. List of all MySQLadmin flush commands.
  141. # MySQLadmin -u root -ptmppassword flush-hosts
  142. # MySQLadmin -u root -ptmppassword flush-logs
  143. # MySQLadmin -u root -ptmppassword flush-privileges
  144. # MySQLadmin -u root -ptmppassword flush-status
  145. # MySQLadmin -u root -ptmppassword flush-tables
  146. # MySQLadmin -u root -ptmppassword flush-threadsflush-hosts: Flush all information in the host cache. 
  147. flush-privileges: Reload the grant tables (same as reload). 
  148. flush-status: Clear status variables. 
  149. flush-threads: Flush the thread cache. 
  150. 13. How to kill a hanging MySQL Client Process?
  151. First identify the hanging MySQL client process using the processlist command.
  152. # MySQLadmin -u root -ptmppassword processlist
  153. +----+------+-----------+----+---------+------+-------+------------------+
  154. | Id | User | Host | db | Command | Time | State | Info |
  155. +----+------+-----------+----+---------+------+-------+------------------+
  156. | 20 | root | localhost | | Sleep | 64 | | |
  157. | 24 | root | localhost | | Query | 0 | | show processlist |
  158. +----+------+-----------+----+---------+------+-------+------------------+Now, use the kill command and pass the process_id as shown below. To kill multiple process you can pass comma separated process id’s.
  159. # MySQLadmin -u root -ptmppassword kill 20
  160. # MySQLadmin -u root -ptmppassword processlist
  161. +----+------+-----------+----+---------+------+-------+------------------+
  162. | Id | User | Host | db | Command | Time | State | Info |
  163. +----+------+-----------+----+---------+------+-------+------------------+
  164. | 26 | root | localhost | | Query | 0 | | show processlist |
  165. +----+------+-----------+----+---------+------+-------+------------------+14. How to start and stop MySQL replication on a slave server?
  166. # MySQLadmin -u root -ptmppassword stop-slave
  167. Slave stopped
  168. # MySQLadmin -u root -ptmppassword start-slave
  169. MySQLadmin: Error starting slave: The server is not configured as slave;
  170. fix in config file or with CHANGE MASTER TO15. How to combine multiple MySQLadmin commands together?
  171. In the example below, you can combine process-list, status and version command to get all the output together as shown below.
  172. # MySQLadmin -u root -ptmppassword process status version
  173. +----+------+-----------+----+---------+------+-------+------------------+
  174. | Id | User | Host | db | Command | Time | State | Info |
  175. +----+------+-----------+----+---------+------+-------+------------------+
  176. | 43 | root | localhost | | Query | 0 | | show processlist |
  177. +----+------+-----------+----+---------+------+-------+------------------+
  178. Uptime: 3135
  179. Threads: 1 Questions: 80 Slow queries: 0 Opens: 15 Flush tables: 3
  180. Open tables: 0 Queries per second avg: 0.25
  181. MySQLadmin Ver 8.42 Distrib 5.1.25-rc, for redhat-linux-gnu on i686
  182. Copyright (C) 2000-2006 MySQL AB
  183. This software comes with ABSOLUTELY NO WARRANTY. This is free software,
  184. and you are welcome to modify and redistribute it under the GPL license
  185. Server version 5.1.25-rc-community
  186. Protocol version 10
  187. Connection Localhost via UNIX socket
  188. UNIX socket /var/lib/MySQL/MySQL.sock
  189. Uptime: 52 min 15 secYou can also use the short form as shown below:
  190. # MySQLadmin -u root -ptmppassword pro stat verUse the option -h, 
    to connect to a remote MySQL server and execute the MySQLadmin commands as shown below.
  191. # MySQLadmin -h 192.168.1.112 -u root -ptmppassword pro stat ver

上述的相關(guān)內(nèi)容就是對15個MySQL使用管理命令的描述,希望會給你帶來一些幫助在此方面。

連接:http://www.cnblogs.com/alon/archive/2010/01/21/1652849.html


文章題目:15個常用的MySQL使用管理命令示例
瀏覽地址:http://www.dlmjj.cn/article/cceoepe.html