所以我试图重新访问我的服务器数据库并让它运行命令将几个表全部导出到单个 csv 文件。所以我有一个命令行命令参数,如下所示:
mysql -h 198.xxx.xxx.xxx -u user-p < file.txt
file.txt 的内容如下所示:
SELECT * FROM log
INTO OUTFILE 'C:\USERS\username\Desktop\log.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
SELECT * FROM permission_types
INTO OUTFILE 'C:\USERS\username\Desktop\permission_types.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
SELECT * FROM personal_info_options
INTO OUTFILE 'C:\USERS\username\Desktop\personal_info_options.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
我不确定我是否有这个权利的语法,或者如果这可能的话,我一直在做一堆研究试图获得例子。人们通常会告诉你概念,但似乎从来没有给你测试它们所需的代码,它总是像这样:
mysql -h localhost -u user-p < somefile and they don't show you contents
of a file for example
我正在运行 Windows 7,我安装了 WAMPServer,它具有 MYSQL 版本 5.5.24,我可以通过命令行访问它。我不确定 FILEDS TERMINATED BY 或 ENCLOSED BY 或 LINES TERMINATED BY ... 我需要这些吗?这实际上会保存到我的本地机器吗?我对运行这个脚本很紧张,我不想犯错误并弄乱数据库。.txt 也可以用于脚本文件吗?
你能提供的任何帮助都会很棒。