自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

MySQL常用技巧都包括哪些?

數(shù)據(jù)庫(kù) MySQL
我們今天主要和大家分享的是MySQL常用技巧,MySQL常用技巧可以使我們的實(shí)際操作變得更為簡(jiǎn)單,以下就是文章的具體內(nèi)容講述。

以下的文章主要介紹的是MySQL常用技巧,我們主要是講述七個(gè)實(shí)際應(yīng)用技巧,如果你對(duì)這七個(gè)MySQL常用技巧感興趣的話(huà),你就可以瀏覽以下的文章了,望會(huì)給你帶來(lái)一些幫助在此學(xué)習(xí)方面。

 

1)MySQL常用技巧之一,用戶(hù)權(quán)限管理最好是細(xì)分到DB級(jí) 或 Table級(jí),不要輕易開(kāi)通全局權(quán)限;

 

2)MySQL常用技巧之二,用grant 和 revoke,進(jìn)行用戶(hù)授權(quán)和收權(quán);

 

  1. MySQL> grant select on db.* to user@host identified by ‘passwd’;  
  2. MySQL> revoke all on db.* from user@host;  
  3. MySQL> flush privileges; 

 

注意:對(duì)用戶(hù)權(quán)限作變更后需運(yùn)行flush使變更生效;

 

3)MySQL常用技巧之三,查看服務(wù)器運(yùn)行狀況的幾個(gè)重要命令;

show status; 顯示系統(tǒng)的運(yùn)行狀態(tài)

 

show variables; 顯示系統(tǒng)運(yùn)行的參數(shù)設(shè)置與環(huán)境變量

 

show processlist; 顯示現(xiàn)有的訪問(wèn)連接;

 

對(duì)master slave系統(tǒng)還有:show master/slave status;

 

4)MySQL常用技巧之四,設(shè)置最大的并發(fā)響應(yīng)連接數(shù)、等待響應(yīng)隊(duì)列的最大等待連接數(shù)(上限與具體操作系統(tǒng)有關(guān))、非活動(dòng)連接超時(shí)時(shí)間

最大連接數(shù)

 

查看:MySQL> show variables like ‘max_connections’;

 

設(shè)置:MySQL> set global max_connections = 200;

 

默認(rèn)為100,若設(shè)置為0,則表示不作限制;

 

瞬時(shí)并發(fā)等待連接數(shù)

查看:MySQL> show variables like ‘back_log’;

 

設(shè)置:MySQL> set global back_log = 200;

 

默認(rèn)為50;

 

非活動(dòng)連接超時(shí)時(shí)間

MySQL> set wait_timeout = 3600;

 

默認(rèn)為28800,即8小時(shí),單位秒;

 

5)MySQL常用技巧之五,表優(yōu)化(碎片整理)

倘若一個(gè)數(shù)據(jù)量很大的表進(jìn)行了大量的修改,那么可以通過(guò)命令

 

MySQL> optimize table table_name;

 

來(lái)達(dá)到碎片整理的目的;

 

6)MySQL常用技巧之六,使用MySQLhotcopy進(jìn)行數(shù)據(jù)庫(kù)文件熱備份

/home/MySQL/bin/MySQLhotcopy db_name[./table_regex/] [new_db_name | direc tory]

 

示例:

 

/home/MySQL/bin/MySQLhotcopy -u root -p ‘xxxx’ test./^tt$/ ./

 

注意:MySQLhotcopy是一個(gè)perl程序,需要DBI和DBD perl模塊的支持

 

7)MySQL常用技巧之七,錯(cuò)誤日志與binlog

 

錯(cuò)誤記錄日志一般是在數(shù)據(jù)目錄下,如:

 

var/.err

 

binlog可以記錄數(shù)據(jù)庫(kù)上發(fā)生的所有操作記錄,通過(guò)my.cnf中的log-bin選項(xiàng)來(lái)開(kāi)啟,如果被注釋就代表關(guān)閉,binlog的內(nèi)容可以通過(guò)以下命令來(lái)查看:

  1. MySQLbinlog [options] log-files 

附錄 權(quán)限名稱(chēng)與描述列表

  1. Privilege  
  2. Meaning  
  3. ALL [PRIVILEGES]  
  4. Sets all simple privileges except GRANT OPTION  
  5. ALTER  
  6. Allows use of ALTER TABLE  
  7. CREATE  
  8. Allows use of CREATE TABLE  
  9. CREATE TEMPORARY TABLES  
  10. Allows use of CREATE TEMPORARY TABLE  
  11. DELETE  
  12. Allows use of DELETE  
  13. DROP  
  14. Allows use of DROP TABLE  
  15. EXECUTE  
  16. Not implemented  
  17. FILE  
  18. Allows use of SELECT … INTO OUTFILE and LOAD DATA INFILE  
  19. INDEX  
  20. Allows use of CREATE INDEX and DROP INDEX  
  21. INSERT  
  22. Allows use of INSERT  
  23. LOCK TABLES  
  24. Allows use of LOCK TABLES on tables for which you have the SELECT privilege  
  25. PROCESS  
  26. Allows use of SHOW FULL PROCESSLIST  
  27. REFERENCES  
  28. Not implemented  
  29. RELOAD  
  30. Allows use of FLUSH  
  31. REPLICATION CLIENT  
  32. Allows the user to ask where slave or master servers are  
  33. REPLICATION SLAVE  
  34. Needed for replication slaves (to read binary log events from the master)  
  35. SELECT  
  36. Allows use of SELECT  
  37. SHOW DATABASES  
  38. SHOW DATABASES shows all databases  
  39. SHUTDOWN  
  40. Allows use of MySQLadmin shutdown  
  41. SUPER  
  42. Allows use of CHANGE MASTER, KILL, PURGE MASTER LOGS, and SET GLOBAL statements, 
  43. the MySQLadmin debug command; allows you to connect (once) even if max_connections is reached  
  44. UPDATE  
  45. Allows use of UPDATE  
  46. USAGE  
  47. Synonym for “no privileges”  
  48. GRANT OPTION  
  49. Allows privileges to be granted  

 

 以上的相關(guān)內(nèi)容就是對(duì)MySQL常用技巧的介紹,望你能有所收獲。

【編輯推薦】

  1. MySQL存儲(chǔ)引擎InnoDB與MyISAM的差別
  2. MySQL數(shù)據(jù)庫(kù)中常用的應(yīng)用技巧有哪些?
  3. MySQL SHOW INDEX語(yǔ)法的實(shí)際應(yīng)用
  4. MySQL EXPLAIN語(yǔ)句中的extended 選項(xiàng)介紹
  5. 用MySQL 數(shù)字類(lèi)型如何正確的轉(zhuǎn)換函數(shù)
責(zé)任編輯:佚名 來(lái)源: 互聯(lián)網(wǎng)
相關(guān)推薦

2010-06-13 13:35:06

MySQL數(shù)據(jù)庫(kù)優(yōu)化

2010-05-21 16:33:02

MySQL數(shù)據(jù)庫(kù)

2010-05-21 18:20:43

MySQL常用技巧

2022-06-06 07:35:26

MySQLInnoDBMyISAM

2010-05-31 10:35:12

MySQL數(shù)據(jù)類(lèi)型

2020-06-04 10:49:53

Pandas字符串技巧

2011-07-01 16:05:22

SEO

2010-07-05 10:20:27

UML圖

2010-06-29 10:58:40

VoIP協(xié)議

2011-02-25 15:31:19

MySQL數(shù)據(jù)庫(kù)DBA

2010-09-07 10:20:21

CSS

2011-01-19 09:07:20

Thunderbird

2010-10-08 09:42:23

JavaScript方

2021-05-20 14:54:36

人工智能機(jī)器人技術(shù)

2016-10-20 20:21:09

Python爬蟲(chóng)技巧

2010-09-02 23:52:15

VoIP網(wǎng)絡(luò)協(xié)議

2017-09-25 15:03:54

2013-04-01 09:48:04

路由器QoS路由器設(shè)置

2013-05-23 10:01:38

2021-06-17 08:59:45

React前端優(yōu)化
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)