Mysql--show命令

2021-03-02 小碼奴

* 顯示所有的資料庫名稱

mysql root@localhost:sakila> show databases;                                                                     ++| Database           |++| information_schema || chain_dev          || jpa                || mysql              || performance_schema || sakila             || sys                || test               |++

* 顯示資料庫創建語句

mysql root@localhost:sakila> show create database sakila;                                                                                                                                                           +++| Database | Create Database                                                 |+++| sakila   | CREATE DATABASE `sakila` /*!40100 DEFAULT CHARACTER SET utf8 */ |+++1 row in set

* 顯示當前資料庫中所有表的名稱

mysql root@localhost:sakila> show tables;                                                                        +---+| Tables_in_sakila           |+---+| actor                      || actor_info                 || address                    || category                   || city                       || country                    || customer                   || customer_list              || film                       || film_actor                 || film_category              || film_list                  || film_text                  || inventory                  || language                   || nicer_but_slower_film_list || payment                    || rental                     || sales_by_film_category     || sales_by_store             || staff                      || staff_list                 || store                      |+---+

* 顯示某個資料庫的所有表名稱(未切換到某個具體的數據時使用)

mysql> show tables from sakila;+---+| Tables_in_sakila           |+---+| actor                      || actor_info                 || address                    || category                   || city                       || country                    || customer                   || customer_list              || film                       || film_actor                 || film_category              || film_list                  || film_text                  || inventory                  || language                   || nicer_but_slower_film_list || payment                    || rental                     || sales_by_film_category     || sales_by_store             || staff                      || staff_list                 || store                      |+---+

* 資料庫各個表(含視圖)的狀態

mysql root@localhost:sakila> show table status from sakila \G;                                                                                                                                                      ***************************[ 1. row ]***************************Name            | actorEngine          | InnoDBVersion         | 10Row_format      | DynamicRows            | 200Avg_row_length  | 81Data_length     | 16384Max_data_length | 0Index_length    | 16384Data_free       | 0Auto_increment  | 201Create_time     | 2020-11-26 16:08:11Update_time     | 2020-11-26 16:12:22Check_time      | <null>Collation       | utf8mb4_general_ciChecksum        | <null>Create_options  | Comment         | 

後面還有很多表...

如果只是想看某個表的狀態,則可以添加過濾條件

mysql root@localhost:sakila> show table status from sakila where name = 'actor'  \G;                                                                                                                                ***************************[ 1. row ]***************************Name            | actorEngine          | InnoDBVersion         | 10Row_format      | DynamicRows            | 200Avg_row_length  | 81Data_length     | 16384Max_data_length | 0Index_length    | 16384Data_free       | 0Auto_increment  | 201Create_time     | 2020-11-26 16:08:11Update_time     | 2020-11-26 16:12:22Check_time      | <null>Collation       | utf8mb4_general_ciChecksum        | <null>Create_options  | Comment         | 

1 row in setTime: 0.004s

查看視圖類型

mysql root@localhost:sakila> show table status from sakila where comment = 'view'  \G;                                                                                                                              ***************************[ 1. row ]***************************Name            | actor_infoEngine          | <null>Version         | <null>Row_format      | <null>Rows            | <null>Avg_row_length  | <null>Data_length     | <null>Max_data_length | <null>Index_length    | <null>Data_free       | <null>Auto_increment  | <null>Create_time     | <null>Update_time     | <null>Check_time      | <null>Collation       | <null>Checksum        | <null>Create_options  | <null>Comment         | VIEW

* 顯示函數的基本信息

mysql root@localhost:sakila> show FUNCTION STATUS \G;                                                                                                                                                               ***************************[ 1. row ]***************************Db                   | sakilaName                 | get_customer_balanceType                 | FUNCTIONDefiner              | root@localhostModified             | 2020-11-26 16:08:12Created              | 2020-11-26 16:08:12Security_type        | DEFINERComment              | character_set_client | utf8mb4collation_connection | utf8mb4_general_ciDatabase Collation   | utf8_general_ci還有很多信息...

* 過濾某個函數的信息

mysql root@localhost:sakila> show FUNCTION STATUS where name like '%inv%';                                                                                                                                          +---+---++-+-+-++----+--+--++| Db     | Name                       | Type     | Definer        | Modified            | Created             | Security_type | Comment | character_set_client | collation_connection | Database Collation |+---+---++-+-+-++----+--+--++| sakila | inventory_held_by_customer | FUNCTION | root@localhost | 2020-11-26 16:08:12 | 2020-11-26 16:08:12 | DEFINER       |         | utf8mb4              | utf8mb4_general_ci   | utf8_general_ci    || sakila | inventory_in_stock         | FUNCTION | root@localhost | 2020-11-26 16:08:12 | 2020-11-26 16:08:12 | DEFINER       |         | utf8mb4              | utf8mb4_general_ci   | utf8_general_ci    |+---+---++-+-+-++----+--+--++

2 rows in setTime: 0.016s

* 顯示某個表的信息

mysql root@localhost:sakila> desc actor;                                                                                                                                                                            +---+--+-++----+----+| Field       | Type                 | Null | Key | Default           | Extra                       |+---+--+-++----+----+| actor_id    | smallint(5) unsigned | NO   | PRI | <null>            | auto_increment              || first_name  | varchar(45)          | NO   |     | <null>            |                             || last_name   | varchar(45)          | NO   | MUL | <null>            |                             || last_update | timestamp            | NO   |     | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |+---+--+-++----+----+

4 rows in setTime: 0.008smysql root@localhost:sakila> describe actor; +---+--+-++----+----+| Field | Type | Null | Key | Default | Extra |+---+--+-++----+----+| actor_id | smallint(5) unsigned | NO | PRI | <null> | auto_increment || first_name | varchar(45) | NO | | <null> | || last_name | varchar(45) | NO | MUL | <null> | || last_update | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |+---+--+-++----+----+

4 rows in setTime: 0.010s

* 顯示某個表的創建語句

mysql root@localhost:sakila> show create table actor \G;                                                                                                                                                            ***************************[ 1. row ]***************************Table        | actorCreate Table | CREATE TABLE `actor` (  `actor_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,  `first_name` varchar(45) NOT NULL,  `last_name` varchar(45) NOT NULL,  `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,  PRIMARY KEY (`actor_id`),  KEY `idx_actor_last_name` (`last_name`)) ENGINE=InnoDB AUTO_INCREMENT=201 DEFAULT CHARSET=utf8mb4

1 row in setTime: 0.001s

類似的還有查看視圖創建、查看觸發器創建、查看存儲過程創建、用戶創建、函數創建等

mysql root@localhost:sakila> show create view actor_info \G;                                                                                                                                                        ***************************[ 1. row ]***************************View                 | actor_infoCreate View          | CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `actor_info` AS select `a`.`actor_id` AS `actor_id`,`a`.`first_name` AS `first_name`,`a`.`last_name` AS `last_name`,group_concat(distinct concat(`c`.`name`,': ',(select group_concat(`f`.`title` order by `f`.`title` ASC separator ', ') from ((`film` `f` join `film_category` `fc` on((`f`.`film_id` = `fc`.`film_id`))) join `film_actor` `fa` on((`f`.`film_id` = `fa`.`film_id`))) where ((`fc`.`category_id` = `c`.`category_id`) and (`fa`.`actor_id` = `a`.`actor_id`)))) order by `c`.`name` ASC separator '; ') AS `film_info` from (((`actor` `a` left join `film_actor` `fa` on((`a`.`actor_id` = `fa`.`actor_id`))) left join `film_category` `fc` on((`fa`.`film_id` = `fc`.`film_id`))) left join `category` `c` on((`fc`.`category_id` = `c`.`category_id`))) group by `a`.`actor_id`,`a`.`first_name`,`a`.`last_name`character_set_client | utf8mb4collation_connection | utf8mb4_general_ci

1 row in setTime: 0.002s

mysql root@localhost:sakila> show create trigger ins_film \G; ***************************[ 1. row ]***************************Trigger | ins_filmsql_mode | STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTIONSQL Original Statement | CREATE DEFINER=`root`@`localhost` TRIGGER `ins_film` AFTER INSERT ON `film` FOR EACH ROW BEGIN INSERT INTO film_text (film_id, title, description) VALUES (new.film_id, new.title, new.description); ENDcharacter_set_client | utf8mb4collation_connection | utf8mb4_general_ciDatabase Collation | utf8_general_ciCreated | 2020-11-26 16:08:12.040000

1 row in setTime: 0.004s

mysql root@localhost:sakila> show create procedure rewards_report \G; ***************************[ 1. row ]***************************Procedure | rewards_reportsql_mode | STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTIONCreate Procedure | CREATE DEFINER=`root`@`localhost` PROCEDURE `rewards_report`( IN min_monthly_purchases TINYINT UNSIGNED , IN min_dollar_amount_purchased DECIMAL(10,2) , OUT count_rewardees INT) READS SQL DATA COMMENT 'Provides a customizable report on best customers'proc: BEGIN

DECLARE last_month_start DATE; DECLARE last_month_end DATE;

/* Some sanity checks... */ IF min_monthly_purchases = 0 THEN SELECT 'Minimum monthly purchases parameter must be > 0'; LEAVE proc; END IF; IF min_dollar_amount_purchased = 0.00 THEN SELECT 'Minimum monthly dollar amount purchased parameter must be > $0.00'; LEAVE proc; END IF;

/* Determine start and end time periods */ SET last_month_start = DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH); SET last_month_start = STR_TO_DATE(CONCAT(YEAR(last_month_start),'-',MONTH(last_month_start),'-01'),'%Y-%m-%d'); SET last_month_end = LAST_DAY(last_month_start);

/* Create a temporary storage area for Customer IDs. */ CREATE TEMPORARY TABLE tmpCustomer (customer_id SMALLINT UNSIGNED NOT NULL PRIMARY KEY);

/* Find all customers meeting the monthly purchase requirements */ INSERT INTO tmpCustomer (customer_id) SELECT p.customer_id FROM payment AS p WHERE DATE(p.payment_date) BETWEEN last_month_start AND last_month_end GROUP BY customer_id HAVING SUM(p.amount) > min_dollar_amount_purchased AND COUNT(customer_id) > min_monthly_purchases;

/* Populate OUT parameter with count of found customers */ SELECT COUNT(*) FROM tmpCustomer INTO count_rewardees;

/* Output ALL customer information of matching rewardees. Customize output as needed. */ SELECT c.* FROM tmpCustomer AS t INNER JOIN customer AS c ON t.customer_id = c.customer_id;

/* Clean up */ DROP TABLE tmpCustomer;ENDcharacter_set_client | utf8mb4collation_connection | utf8mb4_general_ciDatabase Collation | utf8_general_ci

1 row in setTime: 0.001s

mysql root@localhost:sakila> show create user 'root'@'localhost' \G; ***************************[ 1. row ]***************************CREATE USER for root@localhost | CREATE USER 'root'@'localhost' IDENTIFIED WITH 'mysql_native_password' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK

1 row in setTime: 0.001s

mysql root@localhost:sakila> show create function inventory_held_by_customer \G; ***************************[ 1. row ]***************************Function | inventory_held_by_customersql_mode | STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTIONCreate Function | CREATE DEFINER=`root`@`localhost` FUNCTION `inventory_held_by_customer`(p_inventory_id INT) RETURNS int(11) READS SQL DATABEGIN DECLARE v_customer_id INT; DECLARE EXIT HANDLER FOR NOT FOUND RETURN NULL;

SELECT customer_id INTO v_customer_id FROM rental WHERE return_date IS NULL AND inventory_id = p_inventory_id;

RETURN v_customer_id;ENDcharacter_set_client | utf8mb4collation_connection | utf8mb4_general_ciDatabase Collation | utf8_general_ci

1 row in setTime: 0.002s

* 查看某個表的欄位信息

mysql root@localhost:sakila> show columns from actor;                                                                                                                                                               +---+--+-++----+----+| Field       | Type                 | Null | Key | Default           | Extra                       |+---+--+-++----+----+| actor_id    | smallint(5) unsigned | NO   | PRI | <null>            | auto_increment              || first_name  | varchar(45)          | NO   |     | <null>            |                             || last_name   | varchar(45)          | NO   | MUL | <null>            |                             || last_update | timestamp            | NO   |     | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |+---+--+-++----+----+

4 rows in setTime: 0.010s

沒有切換到具體資料庫的時候需要關聯資料庫

mysql root@localhost:(none)> show columns from actor from sakila;                                                                                                                                                   +---+--+-++----+----+| Field       | Type                 | Null | Key | Default           | Extra                       |+---+--+-++----+----+| actor_id    | smallint(5) unsigned | NO   | PRI | <null>            | auto_increment              || first_name  | varchar(45)          | NO   |     | <null>            |                             || last_name   | varchar(45)          | NO   | MUL | <null>            |                             || last_update | timestamp            | NO   |     | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |+---+--+-++----+----+

4 rows in setTime: 0.015s

* 顯示系統中正在運行的所有進程,也就是當前正在執行的查詢

mysql root@localhost:(none)> show processlist;                                                                                                                                                                      +----+-+--+---+----+--++---+| Id | User | Host            | db     | Command | Time  | State    | Info             |+----+-+--+---+----+--++---+| 21 | root | localhost:61384 | sys    | Sleep   | 11486 |          | <null>           || 22 | root | localhost:61387 | sys    | Sleep   | 11486 |          | <null>           || 32 | root | localhost:63007 | <null> | Query   | 0     | starting | show processlist |+----+-+--+---+----+--++---+

3 rows in setTime: 0.010s

* 顯示一些系統特定資源的信息

mysql root@localhost:(none)> show status \G;                                                                                                                                                                        ***************************[ 1. row ]***************************Variable_name | Aborted_clientsValue         | 20***************************[ 2. row ]***************************Variable_name | Aborted_connectsValue         | 5***************************[ 3. row ]***************************Variable_name | Binlog_cache_disk_useValue         | 0***************************[ 4. row ]***************************Variable_name | Binlog_cache_useValue         | 0***************************[ 5. row ]***************************Variable_name | Binlog_stmt_cache_disk_useValue         | 0

還有很多信息....

* 顯示系統變量和名稱

mysql root@localhost:(none)> show variables \G;                                                                                                                                                                     ***************************[ 1. row ]***************************Variable_name | auto_generate_certsValue         | ON***************************[ 2. row ]***************************Variable_name | auto_increment_incrementValue         | 1***************************[ 3. row ]***************************Variable_name | auto_increment_offsetValue         | 1***************************[ 4. row ]***************************Variable_name | autocommitValue         | ON***************************[ 5. row ]***************************Variable_name | automatic_sp_privilegesValue         | ON還有很多信息...
// 如果只想看某個變量的信息,可以過濾mysql root@localhost:(none)> show variables like '%auto_generate%'; ++--+| Variable_name | Value |++--+| auto_generate_certs | ON || sha256_password_auto_generate_rsa_keys | ON |++--+2 rows in setTime: 0.011s

* 顯示伺服器支持的不同權限

mysql root@localhost:(none)> show privileges;                                                                                                                                                                       ++----++| Privilege               | Context                               | Comment                                               |++----++| Alter                   | Tables                                | To alter the table                                    || Alter routine           | Functions,Procedures                  | To alter or drop stored functions/procedures          || Create                  | Databases,Tables,Indexes              | To create new databases and tables                    || Create routine          | Databases                             | To use CREATE FUNCTION/PROCEDURE                      || Create temporary tables | Databases                             | To use CREATE TEMPORARY TABLE                         || Create view             | Tables                                | To create new views                                   || Create user             | Server Admin                          | To create new users                                   || Delete                  | Tables                                | To delete existing rows                               || Drop                    | Databases,Tables                      | To drop databases, tables, and views                  || Event                   | Server Admin                          | To create, alter, drop and execute events             || Execute                 | Functions,Procedures                  | To execute stored routines                            || File                    | File access on server                 | To read and write files on the server                 || Grant option            | Databases,Tables,Functions,Procedures | To give to other users those privileges you possess   || Index                   | Tables                                | To create or drop indexes                             || Insert                  | Tables                                | To insert data into tables                            || Lock tables             | Databases                             | To use LOCK TABLES (together with SELECT privilege)   || Process                 | Server Admin                          | To view the plain text of currently executing queries || Proxy                   | Server Admin                          | To make proxy user possible                           || References              | Databases,Tables                      | To have references on tables                          || Reload                  | Server Admin                          | To reload or refresh tables, logs and privileges      || Replication client      | Server Admin                          | To ask where the slave or master servers are          || Replication slave       | Server Admin                          | To read binary log events from the master             || Select                  | Tables                                | To retrieve rows from table                           || Show databases          | Server Admin                          | To see all databases with SHOW DATABASES              || Show view               | Tables                                | To see views with SHOW CREATE VIEW                    || Shutdown                | Server Admin                          | To shut down the server                               || Super                   | Server Admin                          | To use KILL thread, SET GLOBAL, CHANGE MASTER, etc.   || Trigger                 | Tables                                | To use triggers                                       || Create tablespace       | Server Admin                          | To create/alter/drop tablespaces                      || Update                  | Tables                                | To update existing rows                               || Usage                   | Server Admin                          | No privileges - allow connect only                    |++----++31 rows in setTime: 0.010s

* 顯示伺服器的引摯

mysql root@localhost:(none)> show engines;                                                                                                                                                                          ++----+----+----+---+--+| Engine             | Support | Comment                                                        | Transactions | XA     | Savepoints |++----+----+----+---+--+| InnoDB             | DEFAULT | Supports transactions, row-level locking, and foreign keys     | YES          | YES    | YES        || MRG_MYISAM         | YES     | Collection of identical MyISAM tables                          | NO           | NO     | NO         || MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO     | NO         || BLACKHOLE          | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO     | NO         || MyISAM             | YES     | MyISAM storage engine                                          | NO           | NO     | NO         || CSV                | YES     | CSV storage engine                                             | NO           | NO     | NO         || ARCHIVE            | YES     | Archive storage engine                                         | NO           | NO     | NO         || PERFORMANCE_SCHEMA | YES     | Performance Schema                                             | NO           | NO     | NO         || FEDERATED          | NO      | Federated MySQL storage engine                                 | <null>       | <null> | <null>     |++----+----+----+---+--+

9 rows in setTime: 0.016s

* 顯示最後一個執行的語句所產生的錯誤、警告和通知

mysql root@localhost:sakila> show warnings;                                                                                                                                                                         +--+-++| Level | Code | Message                                                                                                                                              |+--+-++| Error | 1064 | You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'wa' at line 1 |+--+-++

1 row in setTime: 0.011s

* 顯示最後一個執行語句所產生的錯誤

mysql root@localhost:sakila> show errors;                                                                                                                                                                           +--+-++| Level | Code | Message                                                                                                                                              |+--+-++| Error | 1064 | You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'wa' at line 1 |+--+-++

1 row in setTime: 0.009s

* 顯示伺服器的編碼列表

mysql root@localhost:sakila> show CHARACTER SET;                                                                                                                                                                    ++---+-+---+| Charset  | Description                     | Default collation   | Maxlen |++---+-+---+| big5     | Big5 Traditional Chinese        | big5_chinese_ci     | 2      || dec8     | DEC West European               | dec8_swedish_ci     | 1      || cp850    | DOS West European               | cp850_general_ci    | 1      || hp8      | HP West European                | hp8_english_ci      | 1      || koi8r    | KOI8-R Relcom Russian           | koi8r_general_ci    | 1      || latin1   | cp1252 West European            | latin1_swedish_ci   | 1      || latin2   | ISO 8859-2 Central European     | latin2_general_ci   | 1      || swe7     | 7bit Swedish                    | swe7_swedish_ci     | 1      || ascii    | US ASCII                        | ascii_general_ci    | 1      || ujis     | EUC-JP Japanese                 | ujis_japanese_ci    | 3      || sjis     | Shift-JIS Japanese              | sjis_japanese_ci    | 2      || hebrew   | ISO 8859-8 Hebrew               | hebrew_general_ci   | 1      || tis620   | TIS620 Thai                     | tis620_thai_ci      | 1      || euckr    | EUC-KR Korean                   | euckr_korean_ci     | 2      || koi8u    | KOI8-U Ukrainian                | koi8u_general_ci    | 1      || gb2312   | GB2312 Simplified Chinese       | gb2312_chinese_ci   | 2      || greek    | ISO 8859-7 Greek                | greek_general_ci    | 1      || cp1250   | Windows Central European        | cp1250_general_ci   | 1      || gbk      | GBK Simplified Chinese          | gbk_chinese_ci      | 2      || latin5   | ISO 8859-9 Turkish              | latin5_turkish_ci   | 1      || armscii8 | ARMSCII-8 Armenian              | armscii8_general_ci | 1      || utf8     | UTF-8 Unicode                   | utf8_general_ci     | 3      || ucs2     | UCS-2 Unicode                   | ucs2_general_ci     | 2      || cp866    | DOS Russian                     | cp866_general_ci    | 1      || keybcs2  | DOS Kamenicky Czech-Slovak      | keybcs2_general_ci  | 1      || macce    | Mac Central European            | macce_general_ci    | 1      || macroman | Mac West European               | macroman_general_ci | 1      || cp852    | DOS Central European            | cp852_general_ci    | 1      || latin7   | ISO 8859-13 Baltic              | latin7_general_ci   | 1      || utf8mb4  | UTF-8 Unicode                   | utf8mb4_general_ci  | 4      || cp1251   | Windows Cyrillic                | cp1251_general_ci   | 1      || utf16    | UTF-16 Unicode                  | utf16_general_ci    | 4      || utf16le  | UTF-16LE Unicode                | utf16le_general_ci  | 4      || cp1256   | Windows Arabic                  | cp1256_general_ci   | 1      || cp1257   | Windows Baltic                  | cp1257_general_ci   | 1      || utf32    | UTF-32 Unicode                  | utf32_general_ci    | 4      || binary   | Binary pseudo charset           | binary              | 1      || geostd8  | GEOSTD8 Georgian                | geostd8_general_ci  | 1      || cp932    | SJIS for Windows Japanese       | cp932_japanese_ci   | 2      || eucjpms  | UJIS for Windows Japanese       | eucjpms_japanese_ci | 3      || gb18030  | China National Standard GB18030 | gb18030_chinese_ci  | 4      |++---+-+---+

41 rows in setTime: 0.015s

相關焦點

  • MySQL 常用show命令
    參考來源:網絡  責編 | 檸檸精品課:522字 |2 分鐘閱讀MySQL中有很多的基本命令,show命令也是其中之一,在很多使用者中對show命令的使用還容易產生混淆,本文匯集了show命令的眾多用法。
  • 詳解MySQL資料庫中Show命令的用法
    MySQL中有很多的基本命令,show命令也是其中之一,在很多使用者中對show命令的使用還容易產生混淆,本文主要介紹了show命令的主要用法。 a. show tables或show tables from database_name; -- 顯示當前資料庫中所有表的名稱。
  • mysql 常用命令一
    【資料庫連接】 mysql -h ip -u name -ppassword -P port -D database_name>【資料庫SHOW命令】 顯示mysql中所有資料庫的名稱 show databases;#顯示mysql中的相關 show tables [ from db_name
  • 新手入門MYSQL資料庫命令大全
    一、命令行連接資料庫Windows作業系統進入CMD命令行,進入mysql.exe所在目錄,運行命令mysql.exe -h主機名 -u用戶名 -p密碼注意:參數名與值之間沒有空格 , 如:-h127.0.0.1
  • MySQL資料庫常用命令詳解
    (1)登錄MySQL資料庫用SSH客戶端連接CentOS伺服器,打開終端命令輸入窗口,在終端輸入窗口輸入命令:mysql -uroot –p 該命令用root帳號以密碼方式登錄MySQL,回車後提示輸入密碼
  • mysql常用命令,保存一下,以後查詢方便了
    格式:grant select on 資料庫.* to 用戶名@登錄主機 identified by "密碼"grant select,insert,update,delete on *.* to test1@"%" Identified by "abc";7、使用test1帳號從其他主機上登錄命令
  • MySQL show profile使用說明
    show profile 和 show profiles 命令用於展示SQL語句的資源使用情況,包括CPU的使用,CPU上下文切換,IO等待,內存使用等,這個命令對於分析某個SQL的性能瓶頸非常有幫助,藉助於show profile的輸出信息,能讓我們知道一個SQL在哪個階段耗時最長
  • mysql show processlist Time為負數的思考
    二、關於show processlist中的Time實際上show processlist中的信息基本都來自函數 mysqld_list_processes,也就是說每次執行show1、執行命令如果主庫執行常見的命令都會在命令發起的時候調用重載1,設置start_time為命令開始執行的時間如下:堆棧:#0 THD::set_time (this=0x7ffe7c000c90) at /mysqldata/percona-server-locks-detail-5.7.22/sql
  • 技術分享 | mysql show processlist Time 為負數的思考
    文章末尾有他著作的《深入理解 MySQL 主從原理 32 講》,深入透徹理解 MySQL 主從,GTID 相關技術知識。
  • 5 分鐘小技巧系列 | 定製化 MySQL Show Processlist 輸出結果
    在 MySQL 的命令提示符下,可以使用 \P 的命令設定要過濾的內容,步驟如下:$ mysql -u root -p$ mysql> \P grep -v Sleep# 此時輸出結果就沒有 Sleep 相關的信息了$ mysql> Show Full Processlist; 在使用
  • mysql 慢查詢命令
    如何查找MySQL中查詢慢的SQL語句更多如何在mysql查找效率慢的SQL語句呢?找到[mysqld]下面加上代碼如下log-slow-queries = F:/MySQL/log/mysqlslowquery。
  • 學會用 Mysql show processlist 排查問題
    mysql show full processlist 查看當前線程處理情況事發現場每次執行看到的結果應該都有變化,因為是實時的,
  • MySQL - mysqldump常用命令 - linux運維菜
    導出數據1、備份全部資料庫的數據和表結構mysqldump -uroot -ppassword -A >all.sql2、只備份表結構,不備份數據mysqldump -uroot -ppassword -A -d > database.sql3、只備份資料庫,不備份表結構mysqldump -uroot -ppassword -A -t > data.sql
  • MySQL優化:學會使用show profile和trace分析慢查詢
    使用如下命令開啟:mysql> set profiling=1;1.3 執行要分析的sql語句mysql> select * from test_table where d=90000;執行完成SQL後再執行
  • 一文詳解MySQL權限
    ,• Reference權限是在5.7.6版本之後引入,代表是否允許創建外鍵• Reload權限代表允許執行flush命令,指明重新加載權限表到系統內存中, refresh命令代表關閉和重新開啟日誌文件並刷新所有的表• Replication client權限代表允許執行show master status,show slave status,show binary logs
  • Linux下MySQL的一些基本使用方法
    mysql> 注意:操作這些命令的時候,應該把mysqld伺服器打開。這些新手兄弟早就知道了吧:)3]如何在資料庫中操作命令呢,我想這是mysql手冊都有的,我主要說幾個要注意的地方。其實我也會不了幾個命令。
  • 【用binlog日誌】恢復 MySQL 資料庫刪除數據
    在MySQL命令行下使用show variables like 『log_bin』;命令查看binlog日誌是否開啟,Value的值為ON表示開啟,為OFF表示關閉。在存放資料庫的文件夾中是否存在mysql-bin.000001類似的文件,有則表示binlog日誌功能是開啟的。
  • 用 Docker 構建 MySQL 主從環境
    首先使用 docker 命令進入到 mysql-master 容器中,再登錄到 mysql 輸入show master status命令獲取主庫狀態,這裡我們要關心兩個參數 File 以及 Position,之後配置從庫會用到這兩個參數
  • MySQL EXPLAIN 命令詳解
    MySQL的EXPLAIN命令用於SQL語句的查詢執行計劃(QEP)。這條命令的輸出結果能夠讓我們了解MySQL 優化器是如何執行SQL 語句的。這條命令並沒有提供任何調整建議,但它能夠提供重要的信息幫助你做出調優決策。一、語法MySQL 的EXPLAIN 語法可以運行在SELECT 語句或者特定表上。
  • Centos7 安裝MySQL 5.7
    mysql57-community-release-el7-10.noarch.rpm使用上面的命令就直接下載了安裝用的Yum Repository,,然後就可以直接yum安裝了。:grep "password" /var/log/mysqld.log使用如下命令進入資料庫:mysql -uroot -p輸入初始密碼(是上面圖片最後面的紅色框內字符),此時不能做任何事情,因為MySQL默認必須修改密碼之後才能操作資料庫: