MariaDB: Difference between revisions

>Samthecrazyman
Added how to add a new user.
>Samthecrazyman
m Slight changes to commands to make them work
Line 101: Line 101:
* If not logged on a root, <code>su</code>.
* If not logged on a root, <code>su</code>.
* Run <code>mysql -u root -p</code> and type your password when requested.
* Run <code>mysql -u root -p</code> and type your password when requested.
* Type the following, adapting to your needs: <pre>mysql> CREATE USER 'backup'@'localhost' IDENTIFIED BY 'password';</pre>
* Type the following, adapting to your needs: <pre>mysql> CREATE USER backup@localhost IDENTIFIED BY 'password';</pre>
** Change <code>password</code> to a password of your choice. If using for a cron job later on, keep the password to an alphanumeric one without any special characters.
** Change <code>password</code> to a password of your choice. If using for a cron job later on, keep the password to an alphanumeric one without any special characters.
* To grant it read-only privileges, run the following command:
* To grant it read-only privileges, run the following command:
<pre>mysql> GRANT SELECT, LOCK TABLES ON *.* TO 'backup'@'localhost' IDENTIFIED 'password';</pre>
<pre>mysql> GRANT SELECT, LOCK TABLES ON *.* TO backup@localhost IDENTIFIED 'password';</pre>
* To make MySQL take note of the new privileges, restart the MySQL server or run the following command:
* To make MySQL take note of the new privileges, restart the MySQL server or run the following command:
<pre>mysql> FLUSH PRIVILEGES</pre>
<pre>mysql> FLUSH PRIVILEGES;</pre>
* You can now exit the MySQL server.
* You can now exit the MySQL server.