Percona Toolkit

This is to help me remember how to get percona toolkit, so that I can get the grants information out of the mysql database – the database in mysql which keeps tracks of users, databases, and (in particular) grants, i.e. permissions.

I originally dug this up for use when I was migrating tarragon. But now I am working on migrating oregano from fedora to arch, and I will have to transfer the databases. I have finally learned (I admit I am slow) that one cannot expect to be able to move the database directory even from one release to another, let alone from one distribution to another. The only way to do this properly is to dump the databases, reinstall mariadb/mysql in the new place, and set it up, and then reimport the dumped databases.

Which leaves re-establishing all the permissions, the grants. I haven’t looked again recently but six months ago when I researched this, the only way I could find (maybe it is more accurate to say – the first way I found, and then I quit looking), was to use the Percona toolkit, which has a tool called pt-show-grants, which reads out the grant information from the mysql database, and displays it as a sequence of sql grant statements, which can be saved and imported back into mysql later to re-establish the grants.

There are copies of the percona toolkit for Debian, Ubuntu, RHEL and Centos. There is also a “Linux – Generic” which I used. Download the tar.gz and extract it, and then read the INSTALL, which basically builds a makefile with Perl, and then does make, make test, make install in the normal way, installing into /usr/local/bin.

Then I was able to do:

pt-show-grants > \ 
     /backup/databases/oregano/grants.txt