I am using a script to take a backup of all my databases in the Mysql.
Script is :
#!/bin/bash
cd /root/Desktop/backup
echo “You are In Backup Directory”
Now=$(date +%d-%m-%Y--%H:%M:%S)
File=$Now.sql
mysqldump –u root --all-databases > $File
echo “Your Database Backup Successfully Completed”
But when im trying to restore the database its giving me the following error and also there is no back at all just a file is created:
SQL query:
Usage: mysqldump [OPTIONS] database [tables]
OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
OR mysqldump [OPTIONS] --all-databases [OPTIONS]
For more options, use mysqldump --help
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Usage: mysqldump [OPTIONS] database [tables] OR mysqldump [OPTIONS] --databa' at line 1
Please help.
Finally i got it, i need to define password in my.cnf
so it automatically used or i have to define it in the command i am executing in the script mysqldump -u root -p 'password' --all-databases > $File.
Thanks for your efforts guys.
如果分隔符使用不正确或带有任何参数的关键字,则会出现1064错误,请检查备份文件并尝试在sqlyog中运行该sql命令,您可以找出错误所在
#!/bin/bash
cd /root/Desktop/backup
echo "You are In Backup Directory"
Now=$(date +%d-%m-%Y--%H:%M:%S)
File=$Now.sql
mysqldump -uroot -p --all-databases > $File
echo "Your Database Backup Successfully Completed"
You were getting the issue because of "-" it was some other character in your script in mysqldump statement.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.