1

I have an application that stores its data in an MySQL database. The application is using a specific DB account with full access, the indivdual user rights are maintained on application level. Apart from root there is no other user with access to that database.

In order to install the application on a computer I need an sql script that creates the database, the application user, all tables without data, views, triggers, stored procedures, etc.

mysqldump --no-data --routines --add-drop-database --databases dbname > sqlfile will do almost all these things but I could not find any option to include the creation of the user having access to that database. Any hints?

2 Answers 2

1

The reason that mysqldump doesn't dump user information is because that is stored in a different database name mysql rather than in the database for your applicaation.

You cannot add this information manually to the generated sql dump either. You have two options. Create a shell script or create a separate sql file that contains user creation information. In either case your file will include statements like

GRANT ALL ON appdb.* TO 'pb_skat'@'localhost';

http://dev.mysql.com/doc/refman/5.7/en/grant.html

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you e4c5. That was my concern so I will go with two scripts to be called by the installation script: database structure and user. (And retrospectively I am glad I decided to keep authorization on app level and not in the database...)
Sorry, I was - and still am - in a hurry as I am late with the project, so I forgot. Anyway, apart from all buttons on this form (I hope I pushed all required) I still think that a personal thank you to someone who took the time to help is the most important thing. So again e4c5: thank you very much!
All the best wtih your project
0

Before introducing the application dump to your database.

  1. First list down the users which all are available with you:

SELECT User, Host, Password FROM mysql.user;

  1. Check if that user has permissions using "show grants" command to perform the operation, else provide the permissions to do so.

GRANT ALL PRIVILEGES ON . TO 'root'@'localhost' WITH GRANT OPTION

  1. Create the database name where you want to introduce the dump.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.