大网数据广告活动
服务器运维问答

Used mysql command instead of mysqldump

· 52CE 我爱测

I wanted to backup my MySQL database and I accidentally used mysql command instead of mysqldump . So I executed: /usr/local/mysql5/bin/mysql -u db_username -p db_name > db_backup.sql Instead of: /usr/local/mysql5/bin/mysqldump -u…

问题原文

原帖链接 · TmCrafz · CC BY-SA 4.0

I wanted to backup my MySQL database and I accidentally used mysql command instead of mysqldump. So I executed:

/usr/local/mysql5/bin/mysql -u db_username -p db_name > db_backup.sql

Instead of:

/usr/local/mysql5/bin/mysqldump -u db_username -p db_name > db_backup.sql

I was ask for the db password and nothing happened after. The process just didn't react and I had to kill it. Could this have damaged my database?

已采纳解答

原帖链接 · Martin · CC BY-SA 4.0

The mysql command is an interactive shell, in which you can execute SQL-Queries (like SELECT * FROM accounts; ). Without shell redirection, it will print out a prompt (after entering the password), which indicates that you can enter a command now. This command is being read from stdin; without a quit command (or <Ctrl> + <D> to indicate EOF) this command obviously waits for input.

Without any input, the database is unaltered, and therefore no harm is being done to the database (you only killed a client to access the database, not the database server process!)

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2021-02-01)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。