How can I create a database from a SQL backup file?
To create a database from a SQL backup file, follow these instructions:
First, create the database.
/path/to/bin/mysqladmin -u $mysqlusername -p$mysqlpassword create $mysqldatabasename
Then, add user permission to it.
/path/to/bin/mysqladmin -u usernamehere -ppasshere create databasename
Finally, add the tables back:
/path/to/bin/mysql -u $mysqlusername -p$mysqlpassword $mysqldatabasename < backup.sql
OR:
mysql -u user -p -e ‘source backup_file’ database
Related links:
Related Links: