Hi,
I have the following script to restore a backup from a dump. Syntax for executing this script might be:
./restore-db.sh 07-24-13 july24
where 07-24-13 is part of the backup.sql.gz file name and july24 is the MySQL DB to be created to hold the data
Here's the script:
What I am having problems with is GRANT permissions for the database, to get this manually-created database to show up in cPanel and/or phpMyAdmin. I don't really want to create a global MySQL root user if I don't have to for security purposes.
What are the series of GRANT queries that I need to run to make this database accessible to a user? Let me know what the best solution is.
Thanks much.
I have the following script to restore a backup from a dump. Syntax for executing this script might be:
./restore-db.sh 07-24-13 july24
where 07-24-13 is part of the backup.sql.gz file name and july24 is the MySQL DB to be created to hold the data
Here's the script:
Code:
#!/bin/sh
# Database name
FILE=/home/sitename/backups/site.$1.sql.gz
DBNAME=$2
# Does the backup source even exist?
if [ -f $FILE ];
then
echo "Backup source found."
else
echo "Backup file not found. Please try again."
exit 1
fi
# Find the backup file based on the args
echo "Creating database ${DBNAME}..."
mysql -u root -pPASS -e "create database if not exists ${DBNAME};"
# Do the restoration
echo "Restoring database..."
echo "Please wait..."
gunzip < $FILE | mysql -u root -pPASS ${DBNAME}
echo Done!
What are the series of GRANT queries that I need to run to make this database accessible to a user? Let me know what the best solution is.
Thanks much.