mariadb under Linux uses root user boot mode of recommendation
- 2021-07-09 09:49:41
- OfStack
Recently, due to the need of testing security products, I want to adjust the startup user of mariadb to root, and finally succeed after one twists and turns!
Note: Starting mysql as root is a very dangerous behavior, which is equivalent to giving database operators (database administrators or hackers) a channel to directly operate the system through mysql!
Actually, root is not allowed to start officially, so root will return startup failure under 1 startup mode, and prompt in/var/log/mariadb/mariadb. log
Please consult the Knowledge Base to find out how to run mysqld as root!
Ok, to get down to business, about the startup mode of Mariadb:
1 people will operate:
systemctl start mariadb
However, this instruction actually calls mariadb. service (find the specific directory with find) and starts mariadb.
mariadb. service modify the configuration as follows:
# vi `find /usr -name 'mariadb.service' `
[Unit]
Slightly
[Service]
Type=simple
User=mysql is modified here as the startup user of User=root service
Group=mysql is modified here as the startup group of Group=root service
# Initialize the script of the mysql library file. 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 content during debugging, you can ignore it
ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n
# Execute mysqld execution script, do security check, it is this file to limit root startup
ExecStart=/usr/bin/mysqld_safe --basedir=/usr
Add parameters here
--user=root
Omitted below. . .
#systemctl demon-reload
#systemctl restart mariadb
PS: The same operation mode supports mysql to be started by other users,
BUT
/var/lib/mysql /var/log/mariadb
The permissions or owners of these two directories need to be adjusted.
Summarize