Ecommerce Shopify WordPress Discussion

Docker – Error establishing a database connection

Im on Mac 14.2.1 and Docker 4.27.2. Just today an error has started when running npm run wp-env start the container is created and is running but an error is displayed stating that there is an issue with the database connection. ➜ TEST npm run wp-env start > @ wp-env /Users/ciaran/Projects/TEST > wp-env "start" ⚠ Warning: could not find a .wp-env.json configuration file and could not determine if '/Users/ciaran/Projects/TEST' is a WordPress installation, a plugin, or a theme. ✖ Error while running docker compose command. Container 31ccb2fb25f5a8b628d4a487d8d7a7d7-tests-mysql-1 Running Container 31ccb2fb25f5a8b628d4a487d8d7a7d7-tests-wordpress-1 Running Error: Error establishing a database connection. This either means that the username and password information in your `wp-config.php` file is incorrect or that contact with the database server at `tests-mysql` could not be established. This could mean your host’s database server is down. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! @ wp-env: `wp-env "start"` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the @ wp-env script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm WARN Local package.json exists, but node_modules missing, did you mean to install? npm ERR! A complete log of this run can be found in: npm ERR! /Users/ciaran/.npm/_logs/2024-02-21T16_45_59_997Z-debug.log log 0 info it worked if it ends with ok 1 verbose cli [ 1 verbose cli '/Users/ciaran/.nvm/versions/node/v14.21.3/bin/node', 1 verbose cli '/Users/ciaran/.nvm/versions/node/v14.21.3/bin/npm', 1 verbose cli 'run', 1 verbose cli 'wp-env', 1 verbose cli 'start' 1 verbose cli ] 2 info using npm@6.14.18 3 info using node@v14.21.3 4 verbose run-script [ 'prewp-env', 'wp-env', 'postwp-env' ] 5 info lifecycle @~prewp-env: @ 6 info lifecycle @~wp-env: @ 7 verbose lifecycle @~wp-env: unsafe-perm in lifecycle true 8 verbose lifecycle @~wp-env: PATH: /Users/ciaran/.nvm/versions/node/v14.21.3/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/ciaran/Projects/TEST/node_modules/.bin:/Users/ciaran/.nvm/versions/node/v14.21.3/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/ 9 verbose lifecycle @~wp-env: CWD: /Users/ciaran/Projects/TEST 10 silly lifecycle @~wp-env: Args: [ '-c', 'wp-env "start"' ] 11 silly lifecycle @~wp-env: Returned: code: 1 signal: null 12 info lifecycle @~wp-env: Failed to exec wp-env script 13 verbose stack Error: @ wp-env: `wp-env "start"` 13 verbose stack Exit status 1 13 verbose stack at EventEmitter.<anonymous> (/Users/ciaran/.nvm/versions/node/v14.21.3/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16) 13 verbose stack at EventEmitter.emit (events.js:400:28) 13 verbose stack at ChildProcess.<anonymous> (/Users/ciaran/.nvm/versions/node/v14.21.3/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14) 13 verbose stack at ChildProcess.emit (events.js:400:28) 13 verbose stack at maybeClose (internal/child_process.js:1088:16) 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:296:5) 14 verbose pkgid @ 15 verbose cwd /Users/ciaran/Projects/TEST 16 verbose Darwin 23.2.0 17 verbose argv "/Users/ciaran/.nvm/versions/node/v14.21.3/bin/node" "/Users/ciaran/.nvm/versions/node/v14.21.3/bin/npm" "run" "wp-env" "start" 18 verbose node v14.21.3 19 verbose npm v6.14.18 20 error code ELIFECYCLE 21 error errno 1 22 error @ wp-env: `wp-env "start"` 22 error Exit status 1 23 error Failed at the @ wp-env script. 23 error This is probably not a problem with npm. There is likely additional logging output above. 24 verbose exit [ 1, true ] any help on this would be great. I've nuked docker, NVM and Node and reinstalled to no avail.
I had this problem today too. Apparently, there's something wrong with MariaDB. Here is what I did to fix it on my Mac: Open the docker container file (for me it was located at /(myusername)/.wp-env/(container_name) Your container name in this case will be: 31ccb2fb25f5a8b628d4a487d8d7a7d7 Note: You will need to do cmd + shift + . to see the .wp-env file because it is hidden Open the docker-compose.yml file in a code editor. Underneath image: mariadb, create a new line and enter: command: --character-set-server=utf8mb4 --collation-server=utf8mb4_bin I had to enter this 2 times, so check if image: mariadb appears more than once Save the docker-compose.yml file and delete everything else in the folder Open terminal and navigate to /(username)/.wp-env/(container_name) using the cd command Enter docker compose up -d to start Wordpress Do not use wp-env start because it will overwrite your docker-compose.yml file. Your Wordpress site should be working now when you visit localhost:8888. (You may have to setup the site manually). If you need more info, I got this from here:

February 26, 2024

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.