Select Page
MySQL correct permissions

MySQL correct permissions

If somehow someone messes up the MySQL folder permissions and you need the MySQL correct permissions, they can be found below:

chmod -v 0751 /var/lib/mysql
chown -R mysql:mysql /var/lib/mysql
InnoDB: Ignoring tablespace for because it could not be opened.

InnoDB: Ignoring tablespace for because it could not be opened.

This one was a little tricky. The same system where the junior admin made a little mess of the MariaDB server, there was this long string of errors about “InnoDB: Ignoring tablespace for because it could not be opened.”  Apparently, somehow the db got deleted manually from the filesystem and we got left with a zillion of these:

2023-08-22 19:04:31 0 [Warning] InnoDB: Ignoring tablespace for `foo`.`core_layout_link` because it could not be opened.
2023-08-22 19:04:31 0 [ERROR] InnoDB: Operating system error number 2 in a file operation.
2023-08-22 19:04:31 0 [ERROR] InnoDB: The error means the system cannot find the path specified.
2023-08-22 19:04:31 0 [ERROR] InnoDB: If you are installing InnoDB, remember that you must create directories yourself, InnoDB does not create them.
2023-08-22 19:04:31 0 [ERROR] InnoDB: Cannot open datafile for read-only: ‘./foo/core_layout_update.ibd’ OS error: 71
2023-08-22 19:04:31 0 [ERROR] InnoDB: Operating system error number 2 in a file operation.
2023-08-22 19:04:31 0 [ERROR] InnoDB: The error means the system cannot find the path specified.
2023-08-22 19:04:31 0 [ERROR] InnoDB: If you are installing InnoDB, remember that you must create directories yourself, InnoDB does not create them.
2023-08-22 19:04:31 0 [ERROR] InnoDB: Could not find a valid tablespace file for “foo`.`core_layout_update“. Please refer to https://mariadb.com/kb/en/innodb-data-dictionary-troubleshooting/ for how to resolve the issue.
2023-08-22 19:04:31 0 [Warning] InnoDB: Ignoring tablespace for `foo`.`core_layout_update` because it could not be opened.
2023-08-22 19:04:31 0 [ERROR] InnoDB: Operating system error number 2 in a file operation.
2023-08-22 19:04:31 0 [ERROR] InnoDB: The error means the system cannot find the path specified.
2023-08-22 19:04:31 0 [ERROR] InnoDB: If you are installing InnoDB, remember that you must create directories yourself, InnoDB does not create them.
2023-08-22 19:04:31 0 [ERROR] InnoDB: Cannot open datafile for read-only: ‘./foo/core_resource.ibd’ OS error: 71
2023-08-22 19:04:31 0 [ERROR] InnoDB: Operating system error number 2 in a file operation.
2023-08-22 19:04:31 0 [ERROR] InnoDB: The error means the system cannot find the path specified.
2023-08-22 19:04:31 0 [ERROR] InnoDB: If you are installing InnoDB, remember that you must create directories yourself, InnoDB does not create them.
2023-08-22 19:04:31 0 [ERROR] InnoDB: Could not find a valid tablespace file for “foo`.`core_resource“. Please refer to https://mariadb.com/kb/en/innodb-data-dictionary-troubleshooting/ for how to resolve the issue.
2023-08-22 19:04:31 0 [Warning] InnoDB: Ignoring tablespace for `foo`.`core_resource` because it could not be opened.
2023-08-22 19:04:31 0 [ERROR] InnoDB: Operating system error number 2 in a file operation.
2023-08-22 19:04:31 0 [ERROR] InnoDB: The error means the system cannot find the path specified.
2023-08-22 19:04:31 0 [ERROR] InnoDB: If you are installing InnoDB, remember that you must create directories yourself, InnoDB does not create them.
2023-08-22 19:04:31 0 [ERROR] InnoDB: Cannot open datafile for read-only: ‘./foo/paypal_ipn_log.ibd’ OS error: 71
2023-08-22 19:04:31 0 [ERROR] InnoDB: Operating system error number 2 in a file operation.
2023-08-22 19:04:31 0 [ERROR] InnoDB: The error means the system cannot find the path specified.
2023-08-22 19:04:31 0 [ERROR] InnoDB: If you are installing InnoDB, remember that you must create directories yourself, InnoDB does not create them.
2023-08-22 19:04:31 0 [ERROR] InnoDB: Could not find a valid tablespace file for “foo`.`paypal_ipn_log“. Please refer to https://mariadb.com/kb/en/innodb-data-dictionary-troubleshooting/ for how to resolve the issue.

Now, “foo” being the db name, apparently i need to recreate the file structure in /var/lib/mysql and then i can go ahead and restart the sql server and delete the db and everything should go back to normal.

Because they were too many of these, i had to do a little bash wizardry to automate the process and make it a little faster:

cat mysql.err |grep “Could not find a valid tablespace file” |cut -d ‘`’ -f 5 >> list

This would get me a list of the tables, while using ‘`’ as the delimiter for the field i was trying to find. i just cycled between the fields numbers before i got to the right one

So we go to the MySQL folder and re-create the foo db folder (where foo is the db name):

cd /var/lib/mysql

mkdir foo

Then i made this script, that would create the required files:

cd foo

nano x.sh

#!/bin/bash -x
list=$(cat ./list)

# Loopty loop
for item in $list; do
touch $item.frm
touch $item.ibd
done

chmod 700 x.sh

./x.sh

Now we have to adjust permissions on the db folder and the files inside:

cd /var/lib/mysql

chown -R mysql:mysql foo

restart mysql and go ahead and delete the foo db and the errors should be gone.

Cheers!

Can’t lock aria control file ‘/var/lib/mysql/aria_log_control

Apparently somehow they managed to start 2 instances of MariaDB that ran concurrently and they were each locking the files for another and this error kept popping in the log: “Can’t lock aria control file ‘/var/lib/mysql/aria_log_control”

Very surprised to see this one, but appeared on a server where a junior admin made a mess of a database, so i was called in to help.

In order to fix, i had to stop the monitoring scripts, and the automatic SQL restart, then i checked for all MySQL running processes, killed them, and started the db properly, while verifying in the logs to see if anything got broken due to the abrupt interruption.

A good practice after this is to run a repair on all databases, to make sure everything is in order

nmcli set nameservers (fix resolv.conf override)

If your /etc/resolv.conf gets overridden by NetworkManager on reboot, then you need to use nmcli to set nameservers in the way below:

1 – find the connection you want to edit

nmcli connection show

2 – add the nameservers

nmcli c modify “connection name” +ipv4.dns “8.8.8.8 9.9.9.9”

3 – reboot

Enjoy

curl: (60) SSL certificate problem: certificate has expired

curl: (60) SSL certificate problem: certificate has expired

if you’re trying to debug a website and you’re running some curl request and this might be a staging website or otherwise, with a self-signed ssl certificate maybe, then you could be running into: curl: (60) SSL certificate problem: certificate has expired

A real quick fix is to set curl to accept insecure connections by default in this manner:

echo “insecure” >> ~/.curlrc

Curl away!

Pin It on Pinterest