???? 上篇文章介紹了在Windows10下安裝MySQL,本篇文章介紹cmd下簡單的操作。
1、登錄 MySQL
????? 當 MySQL 服務已經運行時, 我們可以通過 MySQL 自帶的客戶端工具登錄到 MySQL 數據庫中, 首先打開命令提示符, 輸入以下格式的命名:
mysql -h 主機名 -u 用戶名 -p
參數說明:
-h : 指定客戶端所要登錄的 MySQL 主機名, 登錄本機(localhost 或 127.0.0.1)該參數可以省略;
-u : 登錄的用戶名;
-p : 告訴服務器將會使用一個密碼來登錄, 如果所要登錄的用戶名密碼為空, 可以忽略此選項。
如果我們要登錄本機的 MySQL 數據庫,只需要輸入以下命令即可:
mysql -u root -p
按回車確認, 如果安裝正確且 MySQL 正在運行, 會得到以下響應:
Enter password:
若前期未設置密碼則enter后會顯示:
Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 8Server version: 8.0.21 MySQL Community Server - GPLCopyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
???? ?登錄成功后會有如下 mysql> 界面, 輸入 exit 或 quit 退出登錄。