1

Topic: mysqld: Can't create file '/var/lib/mysql/mysqld.err'

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release):
- Deployed with iRedMail Easy or the downloadable installer?
- Linux/BSD distribution name and version:
- Store mail accounts in which backend (LDAP/MySQL/PGSQL):
- Web server (Apache or Nginx):
- Manage mail accounts with iRedAdmin-Pro?
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====

I'm attempting to upgrade my iRedMail stable container to nightly, which I believe is an upgrade from iredmail v1.5 to v1.8 internally.

To test the upgrade, I copied all data folders (with permissions) including the mysql folder, and renamed the container to iredmail-test.

When I start the iredmail-test container using the :nightly image, I get this error below.  When I start the same container using the :stable image, it works fine.

iredmail-test    | [iRedMail] Starting temporary MariaDB instance.
iredmail-test    | 2022-10-29 14:32:44 0 [Note] mysqld (server 10.6.7-MariaDB-2ubuntu1.1-log) starting as process 214 ...
iredmail-test    | mysqld: Can't create file '/var/lib/mysql/mysqld.err' (errno: 13 "Permission denied")

What could cause this permissions error for mysql in the :nightly version of the docker app?

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: mysqld: Can't create file '/var/lib/mysql/mysqld.err'

Can't create file '/var/lib/mysql/mysqld.err' (errno: 13 "Permission denied")

Clearly file permissions

3

Re: mysqld: Can't create file '/var/lib/mysql/mysqld.err'

Yes, that is certain.

But, if the data has not changed, then the question is what permission requirements changed between the two versions of the docker image?

There is no obvious way to see that, as far as I can tell?

4

Re: mysqld: Can't create file '/var/lib/mysql/mysqld.err'

under which user are both instances running? maybe just a setting makes the difference

5

Re: mysqld: Can't create file '/var/lib/mysql/mysqld.err'

Answering my own question here... 

If you're upgrading from the dockerized iRedMail container :stable image to the :nightly image, here's the general steps I followed, YMMV:

- Cleanup
  - Shutdown/stop the stable image container
  - In the /var/lib/mysql folder, delete the .pid file. (this is what caused the permissions error in the original post)

- Database upgrade (10.3 - 10.6)
  - Using a generic mariadb 10.3 image, create a new database-only container mapping your data directory to '/var/lib/mysql'
  - Start this container, and correct any permission errors in the logs.  In my case, I had to chmod 777 -R all files in my data directory to get a clean start
  - After the container starts cleanly, go into its shell and do a graceful shutdown using mysqladmin.  Something similar to 'mysqladmin --socket='/run/mysqld/mysqld.sock' -u root -p shutdown', and you'll need to paste in your DB's root password
  - The above "clean shutdown" step is important for the upgrade because it removes the database log files which will break this upgrade process
  - Change the image in the container to use a MariaDB 10.6 image, and set the MARIADB_AUTO_UPGRADE: "true" in your docker-compose.yml file
  - This will upgrade the database files to the correct version for the iRedMail :nightly image
  - Make sure there are no errors in the log, then shutdown/stop this container

- iRedMail upgrade
  - Modify the startup to use the :nightly container image.  (in my case this was modifying the docker-compose.yml)
  - Start the container
  - If you see errors related to postfix constantly restarting, you may need to chown -R your '/var/spool/postfix' directory to the postfix user.  You can do this inside the container, while it's running.

Again, YMMV based on your configs, but in my case, the main issue was that the database upgrade needed to be done manually outside of the iRedMail images.

6

Re: mysqld: Can't create file '/var/lib/mysql/mysqld.err'

Thanks for sharing.