Reputation: 163
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?
Upvotes: 1
Views: 2575
Reputation: 1791
Before introducing the application dump to your database.
SELECT User, Host, Password FROM mysql.user;
GRANT ALL PRIVILEGES ON . TO 'root'@'localhost' WITH GRANT OPTION
Upvotes: 0
Reputation: 53734
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
Upvotes: 1