來源:轉(zhuǎn)載 發(fā)布時(shí)間:2018-07-03 17:19:07 閱讀量:1321
前提 : 本人用的是windows10系統(tǒng); 安裝的是MySQL 8.0版本
實(shí)際操作文件是 employees.sql 按官網(wǎng)的步驟 先進(jìn)入MySQL的執(zhí)行目錄
Download the repository
Change directory to the repository
按網(wǎng)上提供的教程是在命令框中執(zhí)行命令:
mysql -uroot -p < emplopees.sql
對此需要注意的是,我的樣例數(shù)據(jù)庫在另一個(gè)目錄,這意味這需要在employees.sql前加上該文件的絕對路徑即
mysql -uroot -p < yourpath\emplopees.sql
------------------------------------------------------------------------------------------------
然后發(fā)現(xiàn)執(zhí)行source部分的時(shí)候會出現(xiàn)
unknown command '\'
的錯(cuò)誤 這是路徑上出現(xiàn)的問題
網(wǎng)上是說 編碼格式不一致所致 可以通過指定編碼解決 如
Mysql -u root -p --default-character-set=utf8 database <backpath
但是我試了一下發(fā)現(xiàn)沒有效果,網(wǎng)上又說 把 路徑中 所有單斜杠'\' 換成雙斜杠進(jìn)行轉(zhuǎn)義'\\' 即可, 雖然也會報(bào)錯(cuò)但也可以解決問題,我就這樣解決了;
----------------------------------------------------------------------------------------------------------------
本來以為可以用自帶的workbench執(zhí)行sql文件進(jìn)行數(shù)據(jù)錄入,沒想到sql頁面的source會報(bào)錯(cuò),下面出現(xiàn)紅曲線有語法錯(cuò)誤,我查了一下,在stackoverflow上發(fā)現(xiàn)這樣一個(gè)回答:
The source command is not a MySQL statement, but something only handled by the MySQL client. MySQL Workbench does not handle this (as it is focused on pure MySQL code).
To import the entire set remove the source commands from the main file and then manually import these files like you did with the main dump. A bit tedious, but at least a way to load all files.
google翻譯就是:
source命令不是MySQL語句,而是一些只能由MySQL客戶端處理的命令。 MySQL Workbench不處理這個(gè)問題(因?yàn)樗鼘W⒂诩僊ySQL代碼)。
要導(dǎo)入整個(gè)集合,請從主文件中刪除源命令,然后像使用主轉(zhuǎn)儲一樣手動導(dǎo)入這些文件。 有點(diǎn)乏味,但至少可以加載所有文件。
然后我就把employees.sql文件分為兩部分,把source部分在CMD手動輸入,其他
mysql -uroot -p < yourpath\emplopees.sql自動執(zhí)行;
------------------------------------------------------------------------------
Failed to open file 'load_departments.dump'
其次遇到找不到源文件的情況load_departments.dump ;需要在每個(gè)源文件前加絕對路徑即可解決;
------------------------------------------------------------------------------
到此所有數(shù)據(jù)庫建表導(dǎo)入數(shù)據(jù)的部分工作就完成了;
原文地址https://blog.csdn.net/u013529093/article/details/80860338
在線
客服
客服
熱線
7*24小時(shí)客服服務(wù)熱線
關(guān)注
微信
關(guān)注官方微信