av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

創(chuàng)新互聯(lián)數(shù)據(jù)庫教程:MySQL登錄和退出服務(wù)器

在《 登錄MySQL數(shù)據(jù)庫》一節(jié),我們了解到用戶可以通過 mysql 命令來登錄 MySQL 服務(wù)器。但是前面還有些參數(shù)沒有介紹到,本節(jié)將詳細(xì)介紹 MySQL 中登錄和退出服務(wù)器的方法。

啟動 MySQL 服務(wù)后,可以使用以下命令來登錄。

mysql -h hostname|hostlP -p port -u username -p DatabaseName -e "SQL語句"

對上述參數(shù)說明如下:

  • -h:指定連接 MySQL 服務(wù)器的地址??梢杂脙煞N方式表示,hostname 為主機(jī)名,hostIP 為主機(jī) IP 地址。
  • -p:指定連接 MySQL 服務(wù)器的端口號,port 為連接的端口號。MySQL 的默認(rèn)端口號是 3306,因此如果不指定該參數(shù),默認(rèn)使用 3306 連接 MySQL 服務(wù)器。
  • -u:指定連接 MySQL 服務(wù)器的用戶名,username 為用戶名。
  • -p:提示輸入密碼,即提示 Enter password。
  • DatabaseName:指定連接到 MySQL 服務(wù)器后,登錄到哪一個數(shù)據(jù)庫中。如果沒有指定,默認(rèn)為 mysql 數(shù)據(jù)庫。
  • -e:指定需要執(zhí)行的 SQL 語句,登錄 MySQL 服務(wù)器后執(zhí)行這個 SQL 語句,然后退出 MySQL 服務(wù)器。

例 1

下面使用 root 用戶登錄到 test 數(shù)據(jù)庫中,命令和運(yùn)行過程如下:

C:\Users\11645>mysql -h localhost -u root -p test
Enter password: ****
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.29-log MySQL Community Server (GPL)

Copyright (c) 2000, 2020, 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.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

上述命令中,通過值 localhost 指定 MySQL 服務(wù)器的地址,參數(shù) -u 指定了登錄 MySQL 服務(wù)器的用戶賬戶,參數(shù) -p 表示會出現(xiàn)輸入密碼提示信息,最后值“test”指定了登錄成功后要使用的數(shù)據(jù)庫。

由結(jié)果可以看到,輸入命令后,會出現(xiàn)“Enter password”提示信息,在這條信息之后輸入密碼,然后按 Enter 鍵。密碼正確后,就成功登錄到 MySQL 服務(wù)器了。

例 2

下面使用 root 用戶登錄到自己計算機(jī)的 mysql 數(shù)據(jù)庫,同時查詢 student 表的表結(jié)構(gòu),命令和運(yùn)行過程如下:

C:\Users\11645>mysql -h localhost -u root -p test -e"DESC student"
Enter password: ****
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id    | int(4)      | NO   | PRI | NULL    |       |
| name  | varchar(20) | YES  |     | NULL    |       |
| age   | int(4)      | YES  |     | NULL    |       |
| stuno | int(11)     | YES  |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+

結(jié)果顯示,執(zhí)行命令并輸入正確密碼后,窗口中就會顯示出 student 表的基本結(jié)構(gòu)。

用戶也可以直接在 mysql 命令的 -p 后加上登錄密碼,登錄密碼與 -p 之間沒有空格。

例 3

下面使用 root 用戶登錄到自己計算機(jī)的 MySQL 服務(wù)器中,密碼直接加在 mysql 命令中。命令如下:

C:\Users\11645>mysql -h localhost -u root -proot
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.29-log MySQL Community Server (GPL)

Copyright (c) 2000, 2020, 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.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

上述命令執(zhí)行后,后面不會提示輸入密碼。因為 -p 后面有密碼,MySQL 會直接使用這個密碼。

退出 MySQL 服務(wù)器的方式很簡單,只要在命令行輸入 EXIT 或 QUIT 即可。“\q”是 QUIT 的縮寫,也可以用來退出 MySQL 服務(wù)器。退出后就會顯示 Bye。如下所示:

mysql> QUIT;
Bye

新聞名稱:創(chuàng)新互聯(lián)數(shù)據(jù)庫教程:MySQL登錄和退出服務(wù)器
路徑分享:http://uogjgqi.cn/article/djjdcdc.html
掃二維碼與項目經(jīng)理溝通

我們在微信上24小時期待你的聲音

解答本文疑問/技術(shù)咨詢/運(yùn)營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流