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 Jun 22 '20 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 Jun 23 '20 at 9:42
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.