1

Arch Linux, standard kernel 5.16.3, MariaDB v10.6.5.

I try to start MariaDB, and it fails with

ERROR 2002 (HY000): Can't connect to local server through socket '/run/mysqld/mysqld.sock' (111)

systemctl status mariadb gives me

Jan 28 20:13:13 gazelle mariadbd[2915]: 2022-01-28 20:13:13 0 [Note] InnoDB: Buffer pool(s) load completed at 220128 20:13:13
Jan 28 20:13:13 gazelle mariadbd[2915]: 2022-01-28 20:13:13 0 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist
Jan 28 20:13:13 gazelle mariadbd[2915]: 2022-01-28 20:13:13 0 [Note] Server socket created on IP: '0.0.0.0'.
Jan 28 20:13:13 gazelle mariadbd[2915]: 2022-01-28 20:13:13 0 [Note] Server socket created on IP: '::'.
Jan 28 20:13:13 gazelle mariadbd[2915]: 2022-01-28 20:13:13 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.db' doesn't exist
Jan 28 20:13:13 gazelle mariadbd[2915]: 2022-01-28 20:13:13 0 [ERROR] Aborting
Jan 28 20:13:13 gazelle mariadbd[2915]: Warning: Memory not freed: 280
Jan 28 20:13:13 gazelle systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
Jan 28 20:13:13 gazelle systemd[1]: mariadb.service: Failed with result 'exit-code'.
Jan 28 20:13:13 gazelle systemd[1]: Failed to start MariaDB 10.6.5 database server.

So okay, I can't connect because the server isn't starting up. But even when it did start --- it did start on a few occasions, I would still get this error. I looked in /run/mysqld, and mysqld.sock is there, with 777 permissions, and it's owned by the mysql user. I've also made sure that /var/lib/mysql and everything underneath it is owned by mysql

Here's /etc/my.cnf

#
# This group is read both by the client and the server
# use it for options that affect everything
#
[client-server]

[mysqld]
socket = /run/mysqld/mysqld.sock

[client]
socket = /run/mysqld/mysqld.sock

#
# include *.cnf from the config directory
#
!includedir /etc/my.cnf.d

What are the next possible steps? I've scoured the 'net, and nothing seems to help.

danblack
  • 12,130
  • 2
  • 22
  • 41
Andrew
  • 55
  • 8
  • 1
    Curious about the two missing tables causing errors. Did the install not go smoothly, maybe reinstall? – Paul T. Jan 29 '22 at 01:30
  • What does `ls -la /var/lib/mysql/mysql` show? What else is in the logs `journalctl -u mariadb.service -n 40`? Is this a new installation or an update from a previous version? Do you have package installation logs? Welcome to SO, please edit the question with added information. – danblack Jan 29 '22 at 01:31
  • 1
    Maybe you could start here : https://stackoverflow.com/questions/34516664/cant-open-and-lock-privilege-tables-table-mysql-user-doesnt-exist/50497470 – David Jan 29 '22 at 01:37
  • @David - The top answer there is mysql only and not mariadb. The second top answer `--user=root` shouldn't be used. I assume arch used `--user=mysql` for the permissions on files. – danblack Jan 29 '22 at 01:47
  • 1
    Seems like `Can't open and lock privilege tables: Table '…' doesn't exist` are the relevant messages; just saying. – user2864740 Jan 29 '22 at 02:09
  • @PaulT. thanks for the comment. Helped clue me in to the issue. I thought it had gone fine, but I had forgotten a critical step. – Andrew Jan 30 '22 at 15:31

2 Answers2

0

When initializing the database, mysql_install_db Whether the datadir directory is specified during dB. It is recommended to use my.cnf Specify the datadir directory in the CNF configuration file

90linux
  • 134
  • 3
0

Okay, so Paul T's comment

Curious about the two missing tables causing errors. Did the install not go smoothly, maybe reinstall?

was the clue. Looked at the MariaDB page on the Arch wiki, and I forgot to run mariadb-install-db. Should've RTFM.

Andrew
  • 55
  • 8
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 31 '22 at 12:52