I'm trying to make mysql database input from a file. But the db filename will be coming from the variable filename= /file/path/name.sql. But when input using < it is showing ambiguous redirect error.
My full script is:
filename= /var/backup/mydatabase.sql
echo $filename
mysql -uxxxx -pxxxx -hxxxx databasename < $filename
And the output is:
/var/backup/mydatabase.sql
./myscript.sh: line 3: $filename: ambiguous redirect
Please note followings:
- Please assume the
filenamevariable is needed for some reason - I'm a root user
So my question here is:
- How to use
shell variablesfor file input purpose?
mysqlclient as root...