mysqldump不保存不同目录中的输出文件

时间:2021-01-29 22:44:00

mysqldump is running fine in our server; we are executing it through system command. e.g -

mysqldump在我们的服务器上正常运行;我们正在通过系统命令执行它。例如 -

exec('mysqldump -h hostname -u userName -ppassword database_name > dump.sql');

exec('mysqldump -h hostname -u userName -ppassword database_name> dump.sql');

but when I want to make the dump file save in a different directory, like –

但是当我想将转储文件保存在不同的目录中时,如 -

exec('mysqldump -h hostname -u userName -ppassword database_name > /backup/dump.sql');

exec('mysqldump -h hostname -u userName -ppassword database_name> /backup/dump.sql');

I also have tried with full path, but the command fails to execute. How should I solve this?

我也尝试过完整路径,但命令无法执行。我该怎么解决这个问题?

Edited: it was a permission issue, I solved it using changing permission to 700. Thanks to @DBK.

编辑:这是一个权限问题,我使用更改权限解决了700.感谢@DBK。

1 个解决方案

#1


0  

try the manual path for creating the dump- use the following command go to cd/var/lib/mysql

尝试手动路径创建转储 - 使用以下命令转到cd / var / lib / mysql

search for the database whose dump you want.

搜索您想要转储的数据库。

ls -l | grep database_name

ls -l | grep database_name

mysqldump database_name > database.sql

mysqldump database_name> database.sql

//if you want to restore the backup

//如果要还原备份

cd /var/lib/mysql

check the database name where you want to restore the mysqldump ls -l | grep database_name

检查要恢复mysqldump ls -l |的数据库名称grep database_name

mysql database_name < database.sql

mysql database_name

#1


0  

try the manual path for creating the dump- use the following command go to cd/var/lib/mysql

尝试手动路径创建转储 - 使用以下命令转到cd / var / lib / mysql

search for the database whose dump you want.

搜索您想要转储的数据库。

ls -l | grep database_name

ls -l | grep database_name

mysqldump database_name > database.sql

mysqldump database_name> database.sql

//if you want to restore the backup

//如果要还原备份

cd /var/lib/mysql

check the database name where you want to restore the mysqldump ls -l | grep database_name

检查要恢复mysqldump ls -l |的数据库名称grep database_name

mysql database_name < database.sql

mysql database_name