1.登錄Linux
2.登錄MySQL:mysql -h192.168.1.1 -uroot -p123123 【h-服務器IP,u-用戶名,p-密碼】
3.use mysqldemo; 【切換到表數據所在庫】
4.1導出數據:select * from TABLE into outfile '/var/lib/mysql-files/DEMO.SQL' fields terminated by ","; 【把TABLE查詢的結果輸出到/var/lib/mysql-files/DEMO.SQL;fields terminated by ","已逗號分隔,方便后面導入,也可以不加分隔】
①路徑/var/lib/mysql-files/是因為若不指定則會報錯:ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement,
show variables like '%secure%'; 【其他目錄對MySQL的權限限制,只能輸出到默認】
+--------------------------+-----------------------+ | Variable_name | Value | +--------------------------+-----------------------+ | require_secure_transport | OFF | | secure_auth | ON | | secure_file_priv | /var/lib/mysql-files/ | +--------------------------+-----------------------+
4.2導入數據:load data infile '/var/lib/mysql-files/DEMO.SQL' into table TABLE fields terminated by ",";【如果不加分隔符會導致多列插入第一列】