使用命令選項連接到 MySQL 伺服器
讓我們看看如何使用命令列選項與MySQL伺服器建立連接,例如mysql或mysqldump這樣的客戶端。
為了讓客戶端程式能夠連接到MySQL伺服器,它必須使用正確的連線參數,例如伺服器執行的主機名稱、MySQL帳戶的使用者名稱和密碼。每個連接參數都有一個預設值,但在必要時可以使用在命令列或選項檔案中指定的程式選項進行覆寫。
呼叫mysql
呼叫mysql而不指定任何明確連線參數的指令是−
mysql
由於沒有參數選項,將會套用預設值。
預設主機名稱為localhost。在Unix上,它有特殊意義。
預設使用者名稱在Windows上是ODBC。在Unix上,是Unix上的登入名稱。
沒有發送密碼,因為沒有提供--password或-p。
對於mysql,第一個參數被視為預設資料庫的名稱。由於沒有這樣的參數,因此mysql不選擇任何預設資料庫。
Imvoke - 指定主機名稱、使用者名稱和密碼
#要明確指定主機名稱、使用者名稱和密碼,必須在命令列上提供適當的選項。如下圖:
mysql --host=localhost --user=myname --password=password mydb mysql -h localhost -u myname -ppassword mydb
The password value is optional.
If a --password or -p option is present, and a password value is mentioned, there shouldn 't be any space between --password= or -p and the password that follows it.
If --password or -p doesn't specify a password value, the client program prompts the user to enter the password. The password doesn't get displayed when it is entered.
Type of Connection
Next step is for client programs to determine the type of connection that needs to be made. To ensure that the client makes a TCP/IP connection to the local server only, the --host or -h option is used to specify a host name with the value of 127.0.0.1 (instead of localhost). Instead of this, the IP address or name of the local server can also be provided. The transport protocol can be explicitly mentioned even for localhost using the --protocol=TCP option。 #
mysql --host=127.0.0.1 mysql --protocol=TCP
mysql --host=remote.example.com
mysql --host=remote.example.com --port=13306
以上是使用命令選項連接到 MySQL 伺服器的詳細內容。更多資訊請關注PHP中文網其他相關文章!

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

熱門話題

本文討論了使用MySQL的Alter Table語句修改表,包括添加/刪除列,重命名表/列以及更改列數據類型。

文章討論了為MySQL配置SSL/TLS加密,包括證書生成和驗證。主要問題是使用自簽名證書的安全含義。[角色計數:159]

文章討論了流行的MySQL GUI工具,例如MySQL Workbench和PhpMyAdmin,比較了它們對初學者和高級用戶的功能和適合性。[159個字符]

本文討論了使用Drop Table語句在MySQL中放下表,並強調了預防措施和風險。它強調,沒有備份,該動作是不可逆轉的,詳細介紹了恢復方法和潛在的生產環境危害。

本文討論了在PostgreSQL,MySQL和MongoDB等各個數據庫中的JSON列上創建索引,以增強查詢性能。它解釋了索引特定的JSON路徑的語法和好處,並列出了支持的數據庫系統。

文章討論了使用準備好的語句,輸入驗證和強密碼策略確保針對SQL注入和蠻力攻擊的MySQL。(159個字符)
