問題描述
我有一個從 phpMyAdmin
導出的 .sql
文件.我想使用命令行將其導入不同的服務器.
我安裝了 Windows Server 2008 R2.我把.sql
文件放在C盤,我試了一下這個命令
database_name <文件.sql
它不起作用.我收到語法錯誤.
- 如何才能順利導入此文件?
- 我需要先創建一個數據庫嗎?
嘗試:
mysql -u 用戶名 -p 數據庫名稱 <文件.sql
檢查 MySQL 選項.>
注意1:最好使用SQL文件file.sql
的完整路徑.
注2:使用-R
和--triggers
保持原數據庫的例程和觸發器.默認情況下不會復制它們.
注意 3 如果 MySQL 不存在并且導出的 SQL 不包含 CREATE DATABASE
(導出的),您可能需要從 MySQL 創建(空)數據庫使用 --no-create-db
或 -n
選項),然后才能導入它.
I have a .sql
file with an export from phpMyAdmin
. I want to import it into a different server using the command line.
I have a Windows Server 2008 R2 installation. I placed the .sql
file on the C drive, and I tried this command
database_name < file.sql
It is not working. I get syntax errors.
- How can I import this file without a problem?
- Do I need to create a database first?
Try:
mysql -u username -p database_name < file.sql
Check MySQL Options.
Note 1: It is better to use the full path of the SQL file file.sql
.
Note 2: Use -R
and --triggers
to keep the routines and triggers of original database. They are not copied by default.
Note 3 You may have to create the (empty) database from MySQL if it doesn't exist already and the exported SQL don't contain CREATE DATABASE
(exported with --no-create-db
or -n
option), before you can import it.
這篇關于如何在 MySQL 中使用命令行導入 SQL 文件?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!