I’m finding myself having to restore a lot of older MySQL databases. It’s getting a bit tedious: (1) finding the DB file, (2) manually creating the database in Siteworx, (3) applying permissions, and (4) going back to command line and executing the restore command. To automate this, I’m trying to write a bash script (which I’d be happy to share here once it’s complete) that accomplishes all of these tasks.
The script will take two arguments: (1) datafile name, (2) the future database name that will hold the restored data.
Everything has been going well thus far, but I’ve ran into a bit of an issue. How does Siteworx create a new database? I’ve tried using existing MySQL users that exist in Siteworx, but it does not appear that they have CREATE DATABASE privileges. With what user does it execute a CREATE DATABASE command? How might I be able to create a new database and apply permissions via command line? I’ve tried running mysql -u root -p, but then realized that I don’t have my MySQL root password and don’t even remember ever having to configure this upon installation of Interworx.
So: how can I create a database and grant a specific MySQL user privileges from command line, in a way that matches the method Siteworx creates DBs and users? I want to make sure that these two things line up.