mysql匯入source資料庫
阿新 • • 發佈:2018-12-15
首先要確保資料庫存在,如果不存在則建立
方法1 source
很智慧,很方便,很快捷。
# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 54467 Server version: 5.6.36-log Source distribution Copyright (c) 2000, 2018, 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. mysql> use wenbo Database changed mysql> source ./wenbo_test.sql Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.04 sec) Query OK, 0 rows affected (0.00 sec)
你可以執行很多次都沒有關係。
可以執行資料庫,可以執行單個表,都是可以的。
mysql> source ./wenbo_online.sql
如果sql中是整個資料庫,那麼source之後,整個資料庫都變了。如果只是整個表的資料,那麼整個表的資料都變了。
其是它就相當於,將sql檔案中的sql語句全部執行一遍。具體什麼效果,還要看sql語句的內容。
方法2 <
mysql -uroot -p wenbo < ./wenbo_test.sql
效果跟source一樣,只是沒有執行過程。