I wanted to run mysqld
as the root user.
I'm running Ubuntu 21.04 and have installed mysql-server
.
MySQL version:
mysql Ver 8.0.25-0ubuntu0.21.04.1 for Linux on x86_64 ((Ubuntu))
Changing the file ownership to root
chown -R root /var/lib/mysql
/etc/mysql/mysql.conf.d/mysqld.cnf
[mysqld]
user = root
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
datadir = /var/lib/mysql
When I start the MySQL service via:
sudo service mysql start
I am getting an error:
mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2021-05-25 08:29:56 PDT; 23s ago
Process: 2413 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Process: 2421 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Main PID: 2421 (code=exited, status=1/FAILURE)
Status: "Server startup in progress"
Error: 13 (Permission denied)
However, if I change the file permissions of /var/lib/mysql back to the mysql user, the service starts.
Please let me know the solution for how I can run this as root.
If I am doing anything wrong please suggest clear steps.
Ref: [1]: https://dev.mysql.com/doc/refman/8.0/en/changing-mysql-user.html