I was clearing up my Pi and I have broken Emoncms

In an attempt to uninstall unwanted and unused programs running and taking up space and memory on the same Pi as my Emoncms I seem to have broken it… (why did I touch it? It has been working just fine for a couple of years… )
I am getting the error:

Can’t connect to database, please verify credentials/configuration in settings.php
Error message: Connection refused

I have looked at the configuration in settings.php and it looks fine to me. I have googled it with no luck. Any suggestions?

There are all sorts of things it could be.

Search on “Can’t connect to database, please verify credentials/configuration in settings.php*
*Error message: Connection refused” gives a number of threads e.g.

What did you remove?

Have you run any updates?

Which SD image?

The settings will not have changed.

I have just run an update from the command line and the error has gone from “settings.php” to “settings.ini” so I guess it is now up to date.

I have added var/www/emoncms/settings.ini and it contains nothing but:

; MYSQL Database settings
username = “emoncms”
password = “emonpiemoncmsmysql2016”

I am getting the same error:

Can’t connect to database, please verify credentials/configuration in settings.ini
Error message: Connection refused

What did I remove?
NodeRED, OpenHab, maybe one or two other things - it was a couple of days ago.

What command?

cd /var/www/emoncms && git pull

That is a really bad idea. You have updated one small part of the system so it is unsurprising it doesn’t work.

You have also now compounded the error you first had.

Why not run the update from the Web UI?

I suspect it will be too difficult to untangle so I suggest a new SD card and a new EmonSD Image then import the old data off the old card.

Yea, I am good at bad ideas - i’m tinkering on the limit of my understanding and do make these kinds mistakes. The Web UI is not working - I just get the error above - so that is why I did not update from the UI.

I just tried this:

[email protected]:~ $ cd backup
[email protected]:~/backup $ ./emoncms-export.sh
=== Emoncms export start ===
Thu 31 Dec 16:27:00 UTC 2020
Backup module version:
“version” : “1.1.5”
EUID: 1000
Reading /home/pi/backup/config.cfg…
Location of mysql database: /home/pi/data
Location of emonhub.conf: /home/pi/data
Location of Emoncms: /var/www/emoncms
Backup destination: /home/pi/data
Image version: emonSD-30Oct18
mysqldump: Got error: 2002: “Can’t connect to local MySQL server through socket ‘/home/pi/data/mysql/mysql.sock’ (2 “No such file or directory”)” when trying to connect
Error: failed to export mysql data
emoncms export failed

Does that mean that the database is missing? Or that it just could not connect to it?

I’ll flash another SD card with a fresh Emon image on it.
I’m not sure how to get at the old database (if it is still there) from the old SD card, I’ll come back to you if I cannot work it out.

Thanks for your help!

It is the same problem as before - something is up with the authentication. You should be able to import the data and setup though.