如何在命令列提示符中使用 MySQL 二進位制檔案建立 MySQL 資料庫?
你可以使用命令提示符中的 mysql 二進位制檔案建立 MySQL 資料庫。以下示例可以幫助理解 −
示例
我們可以使用以下語句從命令提示符連線到 MySQL 伺服器 −
[root@host]# mysql -u root -p Enter password:******
這將為我們提供 mysql> 命令提示符,我們可以在其中執行任何 SQL 命令。以下是上述命令的結果 −
以下程式碼塊顯示了上述程式碼的結果 −
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.7.20 MySQL Community Server (GPL) Copyright (c) 2000, 2017, 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.
在上面的示例中,我們使用 root 作為使用者,但你也可以使用任何其他使用者。任何使用者都能夠執行該使用者允許的所有 SQL 操作。
我們可以隨時使用 mysql> 提示符中的exit 命令斷開與 MySQL 資料庫的連線。
mysql> exit Bye
廣告