LycheeOrg/Lychee-Docker

Initial database configuration instructions unclear and fail

theswampire opened this issue · 4 comments

Hi there!
I am trying to get lychee working but I keep hitting this error:

-------------------------------------
  _               _
 | |   _   _  ___| |__   ___  ___
 | |  | | | |/ __|  _ \ / _ \/ _ \
 | |__| |_| | (__| | | |  __/  __/
 |_____\__, |\___|_| |_|\___|\___|
 | |   |___/ _ __ __ ___   _____| |
 | |   / _' | '__/ _' \ \ / / _ \ |
 | |__| (_| | | | (_| |\ V /  __/ |
 |_____\__,_|_|  \__,_| \_/ \___|_|

-------------------------------------
Lychee Version: 4.4.0 (release)
Lychee Commit:  5b51765
https://github.com/LycheeOrg/Lychee/commit/5b51765c7c66e6542ff2a6dcd3fb57393ff16717
-------------------------------------
**** Make sure the /conf and /uploads folders exist ****
**** Create the symbolic link for the /uploads folder ****
**** Create the symbolic link for the /sym folder ****
**** Create the symbolic link to the old Lychee-Laravel folder ****
**** Copy the .env to /conf ****
**** Inject .env values ****
sed: -e expression #1, char 39: unterminated `s' command
**** Generate the key (to make sure that cookies cannot be decrypted etc) ****

Application key set successfully.
**** Migrate the database ****


In Connection.php line 703:

  SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from inform
  ation_schema.tables where table_schema = lychee and table_name = migrations
   and table_type = 'BASE TABLE')


In Connector.php line 70:

  SQLSTATE[HY000] [2002] No such file or directory


**** Check user.css exists and symlink it ****
**** Create user and use PUID/PGID ****
        User UID :      1000
        User GID :      1000
**** Set Permissions ****
**** Setup complete, starting the server. ****

On the browser I'm greeted by the lovely Lychee-Installer which responds with error 500 once I click "Install".


I had a hard time finding information about the database setup (or I'm just too tired...). The docs somehow just skip over that part but I stumbled across these two articles

# mysql -u root -p
CREATE DATABASE lychee_db CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'shells_user'@'localhost' IDENTIFIED BY 'UltraSecurePassword';
GRANT ALL PRIVILEGES ON lychee_db.* TO 'lychee_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
# mysql -u root -p
MariaDB [(none)]> CREATE DATABASE lychee; 
MariaDB [(none)]> CREATE USER 'lycheeadmin'@'localhost' IDENTIFIED BY '=@!#@%$Lost';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON  lychee.* TO 'lycheeadmin'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit

which I tried both without success. (with adjusted credentials of course)

Are they outdated because I apparently use v4.4.0 and they v3.x?
How can I correctly configure the database?


Setup

Database: MariaDB 10.7.3 (clean, new container)
Container-Engine: Not using Docker, using Podman 3.4.2 (other DB-related apps work fine, so should be irrelevant)
Host: Raspberry Pi 4B 4GB, rev 1.1 (arm64)

d7415 commented

That error looks like one of your options is breaking the injection script. Possibly a password.

Are they outdated because I apparently use v4.4.0 and they v3.x?

Yes, but that shouldn't be relevant in this specific case.

How can I correctly configure the database?

So long as there's a database that the container can connect to, with a username and password with appropriate access, the installer should handle the rest.

@d7415 Thank you for your quick response!
I tried your suggestion and the password indeed caused some trouble. Unfortunately the error 500 still persists ( previously I might have added the password in the installer window...)

The trimmed logs:

**** Inject .env values ****
**** Generate the key (to make sure that cookies cannot be decrypted etc) ****

Application key set successfully.
**** Migrate the database ****


In Connection.php line 703:

  SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from inform
  ation_schema.tables where table_schema = lychee and table_name = migrations
   and table_type = 'BASE TABLE')


In Connector.php line 70:

  SQLSTATE[HY000] [2002] No such file or directory


**** Check user.css exists and symlink it ****
**** Create user and use PUID/PGID ****
        User UID :      1000
        User GID :      1000
**** Set Permissions ****
**** Setup complete, starting the server. ****

There are no errors in the MariaDB container.


I run the containers using following commands:

podman pod create \
	--name lychee_pod \
	--net slirp4netns:port_handler=slirp4netns,allow_host_loopback=true \
	-p 5001:80  # Lychee

podman run -d \
    --name lychee_mariadb \
    --pod lychee_pod \
    -e MYSQL_LOG_CONSOLE=true \
    -v /opt/lychee_db:/var/lib/mysql \
    -e MYSQL_ROOT_PASSWORD=rootpassword \
    mariadb:latest

podman run -d \
	--name lychee \
	--pod lychee_pod \
	-v /opt/lychee:/uploads \
	-e PHP_TZ=$(cat /etc/timezone) \
	-e TIMEZONE=$(cat /etc/timezone) \
	-e DB_CONNECTION=mysql \
	-e DB_HOST=localhost \
	-e DB_PORT=3306 \
	-e DB_DATABASE=lychee \
	-e DB_USERNAME=lychee \
	-e DB_PASSWORD=password \
	lycheeorg/lychee

To setup the database I ran:

# mysql -u root -p
MariaDB [(none)]> CREATE DATABASE lychee; 
MariaDB [(none)]> CREATE USER 'lychee'@'localhost' IDENTIFIED BY 'password';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON  lychee.* TO 'lychee'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;

I turned on APP_DEBUG=true and error 500 from the installer was caused by missing permissions to append to /var/www/html/Lychee/storage/logs/laravel.log which is owned by root and doesn't have write permission for others.
After I changed the permissions to 666, the same SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = lychee and table_name = migrations and table_type = 'BASE TABLE') pops up...

I think I'll try another release version and report back.

d7415 commented

Do you still get a 500 error after fixing the log permissions?

Turns out the SQL Error SQLSTATE[HY000] [2002] No such file or directory is about a socket connection lychee didn't find.
According to this StackOverflow Post DB_HOST needs to be 127.0.0.1 instead of localhost.

I changed the SQL-Commands accordingly:

CREATE DATABASE lychee; 
CREATE USER 'lychee'@'127.0.0.1' IDENTIFIED BY 'Password124';
GRANT ALL PRIVILEGES ON  lychee.* TO 'lychee'@'127.0.0.1';
FLUSH PRIVILEGES;
EXIT;

Lychee now works perfectly fine!
Thank you @d7415 for helping me out 😉