I am running 10.5.12-MariaDB
and trying to take full backup of all databases including user accounts/ passwords and Grants but somehow i am not able to take backup of grants so am i missing something.
Example.
Taking full backup
old-DB # mysqldump --opt --all-databases > /root/openstack.sql
Restoring to new DB server
new-DB # mysql < openstack.sql
Now i can see all databases and all users in mysql.user
table but grants are missing for all users.
example:
old-DB # mysql -e 'show grants for glance';
+-------------------------------------------------------------------------------------------------------+
| Grants for glance@% |
+-------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `glance`@`%` IDENTIFIED BY PASSWORD '*6FE1E5E532A9189C900FB696AC9DEF84CDE2194A' |
| GRANT ALL PRIVILEGES ON `glance`.* TO `glance`@`%` |
+-------------------------------------------------------------------------------------------------------+
Its missing on new DB server
new-DB# mysql -e 'show grants for glance';
ERROR 1141 (42000) at line 1: There is no such grant defined for user 'glance' on host '%'
So i did following
old-DB# mysql --skip-column-names -A -e"SELECT CONCAT('SHOW GRANTS FOR ''',user,'''@''',host,''';') FROM mysql.user WHERE user<>''" | mysql --skip-column-names -A | sed 's/$/;/g' > MySQLUserGrants.sql
Now MySQLUserGrants.sql has all the users grants command so i just copy paste all command and paste to new-DB i got following error
MariaDB [(none)]> GRANT USAGE ON *.* TO `glance`@`%` IDENTIFIED BY PASSWORD '*6FE1E5E532A9189C900FB696AC9DEF84CDE2194A';
ERROR 1133 (28000): Can't find any matching row in the user table
Question, how do i take full mysql backup which include everything even including grants. (or am i missing something?)
FLUSH PRIVILEGES;
fixed my issue and now i can useGRANT
command without error. but still is there any good way to take backup of grant using mysqldump?