0

I'm setting up a "clean" image for my home Raspberry pi running the latest Raspbian, and I'm finding a small problem when installing the mariadb database.

So far, the steps I've taken are the following:

  sudo apt-get install -y mariadb-server

  sudo nano /etc/mysql/my.cnf

Add the following lines to my.cnf:

  [mysqld]
  datadir=/mnt/RaspberryData/mysql
  socket=/mnt/RaspberryData/mysql/mysql.sock
  [client]
  port=3306
  socket=/mnt/RaspberryData/mysql/mysql.sock

The path /mnt/RaspberryData/mysqlcontains the database info of my previous installation, which was configured through a hard link. This may or may not be the issue.

Then execute:

  sudo sytemctl start mariadb
  journalctl -u mariadb

And here's when I have the issue:

Jun 22 19:18:33 raspberrypi systemd[1]: Starting MariaDB 10.3.22 database server...
Jun 22 19:18:34 raspberrypi mysqld[2623]: 2020-06-22 19:18:34 0 [Note] /usr/sbin/mysqld (mysqld 10.3.22-MariaDB-0+deb10u1) starting as process 2623 ...
Jun 22 19:18:35 raspberrypi systemd[1]: Started MariaDB 10.3.22 database server.
Jun 22 19:18:35 raspberrypi /etc/mysql/debian-start[2662]: /usr/bin/mysql_upgrade: the '--basedir' option is always ignored
Jun 22 19:18:35 raspberrypi /etc/mysql/debian-start[2662]: Looking for 'mysql' as: /usr/bin/mysql
Jun 22 19:18:35 raspberrypi /etc/mysql/debian-start[2662]: Looking for 'mysqlcheck' as: /usr/bin/mysqlcheck
Jun 22 19:18:35 raspberrypi /etc/mysql/debian-start[2662]: Version check failed. Got the following error when calling the 'mysql' command line client
Jun 22 19:18:35 raspberrypi /etc/mysql/debian-start[2662]: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Jun 22 19:18:35 raspberrypi /etc/mysql/debian-start[2662]: FATAL ERROR: Upgrade failed

As you can see, there's some kind of update process that is trying to connect through a socket located in /var/run/mysqld/mysqld.sockbut that path has nothing (Only a mysqld.pid file).

I'm guessing the guides on how to move the data from one location to another omitted some process or whatnot, as I can actually get into the database and execute queries. So, what am I missing here?

2
  • Are you sure when mysql is starting it's reading /etc/mysqld/my.cnf, and it's not being ignored in favor of /etc/my.cnf?
    – Kahn
    Commented Jun 22, 2020 at 23:26
  • There is no my.cnf under /etc/my.cnf, so yeah. Also, it seems mariadb is using the path linked on /etc/mysql/my.cnf, as the old databases stored in my new path are being shown.
    – Neuromante
    Commented Jun 23, 2020 at 9:42

2 Answers 2

0

Ok, I found what was left in my configuration.

Bear in mind that this may is a bit overkill (read: modifying more files than it should), but unless someone wiser comes to teach me, I'll stick happy with it:

So, let's start by reading the my.cnffile:

# The MariaDB configuration file
#
# The MariaDB/MySQL tools read configuration files in the following order:
# 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults,
# 2. "/etc/mysql/conf.d/*.cnf" to set global options.
# 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.
# 4. "~/.my.cnf" to set user-specific options.

My issue here was that there was an upgrade process trying to use a socket defined somewhere. Obviously, "somewhere" meant (hopefully) "in a configuration file" so I dove in these files:

Going sudo nanoon the files listed (specially on those under /etc/mysql/mariadb.conf.d/*.cnf showed me several entries for socket that kept the original value on the /run/ folder. So I changed it to the new folder "just in case." It turns out one of the files listed as a comment that I should Not forget to update debian.cnf if you change the socket. Well, thanks, Mr. Database builder, because you mostly give me the real answer, as debian.cnf, even though it has a huge "DO NOT TOUCH" comment above, has this section below:

[mysql_upgrade]
host     = localhost
user     = root
password =
socket   = /var/run/mysqld/mysqld.sock
basedir  = /usr

Which seems to be exactly the process that was crashing.

So, tl;dr: Go through all the files listed on the my.cnf and change the socket value just in case. Also debian.cnf. And if you feel adventurous enough, change only debian.cnfand please tell me what happened.

I have a shitload of stuff to install now that I have the database working.

0

I had the same error message after I updated from Raspberry Stretch to Buster. The /var/run/mysqld/mysqld.sock is not empty (ls -all) but you can't configure the data inside.

I've looked at all of the files (sudo nano) and one file was the answer to my problem! Luckily the old configuration (/etc/mysql/mariadb.conf.d/50-server.cnf.old) was saved!

  • Save the new file 50-server.cnf under a new name in case things go wrong example: 50-server_very_old
  • Use sudo nano to open 50-server.cnf.old and take away the old and save to make it the new version 50-server.cnf.
  • Restart the system and everything works as before!
1
  • 1
    Welcome to the site, and thank you for your contribution. Perhaps you could explain why you propose to edit the file 50-server.cnf.old just to rename it. Wouldn't a cp 50-server.cnf.old 50-server.cnf do just the same?
    – AdminBee
    Commented Mar 9, 2021 at 7:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .