Mysqldump
Jihongchang(讨论 | 贡献)2024年7月10日 (三) 02:57的版本 (建立内容为“mysqldump 命令可以备份数据库中的数据。 备份时是在备份文件中保存了 create 语句和 insert 语句。<syntaxhighlight lang="shell"> mysq…”的新页面)
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 等字符型字段