Failed to run seafile server with non-root user

Hi guys,

I’ve installed successfully installed Seafile server and everything works great with one exception: because I wanted to run it with a different user than root I have created a sealife system user and also chown to seafile user the entire sealife directory.

But when starting the server with
sudo -u seafile ./sealife.sh start
I see the following errors popping in logs/seafile.log:

[10/30/2020 09:31:48 AM] ../common/seaf-db.c(707): Failed to connect to MySQL: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
[10/30/2020 09:31:48 AM] ../common/seaf-db.c(707): Failed to connect to MySQL: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
[10/30/2020 09:31:48 AM] repo-mgr.c(3646): Failed to add branch.
[10/30/2020 09:31:48 AM] seafile-session.c(349): Failed to create system default repo.

So it says that it cannot connect to mysql server although the server is running without any problems and at the same time when being run by root user everything runs perfectly.

Any clues??

I found a solution: I’ve edited the mysql server configuration files to created the socket at /tmp/mysql.sock.

After performing this change I ran in to the following error when using the mysql CLI client:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

To fix it I created a symlink to /tmp/mysql.sock
ln -s /tmp/mysql.sock /var/run/mysqld/mysqld.sock

I have tested everithing with a reboot and now it seems OK.