Ubuntu16.04系統mysql命令匯入匯出sql檔案
阿新 • • 發佈:2019-01-01
一.匯入sql檔案命令規則: mysql -u userName -p 目標資料庫 < 源sql檔案路徑;結束
我測試是匯入quartz原始碼包中的12張表
[email protected]:~$ mysql -u root -p linux_mysql < /home/tao/下載/quartz-2.2.3/docs/dbTables/tables_mysql.sql;
Enter password:[email protected]:~$ mysql -u root -p linux_mysql;
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.7.13 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, 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> show tables;
+--------------------------+
| Tables_in_linux_mysql |
+--------------------------+
| QRTZ_BLOB_TRIGGERS |
| QRTZ_CALENDARS |
| QRTZ_CRON_TRIGGERS |
| QRTZ_FIRED_TRIGGERS |
| QRTZ_JOB_DETAILS |
| QRTZ_LOCKS |
| QRTZ_PAUSED_TRIGGER_GRPS |
| QRTZ_SCHEDULER_STATE |
| QRTZ_SIMPLE_TRIGGERS |
| QRTZ_SIMPROP_TRIGGERS |
| QRTZ_TRIGGERS |
+--------------------------+
11 rows in set (0.00 sec)
mysql>
二.匯出表儲存為sql檔案規則:mysqldump -u userName -p 源資料庫 > 目標目錄中的.sql檔案;結束(不需要自建.sql檔案)
匯出我剛才所匯入進去的12張表
[email protected]:~$ mysqldump -u root -p linux_mysql > /home/tao/下載/tables_mysql.sql;
Enter password:
[email protected]:~$