Professional Documents
Culture Documents
Index
4. Checks ................................................................................................................... 5
1. First steps
First, we need to select the user and root for Debian; in my case, I have chosen:
Look for "Settings" in the applications menu, then "Keyboard Shortcuts" and "Add
new": Name: Command Console Command: gnome-terminal Shortcut: Ctrl + Alt + t
The next step would be to update the repositories using the command:
To grant sudo access to a user, you can add them to the sudoers group. This is defined
in /etc/sudoers. Although there is also a command to do it directly without editing the
file.
To display the available repositories for MariaDB, use: apt search mariadb
1. Mariadb: This program launches the MySQL server. It is the DBMS (Database
Management System) software. It receives client queries and executes them,
returning the appropriate results.
2. Mysql: This process is the client application. Queries to be sent to the DBMS are
written in the client.
3. Mysql_safe: This script starts the database manager (mysqld). If the MySQL
server fails, mysql_safe restarts it.
It is advisable, therefore, to ensure that all potential issues are addressed. For this
purpose, MySQL, and alternatively MariaDB, includes a script written in Perl that takes
care of this: mysql_secure_installation.
1. Enter the password for the MariaDB root. By default, it is empty, so we press
enter.
13/11/2023 Installation and Configuration of MariaDB Enrique Martínez
3. It then asks us to change the MariaDB root password. We say yes and set the
new password: rootmariadb.
To delete folders:
3. Select the Mirror location from where we will download the files.
4. In the text box below, it displays the commands to execute for the download.
5. You can use copy-paste directly into the console you are working with on
Debian.
4. Checks
We can establish a connection to MariaDB using: mariadb -u root -p
5. Connecting to MariaDB
To connect locally, use the command: mariadb -u username -p (-u indicates the
username, and -p is for the password).
If the installation is done correctly, it shouldn't allow entry without the MariaDB
password.
User information is stored in the 'user' table of the 'mysql' database. You can check
them with:
You can verify that when you connect with a new user, not all databases appear as they
do when logging in with the DBMS root.
And restart the machine. Now we can install the client using:
On the server, create a user with which to connect, setting the host to '%'. After
creating it, execute FLUSH PRIVILEGES to reload the privileges.
6. MariaDB Logs
The most important log files in MySQL are as follows:
Error log: records abnormal events that occur between the server and the
database, issues during server startup, execution, or shutdown.
13/11/2023 Installation and Configuration of MariaDB Enrique Martínez
General query log: logs connections with clients and the queries requested by
each one. It's a log that grows rapidly.
Slow query log: records queries that exceed the estimated execution time.
1. The first thing we need to do is specify the path where the log file will be
stored. Initially, if we access MariaDB, we can check that the 'log_error' variable does
not yet have a defined value.
3. You can write these errors to a directory for MariaDB, for example:
/var/log/mariadb/error.log. Remember to create the directory.
13/11/2023 Installation and Configuration of MariaDB Enrique Martínez
Now let's provoke an error that will be reflected in the log file we just created. Using
the ss command, display UDP and TCP connections along with the process ID. Check
which port MariaDB is listening on (3306).
Restart mariaDB.
13/11/2023 Installation and Configuration of MariaDB Enrique Martínez
To continue, change the port back (delete the line from the 50-server.cnf file) and
restart MariaDB..
Edit the 50-server.cnf file to configure both variables. Remove the pound sign. Leave
the default path and restart MariaDB. Every Data Control Language (DCL) operation will
be stored in the general_log_file
13/11/2023 Installation and Configuration of MariaDB Enrique Martínez
"slow_query_log_file": Specifies the path where the log file will be stored.
In the log, information about queries taking more than 10 seconds to execute (as per
the configured time) will be recorded; the others will not.
13/11/2023 Installation and Configuration of MariaDB Enrique Martínez
Restart Apache to load the new configuration with systemctl restart apache2, and
finally, execute:
Change the ownership of this directory to the web server user to enable writing to it:
Before proceeding with this step, it's necessary to restart the computer. The browser
may not display any messages. In any case, continue with the procedure.
Now you can check if it works by accessing localhost or 127.0.0.1. If you encounter any
errors, run the mysql_secure_installation script and set a password for the root user of
the database.