Nightmare! Error establishing a database connection

Please help!

I’ve suddenly got this error: Error establishing a database connection

It happened 2 or 3 times while I was updating pages, but was ok when I waited a couple of seconds. Now I cannot access the site at all - with a deadline to meet.

I go to Adminer and it says ‘No such file or directory’.

WP_ALLOW_REPAIR is set to ‘True’ but going to /wp-admin/maint/repair.php just gives the same error.

I haven’t installed anything new on the site for about 1 week. This just came out of the blue.

Last few lines of the log file are below:

   'Error\n    at Object.<anonymous> (/Applications/Local by Flywheel.app/Contents/Resources/app.asar/main/actions-sites/wait-for-mysql.js:1:2800)\n    at Generator.next (<anonymous>)\n    at _0x3cbc6e (/Applications/Local by Flywheel.app/Contents/Resources/app.asar/main/actions-sites/wait-for-mysql.js:1:1126)\n    at process._tickCallback (internal/process/next_tick.js:68:7)' }
Aug 19, 2020, 3:30 PM GMT+1 - info: [main/index] Shutting Down VM
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/EnvironmentLoader] Environment does not have package.json: /Users/murph/Library/Application Support/Local by Flywheel/environments/custom-1-3-0/package.json
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/EnvironmentLoader] Loading Environment: /Applications/Local by Flywheel.app/Contents/Resources/extraResources/environments/custom-1-0-0/out/environment.js
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/EnvironmentLoader] Successfully Loaded Environment: /Applications/Local by Flywheel.app/Contents/Resources/extraResources/environments/custom-1-0-0/out/environment.js
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/EnvironmentLoader] Loading Environment: /Applications/Local by Flywheel.app/Contents/Resources/extraResources/environments/custom-1-1-0/out/environment.js
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/EnvironmentLoader] Successfully Loaded Environment: /Applications/Local by Flywheel.app/Contents/Resources/extraResources/environments/custom-1-1-0/out/environment.js
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/EnvironmentLoader] Loading Environment: /Applications/Local by Flywheel.app/Contents/Resources/extraResources/environments/custom-1-2-0/out/environment.js
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/EnvironmentLoader] Successfully Loaded Environment: /Applications/Local by Flywheel.app/Contents/Resources/extraResources/environments/custom-1-2-0/out/environment.js
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/EnvironmentLoader] Loading Environment: /Applications/Local by Flywheel.app/Contents/Resources/extraResources/environments/custom-1-3-0/out/environment.js
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/EnvironmentLoader] Successfully Loaded Environment: /Applications/Local by Flywheel.app/Contents/Resources/extraResources/environments/custom-1-3-0/out/environment.js
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/EnvironmentLoader] Loading Environment: /Applications/Local by Flywheel.app/Contents/Resources/extraResources/environments/custom-1-3-1/out/environment.js
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/EnvironmentLoader] Successfully Loaded Environment: /Applications/Local by Flywheel.app/Contents/Resources/extraResources/environments/custom-1-3-1/out/environment.js
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/EnvironmentLoader] Loading Environment: /Applications/Local by Flywheel.app/Contents/Resources/extraResources/environments/custom-1-3-2/out/environment.js
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/EnvironmentLoader] Successfully Loaded Environment: /Applications/Local by Flywheel.app/Contents/Resources/extraResources/environments/custom-1-3-2/out/environment.js
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/EnvironmentLoader] Loading Environment: /Applications/Local by Flywheel.app/Contents/Resources/extraResources/environments/flywheel-1-0-0/out/environment.js
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/EnvironmentLoader] Successfully Loaded Environment: /Applications/Local by Flywheel.app/Contents/Resources/extraResources/environments/flywheel-1-0-0/out/environment.js
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/EnvironmentLoader] Loading Environment: /Applications/Local by Flywheel.app/Contents/Resources/extraResources/environments/flywheel-1-1-0/out/environment.js
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/EnvironmentLoader] Successfully Loaded Environment: /Applications/Local by Flywheel.app/Contents/Resources/extraResources/environments/flywheel-1-1-0/out/environment.js
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/EnvironmentLoader] Loading Environment: /Applications/Local by Flywheel.app/Contents/Resources/extraResources/environments/flywheel-1-2-0/out/environment.js
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/EnvironmentLoader] Successfully Loaded Environment: /Applications/Local by Flywheel.app/Contents/Resources/extraResources/environments/flywheel-1-2-0/out/environment.js
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/EnvironmentLoader] Loading Environment: /Applications/Local by Flywheel.app/Contents/Resources/extraResources/environments/flywheel-1-3-0/out/environment.js
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/EnvironmentLoader] Successfully Loaded Environment: /Applications/Local by Flywheel.app/Contents/Resources/extraResources/environments/flywheel-1-3-0/out/environment.js
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/EnvironmentLoader] Loading Environment: /Applications/Local by Flywheel.app/Contents/Resources/extraResources/environments/flywheel-1-3-1/out/environment.js
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/EnvironmentLoader] Successfully Loaded Environment: /Applications/Local by Flywheel.app/Contents/Resources/extraResources/environments/flywheel-1-3-1/out/environment.js
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/EnvironmentLoader] Loading Environment: /Applications/Local by Flywheel.app/Contents/Resources/extraResources/environments/flywheel-1-3-2/out/environment.js
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/EnvironmentLoader] Successfully Loaded Environment: /Applications/Local by Flywheel.app/Contents/Resources/extraResources/environments/flywheel-1-3-2/out/environment.js
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/check-system] Check System: Docker Machine:  
{ stdout: 'Stopped\n', stderr: '' }
Aug 19, 2020, 3:32 PM GMT+1 - info: [renderer/CheckEnvPage] Check system promise response: 
[ undefined, 'machine-halted' ]
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/docker-machine] Checking Boot2Docker.iso hash
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/docker-machine] Running  /Applications/Local by Flywheel.app/Contents/Resources/extraResources/virtual-machine/vendor/docker/osx/docker-machine start local-by-flywheel
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/docker-machine] Starting "local-by-flywheel"...
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/docker-machine] (local-by-flywheel) Check network to re-create if needed...
Aug 19, 2020, 3:32 PM GMT+1 - info: [main/docker-machine] (local-by-flywheel) Waiting for an IP...
Aug 19, 2020, 3:33 PM GMT+1 - info: [main/docker-machine] Machine "local-by-flywheel" was started.
Aug 19, 2020, 3:33 PM GMT+1 - info: [main/docker-machine] Waiting for SSH to be available...
Aug 19, 2020, 3:33 PM GMT+1 - info: [main/docker-machine] Detecting the provisioner...
Aug 19, 2020, 3:33 PM GMT+1 - info: [main/docker-machine] Started machines may have new IP addresses. You may need to re-run the `docker-machine env` command.
Aug 19, 2020, 3:33 PM GMT+1 - info: [main/set-docker-env] Getting Docker Machine env.
Aug 19, 2020, 3:33 PM GMT+1 - info: [main/set-docker-env] Received Docker Machine env. export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.95.100:2376"
export DOCKER_CERT_PATH="/Users/murph/.docker/machine/machines/local-by-flywheel"
export DOCKER_MACHINE_NAME="local-by-flywheel"
# Run this command to configure your shell: 
# eval $("/Applications/Local by Flywheel.app/Contents/Resources/extraResources/virtual-machine/vendor/docker/osx/docker-machine" env --shell bash local-by-flywheel)

Aug 19, 2020, 3:33 PM GMT+1 - info: [main/docker-machine] checking IP
Aug 19, 2020, 3:33 PM GMT+1 - info: [main/docker-machine] checked IP 192.168.95.100

Aug 19, 2020, 3:33 PM GMT+1 - info: [main/docker-machine-fdv] NFS Mount Status 
{ mountedPoints: [ '/Users', '/Volumes' ],
  mountPoints: [ '/Users', '/Volumes' ] }
Aug 19, 2020, 3:33 PM GMT+1 - info: [main/docker-machine-fdv] unfsd already running
Aug 19, 2020, 3:33 PM GMT+1 - info: [main/docker-router] getRouterContainers()
Aug 19, 2020, 3:33 PM GMT+1 - info: [main/docker-router] teardown()
Aug 19, 2020, 3:33 PM GMT+1 - info: [main/docker-router] Removing router container 488614c01cd88044b7383b58d5a5652c2822aa6e9250f8114810622ffdf62b19
Aug 19, 2020, 3:33 PM GMT+1 - info: [main/docker-router] updateProxyManager()
Aug 19, 2020, 3:33 PM GMT+1 - info: [main/docker-router] runContainer()
Aug 19, 2020, 3:33 PM GMT+1 - info: [main/docker-network-manager] removeExistingNetworks
Aug 19, 2020, 3:33 PM GMT+1 - info: [main/docker-network-manager] createNetwork
Aug 19, 2020, 3:33 PM GMT+1 - info: [main/docker-router] reconnectNetwork()
Aug 19, 2020, 3:33 PM GMT+1 - warn: [main/waitForMySQL] waitForMySQL Response: 
{ stdout: '', stderr: '' }
Aug 19, 2020, 3:33 PM GMT+1 - warn: [main/waitForMySQL] waitForMySQL Response: 
{ stdout: '', stderr: '' }
Aug 19, 2020, 3:34 PM GMT+1 - warn: [main/waitForMySQL] waitForMySQL Response: 
{ stdout: '', stderr: '' }
Aug 19, 2020, 3:34 PM GMT+1 - warn: [main/SiteModel] wpInstalled not returning "installed" 
{ message: '',
  stack:
   'Error\n    at Object.<anonymous> (/Applications/Local by Flywheel.app/Contents/Resources/app.asar/main/actions-sites/wait-for-mysql.js:1:2800)\n    at Generator.next (<anonymous>)\n    at _0x3cbc6e (/Applications/Local by Flywheel.app/Contents/Resources/app.asar/main/actions-sites/wait-for-mysql.js:1:1126)\n    at process._tickCallback (internal/process/next_tick.js:68:7)' }
Aug 19, 2020, 3:38 PM GMT+1 - info: [main/docker-router] getRouterContainers()
Aug 19, 2020, 3:38 PM GMT+1 - info: [main/docker-router] teardown()
Aug 19, 2020, 3:38 PM GMT+1 - info: [main/docker-router] Removing router container 4c6bb9958b9881849adac274caafce8e9892008f3919ec925cea56c89b9a6789
Aug 19, 2020, 3:38 PM GMT+1 - info: [main/docker-router] updateProxyManager()
Aug 19, 2020, 3:38 PM GMT+1 - info: [main/docker-router] runContainer()
Aug 19, 2020, 3:38 PM GMT+1 - info: [main/docker-router] reconnectNetwork()
Aug 19, 2020, 3:39 PM GMT+1 - warn: [main/waitForMySQL] waitForMySQL Response: 
{ stdout: '', stderr: '' }
Aug 19, 2020, 3:39 PM GMT+1 - warn: [main/waitForMySQL] waitForMySQL Response: 
{ stdout: '', stderr: '' }
Aug 19, 2020, 3:40 PM GMT+1 - warn: [main/waitForMySQL] waitForMySQL Response: 
{ stdout: '', stderr: '' }
Aug 19, 2020, 3:40 PM GMT+1 - warn: [main/SiteModel] wpInstalled not returning "installed" 
{ message: '',
  stack:
   'Error\n    at Object.<anonymous> (/Applications/Local by Flywheel.app/Contents/Resources/app.asar/main/actions-sites/wait-for-mysql.js:1:2800)\n    at Generator.next (<anonymous>)\n    at _0x3cbc6e (/Applications/Local by Flywheel.app/Contents/Resources/app.asar/main/actions-sites/wait-for-mysql.js:1:1126)\n    at process._tickCallback (internal/process/next_tick.js:68:7)' }
Aug 19, 2020, 3:40 PM GMT+1 - info: [main/stopSite] Stopping site: running mydumper
Aug 19, 2020, 3:40 PM GMT+1 - info: [main/stopSite] Stopping site: stopping container ea1fd999f7db7eb45a7ab6ff3cf6e31a756cba6a059a14c33534c5872c14fc8d
Aug 19, 2020, 3:40 PM GMT+1 - warn: [main/waitForMySQL] waitForMySQL Response: 
{ stdout: '', stderr: '' }
Aug 19, 2020, 3:40 PM GMT+1 - warn: [main/waitForMySQL] waitForMySQL Response: 
{ stdout: '', stderr: '' }
Aug 19, 2020, 3:40 PM GMT+1 - warn: [main/waitForMySQL] waitForMySQL Response: 
{ stdout: '', stderr: '' }
Aug 19, 2020, 3:40 PM GMT+1 - warn: [main/SiteModel] wpInstalled not returning "installed" 
{ message: '',
  stack:
   'Error\n    at Object.<anonymous> (/Applications/Local by Flywheel.app/Contents/Resources/app.asar/main/actions-sites/wait-for-mysql.js:1:2800)\n    at Generator.next (<anonymous>)\n    at _0x3cbc6e (/Applications/Local by Flywheel.app/Contents/Resources/app.asar/main/actions-sites/wait-for-mysql.js:1:1126)\n    at process._tickCallback (internal/process/next_tick.js:68:7)' }

Hey @murph

It looks like this is happening on Local by Flywheel, which is the older version of Local.

Usually with that kind of an error, that indicates that there’s a problem with the DB going away. There might be more information within the MySQL error logs for the site.

From what you are describing it almost sounds like the DB ran out of space within the VM.

One quick workaround would be to try and restore the site to a new one in Local. You can use a backup of the site, or try using the files for the site by following the steps outlined in the “Restoring From Only Local Site files” section of this help doc:

Thanks Ben. Ive restored a backup but stupidly hadn’t backed up in 3 days :frowning_face:

Anyway, does that basically mean the DB may be beyond saving?

Also - Ive downloaded the dmg file of the latest version of Local. Will I lose my sites if I install it over the old version I’m using?

Maybe… at the very least, I don’t have that level of forensic data saving power!

It is possible that if the site was stopped in the last day or so, the DB was exported to the sql folder of the site. If that’s the case, you can try importing that sql dump to recover any of the data that’s in the db.

Nope, but I usually recommend backing things up anyway! Basically, the 3.x and the 5.x lines are so different that they are two separate applications. You can have both installed, though we generally recommend only having one of them running at a time.

This help doc goes into more detail about migrating from Local Classic to Local Lighting (also just known as “Local” now!)

Hope that helps!

Ah ok - just looking at the sql folder - there are lots of sql files. Are you saying that I might be able to import the database back into Adminer? If so - can you point me to info on how to do that? I know how to import an entire database file but I see lots of files that look like they might be tables here

Oh yeah, I forgot that Classic exported each table as a separate sql file!

From the above error log, it looks like you’re on a Mac, so you can either import each sql file individually (start with the ones that have schema in the filename – that sets up the table). Another option is to open a terminal at that SQL folder and combine the files into one sql file called combined.sql using this command:

cat *schema.sql $(ls *.sql | grep -v "schema") > combined.sql 

From there, use the combined.sql file to import into a new WP site so that you can get the data you need!

Well it very nearly worked - I combined the files ok and created the site - but its kind of messed up in a lot of places and cant quite work out why. Its ok though - at least I can get to some templates I had made so I can export them into the backup site. A huge help.

Thank you :slight_smile:

1 Like

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.