随手记mysql_MySQL
程序员文章站
2022-05-19 08:35:48
...
1,mysql: left, right, outer, inner, left outer, 以及 right outer.
2,导出数据:
mysql> SELECT * FROM tutorials_tbl -> INTO OUTFILE '/tmp/tutorials.txt';#导出csv格式mysql> SELECT * FROM passwd INTO OUTFILE '/tmp/tutorials.txt' -> FIELDS TERMINATED BY ',' ENCLOSED BY '"' -> LINES TERMINATED BY '/r/n';
3,导入数据:mysqldump、load data和mysqlimport
#导出$ mysqldump -u root -p TUTORIALS tutorials_tbl > dump.txt#导入$ mysql -u root -p database_name LOAD DATA LOCAL INFILE 'dump.txt' INTO TABLE mytbl;mysql> LOAD DATA LOCAL INFILE 'dump.txt' INTO TABLE mytbl -> FIELDS TERMINATED BY ':' -> LINES TERMINATED BY '/r/n';mysql>LOAD DATA LOCAL INFILE 'dump.txt' -> INTO TABLE mytbl (b, c, a);$ mysqlimport -u root -p --local database_name dump.txt
4,将导出的数据直接导入到远程的服务器
$ mysqldump -u root -p database_name / | mysql -h other-host.com database_name