Hello i have 10 databases each database have 3 table with same name users
I'm trying to dump each database to a separated folder by name of database include in that directory all my tables dumped.
So i started with this sample code.
mysql -uroot -p -e 'show databases' | while read dbname; do mysqldump -uroot -p -T/backup/$dbname/ --fields-terminated-by="|" "$dbname" > "$dbname".txt; done
Then i get this error.
mysqldump: Can't create/write to file '/home/database/users.sql' (Errcode: 2 - No such file or directory)
I dont have much skills with bash scripting Please help me!!
My second Script
#!/bin/bash
echo "MySQL backup"
mysql -u root -pPwd -e "show databases" \
| grep -Ev 'Database|information_schema' \
| while read dbname;
do
echo "Dumping $dbname"
mysqldump -u root -pPwd --fields-terminated-by="|" $dbname > /var/lib/mysql-files/$dbname/ > "$dbname".txt; done
done