MySQLinstallation, the process to install
Download and install the package:
rpm -Uvh https://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm
Complete installation removing a previous version and its databases
If there is a previous installation of
MySQL and you do not need this data you can do a entirely installation by
removing the current data. This action deletes all data and previous databases, use only in case you are completily sure
that the current data is no longer needed.
## [ONLY FOR EXPERTS ADMINISTRATORS] rm -rf /var/lib/mysql*
Ensure the repo is enabled and install mysql-community-server:
sed -i 's/enabled=1/enabled=0/' /etc/yum.repos.d/mysql-community.repo yum -y --enablerepo=mysql80-community install mysql-community-server
1.1 Set db and table names case insensitive
To make all database and table names case insensitive,
lower_case_table_names must be set to 1.
To do that, the following text nust be added to /etc/my.cnf or /etc/my.cnf.d/mysqld.cnf under
Set option before mysql initilization
This option must be set before iniitializing mysql for the first time.
If the option is modified afterwards, the next mysqld service start will fail.
2 Enable and start service
systemctl enable mysqld.service systemctl start mysqld.service
Now the service must be up&running:
# systemctl status mysqld.service ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2021-01-13 16:32:06 CET; 4min 6s ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 25083 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 25205 (mysqld) Status: "Server is operational" CGroup: /system.slice/mysqld.service └─25205 /usr/sbin/mysqld Jan 13 16:31:55 pmultidb systemd: Starting MySQL Server... Jan 13 16:32:06 pmultidb systemd: Started MySQL Server.
3 Set root password
A password for root user is automatically generated, you can find it in the /var/log/mysql/mysqld.log file:
grep "A temporary password" /var/log/mysql/mysqld.log
To change it execute:
To execute mysql and manage databases you can use:
mysql -u root -p
4 Allow connections on all interfaces on MariaDB
Edit file /etc/my.cnf.d/mariadb-server.cnf to accept connections on all interfaces and not only on localhost.
# # Allow server to accept connections on all interfaces. # bind-address=0.0.0.0
Restart the service:
systemctl restart mariadb.service
5 Allow remote connections (user for JDBC Connections)
Remote connections error
If remote connections are not allowed the following messages will appears when you try to connect from another server using the IP and port.
Host 'xxx.xx.xxx.xxx' is not allowed to connect to this MySQL/MariaDB server
MySQL JDBC is only able to connect via TCP/IP (on Unix, or TCP/IP or named pipe on Windows).
MySQL JDBC driver cannot establish a connection using the local unix socket.With
MySQL on Unix,
localhost has a different meaning that we might expect.
It is not a hostname synonym for the 127.0.0.1 TCP/IP loopback address.
specifies a user that can connect only via unix socket file; it's not possible to connect to that user via TCP/IP.
You can use this sentence to create user and stablish TCP/IP connections to the database server:
mysql> CREATE USER 'deister' IDENTIFIED BY 'XXio98$1234';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'deister';
This instruction creates a user "deister" with full privileges and you can use it to make JDBC connection via TCP/IP.
PermissionsThis command grants the user all permissions. However, you can grant specific permissions to maintain precise control over database access. For example, to explicitly grant the SELECT permission, you would use the following command:
GRANT SELECT ON *.* TO 'username';
6 Create database
To log in to
MySQL as the user you just created, type the following command.
Replace username with the name of the user you created in previous step.
mysql -u username -p
Type the user's password, and then press Enter.
To create a database, type the following command. Replace dbname with the name of the database that you want to create:
CREATE DATABASE dbname;
To work with the new database, type the following command. Replace dbname with the name of the database you created before:
7 Import a database
The database must be exists if not, create it before:
CREATE DATABASE dbname;
Then use this instruction to import a database from file:
mysql -u deister -p dbname < dbname.sql