SQLSTATE[HY000] [2002] No such file or directory on installing OJS 3.4.0-7 with Docker solution

Describe the issue or problem
But I am facing problem when configure OJS with Docker solution: GitHub - pkp/docker-ojs: Open Journal Systems (OJS) is a journal management and publishing system. and configure the platform but when I follow the instruction to install the journal, the following error was thrown:

Errors occurred during installation A database error has occurred:
SQLSTATE[HY000] [2002] No such file or directory 
(SQL: create table `journals` (`journal_id` bigint not null auto_increment 
primary key, `path` varchar(32) not null, `seq` double(8, 2) not null default '0' 
comment 'Used to order lists of journals', `primary_locale` varchar(14) 
not null, `enabled` smallint not null default '1' comment 'Controls 
whether or not the journal is considered \"live\" and will appear on 
the website. (Note that disabled journals may still be accessible, 
but only if the user knows the URL.)', `current_issue_id` bigint null)
 default character set utf8 collate 'utf8_general_ci')`

Does somebody in the community face the same issue? How does it fix it? Or somebody in the community have some suggestion on how to solve the issue?

What application are you using?
For example, OJS 3.4.0-7

With regards,
Jehu Njikonga

Errors occurred on 3.4.0.4 now! A few days ago i can install system all right but today occurred

I had forgot when use docker should config the database connection path to ‘XX.XX.XX.XX:3306’,do not use ‘localhost’

@LAIPENG
Where exactly did you write x.x.x.x:3306? I tryied to wrote it 172.0.0.1:3360 , but I changed my approach.

I check IP of db docker:

# docker network ls
# docker network inscepct xxxxxxxx

 "9ef796cd4846e3f6e5b24153acff77dcf93daa72d2efccaff2078ad97c5c0757": {
                "Name": "ojs_db_ojs34",
                "EndpointID": "146a8f8d91bb27afd093c10a9c78e2b6a846d5bccc372f97a31c8d6b26d0b115",
                "MacAddress": "02:42:ac:18:00:02",
                "IPv4Address": "172.24.0.2/16",
                "IPv6Address": ""

And write 172.24.0.2:3306 as a DB connection in WWW installation page. That WORKS!!!

Please, follow the easyOJS documentation and report the exact point where you were stacked.

If you follow the instructions, you don’t need to use an ip adress to reach the DB. During installation you just need to refer “db” as the remote database host.

@marc

My docker compose file is:

networks:
  inside:
    external: false

services:
  db:
    image: mariadb:10.2
    container_name: "ojs_app_34_db_latest"
    environment:
      MYSQL_ROOT_PASSWORD: "xxxxxx"
      MYSQL_DATABASE: "xxxxx"
      MYSQL_USER: "xxxxx"
      MYSQL_PASSWORD: "xxxxx"
    volumes:
      - ./volumes/db:/var/lib/mysql
      - ./volumes/dump:/docker-entrypoint-initdb.d
      - ./volumes/logs/db:/var/log/mysql

      networks:
      - inside
    restart: always

  ojs:
    image: "pkpofficial/ojs:latest"
    container_name: "ojs_app_34_latest"
    hostname: "xxxxx"
    ports:
      - "8340:80"
      - "8341:443"
    volumes:
      - /etc/localtime:/etc/localtime
      - ./volumes/private:/var/www/files
      - ./volumes/public:/var/www/html/public
      - ./volumes/apache-logs:/var/log/apache2
      - ./volumes/config/ojs.config.inc.php:/var/www/html/config.inc.php
      - ./volumes/plugins:/var/www/html/plugins

    networks:
      - inside
    depends_on:
      - db
    restart: always


  admin:
    image: adminer
    container_name: "ojs_app_34_latest_adminer"
    depends_on:
      - db
    ports:
      - 8088:8080
    networks:
      - inside
    restart: no

Adminer works like a charm - connect to sql. But in config.inc.php I must have:

[database]

driver = mysqli
host = "172.24.0.2:3306"
username = ojs

Only in that configuration it Works
 I don’t know why


TL;DR;
Did you try with host="db"?

Detailed explanation:

When you create a service like “db”, this same name could be used as a reference to this host (that it’s a container) for all hosts in the same sub-network. This is made possible by Docker’s name resolution capabilities, which act as an internal DNS system for containers sharing a network.

As far as you properly defined a network called inside that connects all containers between them db should be reachable from the admin container and also from the ojs one (notice your ports are fine because only external ports need to be exposed, as you did for “admin” and “ojs”. I mean, there is no need to expose the port 3306 for the DB).

In short, a simple reference to “db” should work.

BTW, one of the nicest things of adminer is it’s a single file.
It means, you can “install” it just downloading.

So, instead of creating a new service for adminer, I found very handy adding the adminer file in the OJS container. It’s simplier, but it also lets you confirm your ojs container is reaching correctly to the “db” one.

To do this, you only need to run this single command:

JOURNALNAME="ojs_app_34_latest" && \
docker exec -it ojs_app_$JOURNALNAME \
wget https://github.com/vrana/adminer/releases/download/v4.8.1/adminer-4.8.1-en.php -O /var/www/html/dbcheck.php 

After this, you will be able to reach your adminer in “https://localhost:8341/dbcheck.php”.
And once you finish, remember to remove it, as it could be an security issue:

JOURNALNAME="ojs_app_34_latest" && \
docker exec -it ojs_app_$JOURNALNAME rm /var/www/html/dbcheck.php 

Please, let me know if this worked to you. I’m curious.

Cheers,
m.


PD: I see an indentation issue in your “db” service but it will make your yaml invalid, so it can’t be the problem.

I dropped docker and installed OJS from tgz in “normal” Linux Container inside Proxmox. . Lets close this issue.

1 Like