No edit summary |
m (Add link to the Fedora Developer Portal) |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
MariaDB is a drop-in replacement of MySQL, forked by the community from the latter. | |||
MariaDB is a | |||
NOTE: you can find simmilar information (as in this document) on the Fedora Developer Portal: https://developer.fedoraproject.org/tech/database/mariadb/about.html | |||
== Installation == | == Installation == | ||
<pre>$ su root | <pre>$ su - root | ||
$ | $ dnf install mariadb mariadb-server</pre> | ||
== Initial setup == | == Initial setup == | ||
Line 19: | Line 20: | ||
Then it is advisable to answer as follows | Then it is advisable to answer as follows | ||
<pre>Set root password? [Y/n] Y</pre> | <pre>Set root password? [Y/n] Y</pre> | ||
{{admon/warning | Do not use root account password | Do not provide the system administrator's password for your Linux system here. Use a different strong password, since this is a separate authentication for a MySQL user called "root."}} | {{admon/warning | Do not use system's root account password | Do not provide the system administrator's password for your Linux system here. Use a different strong password, since this is a separate authentication for a MySQL user called "root."}} | ||
<pre>Remove anonymous users? [Y/n] | <pre>Set root password? [Y/n] y | ||
Disallow root login remotely? [Y/n] | Remove anonymous users? [Y/n] y | ||
Remove test database and access to it? [Y/n] | Disallow root login remotely? [Y/n] y | ||
Reload privilege tables now? [Y/n] | Remove test database and access to it? [Y/n] y | ||
Reload privilege tables now? [Y/n] y</pre> | |||
To start MariaDB on boot | To start MariaDB on boot | ||
Line 37: | Line 39: | ||
The configuration files are stored in the <code>/etc/my.cnf.d/</code> directory and the main configuration file is <code>/etc/my.cnf</code> | The configuration files are stored in the <code>/etc/my.cnf.d/</code> directory and the main configuration file is <code>/etc/my.cnf</code> | ||
The default log file is <code>/var/log/ | The default log file is <code>/var/log/mariadb/mariadb.log</code> | ||
The default installation directory is <code>/var/lib/mysql</code> | The default installation directory is <code>/var/lib/mysql</code> | ||
The default PID file is <code>/var/run/mariadb/mariadb.pid</code> | |||
The default unix socket file is <code>/var/lib/mysql/mysql.sock</code> | |||
== Firewall == | |||
MariaDB operates on port 3306 (or whatever else you set in your <code>my.cnf</code>). In firewalld you can open it like this: | |||
$ # make it last after reboot | |||
$ firewall-cmd --permanent --add-port=3306/tcp | |||
$ # change runtime configuration | |||
$ firewall-cmd --add-port=3306/tcp | |||
In case of iptables: | |||
$ iptables -A INPUT -p tcp --dport 3306 -m state --state NEW,ESTABLISHED -j ACCEPT | |||
Bear in mind that you probably don't want to open your database server to the whole world. | |||
== User Creation and Database Creation == | |||
Soon you run into need of creating a user (and database for the user). By default, root user has no password, unless you set it before, e.g. using mysql_secure_installation: | |||
$ mysql -uroot -p | |||
This will run the mysql interactive shell under root user, so we can create a database and a user that will have access to this database: | |||
<pre> | |||
$ mysql -uroot -p | |||
Enter password: | |||
Welcome to the MariaDB monitor. Commands end with ; or \g. | |||
Your MariaDB connection id is 13 | |||
Server version: 10.1.16-MariaDB MariaDB Server | |||
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. | |||
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. | |||
MariaDB [(none)]> CREATE DATABASE mydb; | |||
Query OK, 1 row affected (0.00 sec) | |||
MariaDB [(none)]> CREATE USER 'john'@'localhost' IDENTIFIED BY 'abcdefgh'; | |||
Query OK, 0 rows affected (0.00 sec) | |||
MariaDB [(none)]> GRANT ALL ON mydb.* TO 'john'@'localhost'; | |||
Query OK, 0 rows affected (0.00 sec) | |||
MariaDB [(none)]> exit | |||
Bye | |||
</pre> | |||
Now we can verify that the user has access to the database by creating some table and fill it with some data: | |||
<pre> | |||
$ mysql -ujohn -p | |||
Enter password: | |||
Welcome to the MariaDB monitor. Commands end with ; or \g. | |||
Your MariaDB connection id is 16 | |||
Server version: 10.1.16-MariaDB MariaDB Server | |||
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. | |||
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. | |||
MariaDB [(none)]> CREATE TABLE mydb.t1 (numb int); | |||
Query OK, 0 rows affected (0.09 sec) | |||
MariaDB [(none)]> INSERT INTO mydb.t1 VALUES (1), (2); | |||
Query OK, 2 rows affected (0.02 sec) | |||
Records: 2 Duplicates: 0 Warnings: 0 | |||
</pre> | |||
[[Category:Package MariaDB]] | |||
[[Category:Packages]] |
Latest revision as of 16:21, 19 February 2020
MariaDB is a drop-in replacement of MySQL, forked by the community from the latter.
NOTE: you can find simmilar information (as in this document) on the Fedora Developer Portal: https://developer.fedoraproject.org/tech/database/mariadb/about.html
Installation
$ su - root $ dnf install mariadb mariadb-server
Initial setup
First let's start MariaDB
$ systemctl start mariadb
Now start the secure installation assistant
$ mysql_secure_installation
Press enter if you didn't have setup a password previously
Then it is advisable to answer as follows
Set root password? [Y/n] Y
Set root password? [Y/n] y Remove anonymous users? [Y/n] y Disallow root login remotely? [Y/n] y Remove test database and access to it? [Y/n] y Reload privilege tables now? [Y/n] y
To start MariaDB on boot
$ systemctl enable mariadb
GUI frontends
There are some popular frontends such as phpMyAdmin
Default installation and configuration files
The configuration files are stored in the /etc/my.cnf.d/
directory and the main configuration file is /etc/my.cnf
The default log file is /var/log/mariadb/mariadb.log
The default installation directory is /var/lib/mysql
The default PID file is /var/run/mariadb/mariadb.pid
The default unix socket file is /var/lib/mysql/mysql.sock
Firewall
MariaDB operates on port 3306 (or whatever else you set in your my.cnf
). In firewalld you can open it like this:
$ # make it last after reboot $ firewall-cmd --permanent --add-port=3306/tcp $ # change runtime configuration $ firewall-cmd --add-port=3306/tcp
In case of iptables:
$ iptables -A INPUT -p tcp --dport 3306 -m state --state NEW,ESTABLISHED -j ACCEPT
Bear in mind that you probably don't want to open your database server to the whole world.
User Creation and Database Creation
Soon you run into need of creating a user (and database for the user). By default, root user has no password, unless you set it before, e.g. using mysql_secure_installation:
$ mysql -uroot -p
This will run the mysql interactive shell under root user, so we can create a database and a user that will have access to this database:
$ mysql -uroot -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 13 Server version: 10.1.16-MariaDB MariaDB Server Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> CREATE DATABASE mydb; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> CREATE USER 'john'@'localhost' IDENTIFIED BY 'abcdefgh'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> GRANT ALL ON mydb.* TO 'john'@'localhost'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> exit Bye
Now we can verify that the user has access to the database by creating some table and fill it with some data:
$ mysql -ujohn -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 16 Server version: 10.1.16-MariaDB MariaDB Server Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> CREATE TABLE mydb.t1 (numb int); Query OK, 0 rows affected (0.09 sec) MariaDB [(none)]> INSERT INTO mydb.t1 VALUES (1), (2); Query OK, 2 rows affected (0.02 sec) Records: 2 Duplicates: 0 Warnings: 0