I have a SQL script that creates a MySQL database, needed tables, inserts some basic info, creates the application's MySQL user, and assigns privileges to that MySQL user on the application's database.
Now, if an installation goes awry and I need to reinstall their database, tables, etc. back to factory default, I import the same SQL script. With databases and tables, I can simply use the "IF NOT EXISTS" directive and with my INSERT statements I can simply use "IGNORE" to pass over values that are still there.
The issue I am running into is if the db specific user is still present in the MySQL users table, the script stops processing and errors out,
SO I guess my question is this: is there a way or directive similar to IF NOT EXISTS or IGNORE that I can use with CREATE USER that will check to see if a user exists before trying to create the user? In other words...to ignore recreating the user if the MySQL user already exists?
"#1396 - Operation CREATE USER failed for 'MyDBUser'@'%' "