Categories
How Tos

Create MySQL DB user to take backup of the database

To configure DB backup using G8Keeper, you will need to have DB user that has required permission to take database backup on the database. This user does not need a lot of permissions. Generally just read only permission on the database should be sufficient. But some times you may need to be able to lock tables as well to get a consistent backup. Before we get into steps to create user, you need to ensure that the server where g8keeper-agent is running needs to have mysql client installed. So here are the steps to setup the user.

Note:You need to be comfortable with the unix (linux) command line to perform following steps.

All the commands used below can be accessed in text format here

1. Login to your server that has access to your database.

2. On the terminal, run the MySQL command-line program, and log in as an administrator by typing the following command

> mysql -u root -p -hhostname

Note: If the database is running on the localhost, then you do not need the -h option, else you need to provide url to access the DB host.

3. This will prompt you for the password, please enter password for root account.

4. Next step is to create a new user in database.

mysql> CREATE USER 'g8keeperbkp'@'localhost' IDENTIFIED BY 'g8k33p3r112';

Note: replace password by a reasonably complex password

To give the user access to the database from any host, type the following command:

mysql> grant SELECT, LOCK TABLES on database_name.* to 'g8keeperbkp'@'%' identified by 'g8k33p3r112';

Note:

  • replace “database_name” with the name of database that you want to backup. You can do this on multiple databases. You need to run this command for each database separately
  • ‘%’ is used in above command to allow access from any host. However, if you are running the command on localhost and the user will be accessing the database from same host then you can skip ‘%’ and simply use

In case there is a specific IP from where the user will access the database you can replace ‘%’ with that IP address or hostname

5. After you have given the required permission, we need to verify that the permissions have been granted. To verify the same run following command (depending on how you have created user)

mysql> show grants for 'g8keeperbkp'@'localhost';

or

mysql> show grants for 'g8keeperbkp'@'%';

It should show something like this

6. Once the permission is granted we need to just flush privileges so that the changes can take effect and we are done

mysql> flush privileges;
mysql> quit

With this we are all set.

All the commands used above can be accessed in text format here

Leave a Reply

Your email address will not be published. Required fields are marked *