HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlModerate

Which are the minimum privileges required to get a backup of a MySQL database schema?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
theprivilegesareminimumdatabaseschemamysqlgetwhichrequired

Problem

Which are the minimum privileges required to get a backup of a MySQL database schema? I am interested only on the schema, not on the data.

Are SELECT privileges required?

Solution

According to the MySQL Documentation


mysqldump requires at least the SELECT privilege for dumped tables, SHOW VIEW for dumped views, TRIGGER for dumped triggers, and LOCK TABLES if the --single-transaction option is not used. Certain options might require other privileges as noted in the option descriptions.

Thus, to run

mysqldump --no-data --routines --triggers ...


the privileges required are

  • SELECT



  • SHOW VIEW (If any database has Views)



  • TRIGGER (If any table has one or more triggers)



  • LOCK TABLES (If you use an explicit --lock-tables)



You will also need the SELECT privilege on mysql.proc in order to dump Stored Procedures.

Code Snippets

mysqldump --no-data --routines --triggers ...

Context

StackExchange Database Administrators Q#55546, answer score: 16

Revisions (0)

No revisions yet.