Added the quick-doc: Installing MySQL/MariaDB #157
9 changed files with 234 additions and 0 deletions
|
@ -49,6 +49,7 @@
|
|||
** xref:using-aide.adoc[Checking file integrity with AIDE]
|
||||
** xref:getting-started-with-apache-http-server.adoc[Getting started with Apache HTTP Server]
|
||||
** xref:how-to-edit-iptables-rules.adoc[How to edit iptables rules]
|
||||
** xref:installing-mysql-mariadb.adoc[Installing MySQL/MariaDB]
|
||||
|
||||
|
||||
* xref:getting-started-with-selinux.adoc[SELinux]
|
||||
|
|
18
modules/ROOT/pages/_partials/proc_configuring-mariadb.adoc
Normal file
18
modules/ROOT/pages/_partials/proc_configuring-mariadb.adoc
Normal file
|
@ -0,0 +1,18 @@
|
|||
[discrete]
|
||||
= Configuring MariaDB
|
||||
|
||||
Enable the service at boot and start it right now
|
||||
|
||||
----
|
||||
$ sudo systemctl enable mariadb --now
|
||||
----
|
||||
|
||||
MariaDB default root password is empty.
|
||||
|
||||
Perform the initial setup
|
||||
|
||||
----
|
||||
$ sudo mysql_secure_installation
|
||||
----
|
||||
|
||||
Some questions will be asked: answer to them as you prefer; answering _yes_ to all of them is perfectly fine.
|
|
@ -0,0 +1,48 @@
|
|||
= Allow or prevent access from the network to the database server
|
||||
== Allow access to the database from the network
|
||||
To allow remote connections, you need to open the port 3306 on the firewall.
|
||||
|
||||
----
|
||||
$ sudo firewall-cmd --add-service=mysql --permanent
|
||||
$ sudo firewall-cmd --reload
|
||||
----
|
||||
|
||||
In addition you have to grant rights to the user you want to use to connect to the database.
|
||||
|
||||
From the mysql shell, for example, grant all the privileges on the database _test_ to _my_user_ user connecting from the host _192.168.1.1_ using the password _PaSsWoRd_:
|
||||
|
||||
----
|
||||
mysql> GRANT ALL PRIVILEGES ON test.* TO 'my_user'@'192.168.1.1' IDENTIFIED BY 'PaSsWoRd';
|
||||
----
|
||||
|
||||
== Limit the access to the database only from localhost
|
||||
|
||||
On the other hand, if you want to avoid to expose the database service on the network, edit the configuration file
|
||||
|
||||
* `/etc/my.cnf.d/mariadb-server.cnf` for MariaDB
|
||||
* `/etc/my.cnf.d/community-mysql-server.cnf` for MySQL
|
||||
* `/etc/my.cnf` for MySQL installed from the third party repository
|
||||
|
||||
and add/uncomment/modify this option in the `[mysqld]` section
|
||||
|
||||
----
|
||||
bind-address=127.0.0.1
|
||||
----
|
||||
|
||||
Restart the service (use `mysqld` in place of `mariadb` if it is the case)
|
||||
|
||||
----
|
||||
$ sudo systemctl restart mariadb
|
||||
----
|
||||
|
||||
Verify that the service is listening only on localhost (127.0.0.1). The output of this command:
|
||||
|
||||
----
|
||||
$ ss -ntl |grep 3306
|
||||
----
|
||||
|
||||
should look like:
|
||||
|
||||
----
|
||||
LISTEN 0 80 127.0.0.1:3306 0.0.0.0:*
|
||||
----
|
23
modules/ROOT/pages/_partials/proc_configuring-mysql.adoc
Normal file
23
modules/ROOT/pages/_partials/proc_configuring-mysql.adoc
Normal file
|
@ -0,0 +1,23 @@
|
|||
= Configuring MySQL
|
||||
|
||||
Enable the service at boot and start it right now
|
||||
|
||||
----
|
||||
$ sudo systemctl enable mysqld --now
|
||||
----
|
||||
|
||||
If you installed the package from the Fedora repository, the default root password is empty.
|
||||
|
||||
The package installed from the third party MySQL repository, generates instead a temporary root password. So you have to look which is this temporary password generated during the first startup in order to run the `mysql_secure_installation` script and to be able to set a custom root password.
|
||||
|
||||
----
|
||||
$ sudo grep 'A temporary password is generated' /var/log/mysql/mysqld.log
|
||||
----
|
||||
|
||||
Perform the initial setup:
|
||||
|
||||
----
|
||||
$ sudo mysql_secure_installation
|
||||
----
|
||||
|
||||
Some questions will be asked: answer to them as you prefer; answering _yes_ to all of them is perfectly fine.
|
|
@ -0,0 +1,39 @@
|
|||
= Installing MariaDB server from the Fedora Modular repository
|
||||
|
||||
To list the available versions (_streams_ in modularity terminology) of MariaDB:
|
||||
|
||||
----
|
||||
$ dnf module list mariadb
|
||||
----
|
||||
|
||||
To enable the version of MariaDB you want to use and make the stream RPMs available in the package set:
|
||||
|
||||
----
|
||||
$ sudo dnf module enable mariadb:10.4
|
||||
----
|
||||
|
||||
At this point you can verify that the available RPM provides the 10.4 verison of MariaDB server:
|
||||
|
||||
----
|
||||
$ dnf list mariadb-server
|
||||
----
|
||||
|
||||
To install mariadb server:
|
||||
|
||||
----
|
||||
$ sudo dnf module install mariadb/server
|
||||
----
|
||||
|
||||
or simply, as usual:
|
||||
|
||||
----
|
||||
$ sudo dnf install mariadb-server
|
||||
----
|
||||
|
||||
With modules, you could also install a specific profile: like client, devel or galera (the multi-master replica).
|
||||
|
||||
For instance, if you don't want to install the server stuff, but only the client packages:
|
||||
|
||||
----
|
||||
$ sudo dnf module install mariadb:10.4/client
|
||||
----
|
|
@ -0,0 +1,7 @@
|
|||
= Installing MariaDB
|
||||
|
||||
To install the MariaDB version included in the Fedora repository:
|
||||
|
||||
----
|
||||
$ sudo dnf install mariadb-server
|
||||
----
|
22
modules/ROOT/pages/_partials/proc_installing-mysql.adoc
Normal file
22
modules/ROOT/pages/_partials/proc_installing-mysql.adoc
Normal file
|
@ -0,0 +1,22 @@
|
|||
= Installing MySQL
|
||||
== From the Fedora repository
|
||||
|
||||
In order to install MySQL Community Edition from the Fedora repository:
|
||||
|
||||
----
|
||||
$ sudo dnf install community-mysql-server
|
||||
----
|
||||
|
||||
== From the MySQL repository
|
||||
|
||||
include::{partialsdir}/3rdparty-message.adoc[]
|
||||
|
||||
If you prefer to install the package from the third party repository maintained by MySQL (substitute the Fedora release accordingly):
|
||||
|
||||
----
|
||||
$ sudo dnf install https://repo.mysql.com//mysql80-community-release-fc31-1.noarch.rpm
|
||||
----
|
||||
|
||||
----
|
||||
$ sudo dnf install mysql-community-server
|
||||
----
|
41
modules/ROOT/pages/_partials/proc_using-mysql-mariadb.adoc
Normal file
41
modules/ROOT/pages/_partials/proc_using-mysql-mariadb.adoc
Normal file
|
@ -0,0 +1,41 @@
|
|||
= Using the RDBMS
|
||||
|
||||
Connect to the MySQL/MariaDB shell using the `mysql` command.
|
||||
|
||||
For both of them, the command is `mysql`. The syntax an the options are generally the same.
|
||||
|
||||
----
|
||||
$ mysql -u root -p
|
||||
----
|
||||
|
||||
Once gained access to the shell you can get the running version of the software:
|
||||
|
||||
----
|
||||
mysql> SELECT version();
|
||||
----
|
||||
|
||||
You can create a database:
|
||||
|
||||
----
|
||||
mysql> create schema test;
|
||||
----
|
||||
|
||||
Create a user:
|
||||
|
||||
----
|
||||
mysql> GRANT ALL PRIVILEGES ON test.* TO 'my_user'@'localhost' IDENTIFIED BY 'PaSsWoRd';
|
||||
----
|
||||
|
||||
List the available databases:
|
||||
|
||||
----
|
||||
mysql> show schemas;
|
||||
----
|
||||
|
||||
== Files location
|
||||
|
||||
For both of them, the main configuration file is `/etc/my.cnf`; eventually the configuration can be splitted in many files inside the include directory `/etc/my.cnf.d`.
|
||||
|
||||
Log files can be located in `/var/log/mysql` for MySQL, and `/var/log/mariabd` for MariaDB.
|
||||
|
||||
The database disk storage is located in `/var/lib/mysql`.
|
35
modules/ROOT/pages/installing-mysql-mariadb.adoc
Normal file
35
modules/ROOT/pages/installing-mysql-mariadb.adoc
Normal file
|
@ -0,0 +1,35 @@
|
|||
ifdef::context[:parent-context: {context}]
|
||||
:context: assembly_installing-mysql-mariadb
|
||||
= Installing MySQL/MariaDB
|
||||
|
||||
MySQL is a popular RDBMS (Relational Database Management System). MariaDB was born as a fork of MySQL.
|
||||
Nowadays the two products are a little bit different. Migrating data from one system to the other could not be a trivial task.
|
||||
|
||||
MariaDB is fully GPLv2 licensed while MySQL has two licensing options, GPLv2 (for the Community edition) and Enterprise.
|
||||
|
||||
In the Fedora repositories you can find:
|
||||
|
||||
* MariaDB 10.3 (as a regular package or as a module)
|
||||
* MariaDB 10.4 (as a module)
|
||||
* MySQL 8.0 community edition (as a regular package or as a module)
|
||||
|
||||
NOTE: MariaDB and MySQL packages conflict each other. You have to install MariaDB or MySQL.
|
||||
|
||||
In addition you can install MySQL commmunity edition (8.0 or 5.7) from the repository maintained by MySQL itself: https://dev.mysql.com/downloads/repo/yum/
|
||||
|
||||
include::{partialsdir}/proc_installing-mysql.adoc[leveloffset=+1]
|
||||
|
||||
include::{partialsdir}/proc_configuring-mysql.adoc[leveloffset=+1]
|
||||
|
||||
include::{partialsdir}/proc_installing-mariadb.adoc[leveloffset=+1]
|
||||
|
||||
include::{partialsdir}/proc_installing-mariadb-module.adoc[leveloffset=+1]
|
||||
|
||||
include::{partialsdir}/proc_configuring-mariadb.adoc[leveloffset=+1]
|
||||
|
||||
include::{partialsdir}/proc_using-mysql-mariadb.adoc[leveloffset=+1]
|
||||
|
||||
include::{partialsdir}/proc_configuring-mysql-mariadb-firewall.adoc[leveloffset=+1]
|
||||
|
||||
ifdef::parent-context[:context: {parent-context}]
|
||||
ifndef::parent-context[:!context:]
|
Loading…
Add table
Add a link
Reference in a new issue