MariaDB under Linux starts with the root user (recommended)

MariaDB under Linux starts with the root user (recommended)

Recently, due to the need to test security products, I wanted to adjust the startup user of mariadb to root. After some twists and turns, I finally succeeded!

Note: Starting MySQL as root is a very dangerous behavior, which is equivalent to giving the database operation user (database administrator or hacker) a channel to directly operate the system through MySQL!

In fact, the official does not allow root boot, so in the normal boot mode, root boot will return a startup failure and prompt in /var/log/mariadb/mariadb.log

Please consult the Knowledge Base to find out how to run mysqld as root!

Ok, let's get to the point, about how to start Mariadb:

Most people will do this: systemctl start mariadb

However, this instruction actually calls mariadb.service (use find to find the specific directory) to start mariadb.

Modify the mariadb.service configuration as follows:

# vi `find /usr -name 'mariadb.service' `

[Unit]

slightly

[Service]

Type=simple

User=mysql is changed to User=root here || the startup user of the service

Group=mysql is changed to Group=root || startup group of the service

#Script to initialize mysql library files. If the mysql directory is not empty, it will prompt "Database Mariadb is probably initialized in /var/lib/mysql already, nothing is done". If you see this message when troubleshooting, you can ignore it.

ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n

#Execute the mysqld execution script and do a security check. This file restricts root startup

ExecStart=/usr/bin/mysqld_safe --basedir=/usr Add the parameter --user=root here

The following is omitted. . .

#systemctl demon-reload
#systemctl restart mariadb

PS: The same operation method supports starting MySQL with other users.

BUT The permissions or ownership of the two directories /var/lib/mysql /var/log/mariadb need to be adjusted.

Summarize

The above is the editor's introduction to the way to start mariadb under Linux using the root user. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • MariaDB database installation problems and solutions under Linux (binary version installation)
  • MariaDB 10 automated installation and deployment on Linux servers
  • How to Reset MySQL or MariaDB Root Password in Linux
  • Basic operation tutorial for migrating database from MySQL to MariaDB under Linux
  • Detailed example of installing MariaDB database on Linux

<<:  How to extend Vue Router links in Vue 3

>>:  Vue mobile terminal determines the direction of finger sliding on the screen

Recommend

How to configure /var/log/messages in Ubuntu system log

1. Problem Description Today I need to check the ...

Example code for converting http to https using nginx

I am writing a small program recently. Because th...

Detailed steps and problem solving methods for installing MySQL 8.0.19 on Linux

I recently bought a Tencent Cloud server and buil...

Sample code for installing ElasticSearch and Kibana under Docker

1. Introduction Elasticsearch is very popular now...

Detailed description of the use of advanced configuration of Firewalld in Linux

IP masquerading and port forwarding Firewalld sup...

Detailed explanation of hosts file configuration on Linux server

Linux server hosts file configuration The hosts f...

Implementation of Vue top tags browsing history

Table of contents nonsense Functions implemented ...

MySQL MyISAM default storage engine implementation principle

By default, the MyISAM table will generate three ...

How to use Vue3 to achieve a magnifying glass effect example

Table of contents Preface 1. The significance of ...

Detailed explanation of the use of $emit in Vue.js

1. Parent components can use props to pass data t...

How to reset the initial value of the auto-increment column in the MySQL table

How to reset the initial value of the auto-increm...

Pure CSS3 to achieve mouse over button animation Part 2

After the previous two chapters, do you have a ne...

Refs and Ref Details in Vue3

The editor also shares with you the corresponding...

Detailed example of using the distinct method in MySQL

A distinct Meaning: distinct is used to query the...