Score:0

Unable to start MySQL Server. Failed to set datadir to '/var/lib/mysql/'

kz flag

I have installed MySQL 8.0.31-1 Ubuntu 22.04 from the MySQL APT repository on a freshly installed Xubuntu 22.04. I am not able to launch MySQL Server. I got the following warnings and errors:

[Warning] [MY-010091] [Server] Can't create test file /var/lib/mysql/mysqld_tmp_file_case_insensitive_test.lower-test
[System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.31) starting as process 2169
[Warning] [MY-010091] [Server] Can't create test file /var/lib/mysql/mysqld_tmp_file_case_insensitive_test.lower-test
[Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
[ERROR] [MY-013276] [Server] Failed to set datadir to '/var/lib/mysql/' (OS errno: 13 - Permission denied)
[ERROR] [MY-010119] [Server] Aborting
[System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.31)  MySQL Community Server - GPL.

Permissions for /var/lib/mysql/ is drwx------ 7 mysql mysql

I tried setting the datadir to /usr/local/mysql. I thought I had set the permissions to the same as above. When I ran mysqld --initialize --user=mysql in a poor attempt to initialize this as the data directory, and I got the following:

[System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.31) initializing of server in progress as process 5588
[ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
[ERROR] [MY-010119] [Server] Aborting
[System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.31)  MySQL Community Server - GPL.

Am I dealing with a permissions problem? Also, if the datadir is supposed to be /var/lib/mysql/, where should that be set? Should that be set in /etc/mysql/conf.d/mysql.cnf? I have run MySQL under Windows 10, and I have used Linux. However, this is my first attempt at using the two together.

Update: I did find datadir = /var/lib/mysql and it is located in /etc/mysql/mysql.conf.d/mysqld.cnf. So that looks right. But I am still unsure where the problem is.

Resolution: I was never able to find the problem. Since my system was not 100% configured yet, I simply wiped the drive, installed a fresh system, and then installed MariaDB. I probably should have done that to begin with.

in flag
The `13 - Permission denied` is pointing to either a directory with different permissions or a directory that does not exist. Can you verify the existence and permissions for your `/var/lib/mysql` directory?
inkblot avatar
kz flag
Yes, it exists. Permissions for `/var/lib/mysql/` is `drwx------ 7 mysql mysql`.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.