“Mysqldump”的版本间的差异

来自姬鸿昌的知识库
跳到导航 跳到搜索
第21行: 第21行:
  
 
"--fields-optionally-enclosed-by=""设置字符括上 char、varchar 和 text 等字符型字段
 
"--fields-optionally-enclosed-by=""设置字符括上 char、varchar 和 text 等字符型字段
 
 
 
出现<syntaxhighlight lang="text">
 
出现<syntaxhighlight lang="text">
 
mysqldump: [Warning] Using a password on the command line interface can be insecure.
 
mysqldump: [Warning] Using a password on the command line interface can be insecure.
第38行: 第36行:
 
|C:\ProgramData\MySQL\MySQL Server 5.7\Uploads\
 
|C:\ProgramData\MySQL\MySQL Server 5.7\Uploads\
 
|}
 
|}
 +
所以就只能导出到 "C:\ProgramData\MySQL\MySQL Server 5.7\Uploads\" 这个位置

2024年7月10日 (三) 04:26的版本

mysqldump 命令可以备份数据库中的数据。

备份时是在备份文件中保存了 create 语句和 insert 语句。

mysqldump -u root -pPassword -T 目标目录 dbname table [option];

Password 参数表示 root 用户的密码,密码紧挨着 -p 选项;

目标目录 参数是指导出的文本文件的路径;

dbname 参数表示数据库的名称;

table 参数表示表的名称;

option 表示附件选项。


示例

C:\Users\Administrator>mysqldump -u root -p123456 -T E:\record\2024\7\10\ testdb student "--fields-terminated-by=," "--fields-optionally-enclosed-by=""
mysqldump: [Warning] Using a password on the command line interface can be insecure.
mysqldump: Got error: 1290: The MySQL server is running with the --secure-file-priv option so it cannot execute this statement when executing 'SELECT INTO OUTFILE'

"--fields-terminated-by=," 设置 , 为字段的分隔符,默认值是"\t";

"--fields-optionally-enclosed-by=""设置字符括上 char、varchar 和 text 等字符型字段

出现

mysqldump: [Warning] Using a password on the command line interface can be insecure.
mysqldump: Got error: 1290: The MySQL server is running with the --secure-file-priv option so it cannot execute this statement when executing 'SELECT INTO OUTFILE'

的原因是安装MySQL的时候限制了导入与导出的目录权限,只允许在规定的目录下才能导出、导入。 可以通过

show variables like "secure_file_priv";

查看允许导出、导入的目录位置

Variable_name Value
secure_file_priv C:\ProgramData\MySQL\MySQL Server 5.7\Uploads\

所以就只能导出到 "C:\ProgramData\MySQL\MySQL Server 5.7\Uploads\" 这个位置