Error establishing a database connection wordpress docker

  • I have an existing MySQL 8 docker container at localhost:3308 which is working.

    I just pulled the latest WordPress docker image and ran it with
    docker run --name some-wordpress -p 8080:80 -d wordpress

    //localhost:8080/wp-admin/setup-config.php displays correctly bit will not connect to the MySql instance. The error page gives no diagnostic info so I can’t tell what specifically isn’t working. Just “Error establishing a database connection”

    I set the following:
    Database Name: wordpress [I created a schema called wordpress in MySql assuming “Database” = “Schema”]
    Username: root
    Password: password
    Database host: localhost:3308
    Table prefix: wp_

    The user has full access to the wordpress schema.

    What am I missing/doing wrong?

    • This topic was modified 10 months, 2 weeks ago by James Huff. Reason: moved to Localhost Installs since this is a localhost install

  • I have set up a server to host multiple websites according to this tutorial: //blog.ssdnodes.com/blog/host-multiple-ssl-websites-docker-nginx/

    I have also configured a docker-compose.yml for wordpress like they did in example 2 in the same tutorial. But when I open the website, I get an "Error establishing a database connection" Error. I remember doing this a few months back with everything working fine, but I cant remember what I did differently.

    This is the error message I receive [multiple times] after typing docker-compose up

    wp_test           | MySQL Connection Error: [1045] Access denied for user 'wordpress'@'172.20.0.9' [using password: YES]
    wp_test_db        | 2020-02-23T21:00:45.772510Z 11 [Note] Access denied for user 'wordpress'@'172.20.0.9' [using password: YES]
    

    My docker-compose.yml file looks like this:

    version: "3"
    
    services:
       db_node_domain:
         image: mysql:5.7
         volumes:
            - db_data:/var/lib/mysql
         restart: always
         environment:
            MYSQL_ROOT_PASSWORD: somewordpress
            MYSQL_DATABASE: wordpress
            MYSQL_USER: wordpress
            MYSQL_PASSWORD: wordpress
         container_name: wp_test_db
    
       wordpress:
         depends_on:
            - db_node_domain
         image: wordpress:latest
         expose:
            - 80
         restart: always
         environment:
            VIRTUAL_HOST: blog.example.com
            LETSENCRYPT_HOST: blog.example.com
            LETSENCRYPT_EMAIL: 
            WORDPRESS_DB_HOST: db_node_domain:3306
            WORDPRESS_DB_USER: wordpress
            WORDPRESS_DB_PASSWORD: wordpress
         container_name: wp_test
    volumes:
      db_data:
    
    networks:
      default:
        external:
          name: nginx-proxy
    

    I have tried to stop and start the the image, as suggested here: //www.reddit.com/r/docker/comments/ahzv5d/wordpress_cant_connect_to_mysql/

    I have also tried another wordpress docker-config.yml and added the nginx paramaters myselve, but got the same error message //docs.docker.com/compose/wordpress/

    EDIT I got new error messages

    wp_test_db        | 2020-02-23T22:09:40.654580Z 0 [Note] mysqld [mysqld 5.7.29] starting as process 1 ...
    wp_test_db        | 2020-02-23T22:09:40.659627Z 0 [Note] InnoDB: PUNCH HOLE support available
    wp_test_db        | 2020-02-23T22:09:40.659883Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
    wp_test_db        | 2020-02-23T22:09:40.659958Z 0 [Note] InnoDB: Uses event mutexes
    wp_test_db        | 2020-02-23T22:09:40.660412Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence[] is used for memory barrier
    wp_test_db        | 2020-02-23T22:09:40.660451Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
    wp_test_db        | 2020-02-23T22:09:40.660811Z 0 [Note] InnoDB: Using Linux native AIO
    wp_test_db        | 2020-02-23T22:09:40.661814Z 0 [Note] InnoDB: Number of pools: 1
    wp_test_db        | 2020-02-23T22:09:40.662418Z 0 [Note] InnoDB: Using CPU crc32 instructions
    wp_test_db        | 2020-02-23T22:09:40.667522Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
    wp_test_db        | 2020-02-23T22:09:40.681674Z 0 [Note] InnoDB: Completed initialization of buffer pool
    wp_test_db        | 2020-02-23T22:09:40.687033Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority[].
    wp_test_db        | 2020-02-23T22:09:40.701423Z 0 [ERROR] [FATAL] InnoDB: Table flags are 0 in the data dictionary but the flags in file ./ibdata1 are 0x4000!
    wp_test_db        | 2020-02-23 22:09:40 0x7f7ce62ee740  InnoDB: Assertion failure in thread 140174414505792 in file ut0ut.cc line 918
    wp_test_db        | InnoDB: We intentionally generate a memory trap.
    wp_test_db        | InnoDB: Submit a detailed bug report to //bugs.mysql.com.
    wp_test_db        | InnoDB: If you get repeated assertion failures or crashes, even
    wp_test_db        | InnoDB: immediately after the mysqld startup, there may be
    wp_test_db        | InnoDB: corruption in the InnoDB tablespace. Please refer to
    wp_test_db        | InnoDB: //dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html
    wp_test_db        | InnoDB: about forcing recovery.
    wp_test_db        | 22:09:40 UTC - mysqld got signal 6 ;
    wp_test_db        | This could be because you hit a bug. It is also possible that this binary
    wp_test_db        | or one of the libraries it was linked against is corrupt, improperly built,
    wp_test_db        | or misconfigured. This error can also be caused by malfunctioning hardware.
    wp_test_db        | Attempting to collect some information that could help diagnose the problem.
    wp_test_db        | As this is a crash and something is definitely wrong, the information
    wp_test_db        | collection process might fail.
    wp_test_db        | 
    wp_test_db        | key_buffer_size=8388608
    wp_test_db        | read_buffer_size=131072
    wp_test_db        | max_used_connections=0
    wp_test_db        | max_threads=151
    wp_test_db        | thread_count=0
    wp_test_db        | connection_count=0
    wp_test_db        | It is possible that mysqld could use up to 
    wp_test_db        | key_buffer_size + [read_buffer_size + sort_buffer_size]*max_threads = 68196 K  bytes of memory
    wp_test_db        | Hope that's ok; if not, decrease some variables in the equation.
    wp_test_db        | 
    wp_test_db        | Thread pointer: 0x0
    wp_test_db        | Attempting backtrace. You can use the following information to find out
    wp_test_db        | where mysqld died. If you see no messages after this, something went
    wp_test_db        | terribly wrong...
    wp_test_db        | stack_bottom = 0 thread_stack 0x40000
    wp_test_db        | mysqld[my_print_stacktrace+0x2c][0x5643574c60cc]
    wp_test_db        | mysqld[handle_fatal_signal+0x479][0x564356de87b9]
    wp_test_db        | /lib/x86_64-linux-gnu/libpthread.so.0[+0x110e0][0x7f7ce5ecb0e0]
    wp_test_db        | /lib/x86_64-linux-gnu/libc.so.6[gsignal+0xcf][0x7f7ce4657fff]
    wp_test_db        | /lib/x86_64-linux-gnu/libc.so.6[abort+0x16a][0x7f7ce465942a]
    wp_test_db        | mysqld[+0x699b25][0x564356dbeb25]
    wp_test_db        | mysqld[_ZN2ib5fatalD1Ev+0x12d][0x56435782ed8d]
    wp_test_db        | mysqld[+0x11b68f1][0x5643578db8f1]
    wp_test_db        | mysqld[+0x11b6f28][0x5643578dbf28]
    wp_test_db        | mysqld[_Z6fil_ioRK9IORequestbRK9page_id_tRK11page_size_tmmPvS8_+0x2b0][0x5643578e5110]
    wp_test_db        | mysqld[_Z13buf_read_pageRK9page_id_tRK11page_size_t+0xce][0x56435789a33e]
    wp_test_db        | mysqld[_Z16buf_page_get_genRK9page_id_tRK11page_size_tmP11buf_block_tmPKcmP5mtr_tb+0x4aa][0x56435786957a]
    wp_test_db        | mysqld[_Z31trx_rseg_get_n_undo_tablespacesPm+0x143][0x56435780d1f3]
    wp_test_db        | mysqld[+0x698c99][0x564356dbdc99]
    wp_test_db        | mysqld[_Z34innobase_start_or_create_for_mysqlv+0x2f3d][0x5643577da06d]
    wp_test_db        | mysqld[+0xf80438][0x5643576a5438]
    wp_test_db        | mysqld[_Z24ha_initialize_handlertonP13st_plugin_int+0x4f][0x564356e390ff]
    wp_test_db        | mysqld[+0xb8c0f6][0x5643572b10f6]
    wp_test_db        | mysqld[_Z40plugin_register_builtin_and_init_core_sePiPPc+0x2f0][0x5643572b4300]
    wp_test_db        | mysqld[+0x6bbece][0x564356de0ece]
    wp_test_db        | mysqld[_Z11mysqld_mainiPPc+0xc71][0x564356de2a71]
    wp_test_db        | /lib/x86_64-linux-gnu/libc.so.6[__libc_start_main+0xf1][0x7f7ce46452e1]
    wp_test_db        | mysqld[_start+0x2a][0x564356dd8eaa]
    wp_test_db        | The manual page at //dev.mysql.com/doc/mysql/en/crashing.html contains
    wp_test_db        | information that should help you find out what is causing the crash.
    

    How do I fix error establishing database connection in WordPress?

    How to Fix “Error Establishing a Database Connection” in....
    Inspect the wp-config.php File of your WordPress website..
    Check if the Database User has the Correct Privileges..
    Repair the Database..
    Inspect the WordPress Site URL in the Database..
    Restore a Backup of the Site..
    Contact the Web Hosting Provider..

    How do I check my WordPress database connection?

    Update WordPress database connection details.
    Step 1 - Open File Manager. Log into the one.com control panel. ... .
    Step 2 - Open wp-config. php. ... .
    Step 3 - Locate the login details. Usually, you can find the login details around line 20 in the wp-config file. ... .
    Step 4 - Update details..

    How do you debug error establishing a database connection?

    How To Fix The “Error Establishing a Database Connection”.
    Check Your Database Login Credentials. The first thing to do is check to ensure your database login credentials are correct. ... .
    Repairing Corrupt Database. ... .
    Fixing Corrupt WordPress Files. ... .
    Issues With Your Database Server. ... .
    Restore Latest Backup..

    How do you fix one or more database tables are unavailable the database may need to be repaired?

    If you see a message about unavailable database tables that need to be repaired, follow the steps right below..
    Step 1: Enable WordPress Database Repair Function. WordPress includes a built-in tool to help you repair a corrupted database. ... .
    Step 2: Run Database Repair Tool. ... .
    Step 3: Disable Database Repair Tool..

    Chủ Đề