I’m using the latest, fully upgraded EndeavourOS. I have installed MySQL and replaced it with MariaDB and have failed to get either to work. I consistently get the error of:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)
Here is the output when I run mysqld --verbose:
2020-07-31 17:29:52 0 [Note] mysqld (mysqld 10.4.13-MariaDB) starting as process 11330 ...
2020-07-31 17:29:52 0 [Warning] Can't create test file /var/lib/mysql/username.lower-test
mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 13 "Permission denied")
2020-07-31 17:29:52 0 [ERROR] Aborting
Running sudo systemctl start mariadb.service, I got the following error log: https://pastebin.com/J7wFh5nR (put in a pastebin because its otherwise quite long)
I have tried various solutions from online, including from these following links:
This happens to me sometimes when a mariadb update occurs.
In my case the issue is usually within the service file itself. Check the user running the service:
Then check if that user has read/write rights to the folder/file mentioned in the error.
Also if your database files are located somewhere other than the default, check that the datadir=[database_files_path] is correctly set up in /etc/my.conf
Sometimes the file gets overwritten on updates.
If it’s set to a folder in your /home /run/user /usr /boot or /etc directory make sure to allow this by setting the ProtectHome or ProtectSystem parameters to false in the service file (/usr/lib/systemd/system/mariadb.service):
Well then, in my case it’s probably a consequence of using a symlink to a file in my home directory instead of an actual /etc/my.conf file. I like to have all my config files in one place under my home folder, so I can reuse everything on re-installs. Same with the database files.
However the mariadb.service file I can confirm it sometimes gets overwritten by updates (that one I haven’t symlinked).
That’s what I was telling myself until I noticed that there are a few settings in the service file that IMO belong into the my.cnf file. Like the two parameters I mentioned in the previous post.
Interesting. Never heard of systemctl edit before. I never stop learning.
@nate I had already done what you had suggested beforehand with the ProtectHome etc. It still gave the same error running mysqld --verbose.
@jonathon I had a pacsave. I reconverted the file to a regular file, this likely was a bad idea. Forgive my newness to this. I also did try moving things around as specified in the links I had put. I will try systemctl edit mariadb and see how it goes. I haven’t tried removing the mysql files yet because I’m not sure what to remove (I’m completely new to MariaDB and am installing it to learn how to use it), should I remove everything in the directory?
First off, apologies for me being as dumb with this as I am. I did what you said, followed the Arch Wiki guide, and was now finally able to start the service. I then ran sudo chmod 755 for the folder and it seemingly went through but did not fix the issue.