MySQL Error

I had a power cut this morning and after my emonpi rebooted it seems the mysql server doesn’t want to load, when browsing the the webserver you get the following error

Can’t connect to database, please verify credentials/configuration in settings.php
Error message: Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)

On issuing a “service mysql start” I get a Job for mysql.service failed. See systemctl status mysql.service and journalctl for details.

I’m at a loss on this one TBH.

Take a look at the log in /var/log/mysql.log for more information, with luck that will point you at the problem.

Post some of the end of the log here if you are stuck, it may help us guide you.

Yeh I checked in there and got nothing

Found the issue, Ive run out of space on the /dev/mmcblk0p3.
Does anyone have any step by step guides on extending this partition as its a 16g card.


Not an expert but SSH in you pi and launch this command

[details=Summary]sudo raspi-config

then the first option if I remember well is to expand to full card[/details]

clearly not the correct answer, please read a few post down with the correct answer … still learning myself all the bits and pieces :thinking:

Dave - I cannot find step by step instructions but I did find this:

sudo emonSDexpand may be better if you have an emonPi and are running the emonPi SD image


EDIT: additional info…

Hi Eric,

That command won’t work because the root partition needs to be the last partition on the card.
He needs to expand the 3rd partiton. raspi-config will give this error:

/dev/root is not the last partition. Don’t know how to expand.
Ref: Emonhub - expand file system | Archived Forum

From: (Release Candidate #2 ): emonSD-29Mar16 - emonPi / emonBase (Raspberry Pi + RFM69Pi) Emoncms v9 pre-built SD card image | Archived Forum
Caution: don’t try and run the ‘Expand file-system option’ in raspi-config. This won’t work because of the extra third partition. If you have flashed the image to an SD card greater than 4GB you can run to expand the ~/data partition

$ sudo emonSDexpand
(as Jon pointed out in the post above this one)

1 Like


Here are the steps to manually resize your third partition:

Issue the command sudo fdisk /dev/mmcblk0
Hit p then Enter to display your partition table
Take note of the number in the Start column for /dev/mmcblk0p3
Hit d then Enter, you’ll be prompted for the partition number
Hit 3 then Enter
Hit p to verify the partition is gone
Hit n
Hit p You’ll be prompted for the partition number
Hit 3 then Enter
enter the Start number you made a note of earlier
If you want to use the rest of the space on the card, hit Enter, otherwise type +size{K,M,G} e.g. +8G
Hit p then Enter to verify the partition has been created
Hit w to write the partition table


Log in and issue the command sudo resize2fs /dev/mmcblk0p3

1 Like

Just had the same problem as the original poster and fixed it with your instructions, many thanks. I might have got the resize2fs command wrong but I couldn’t get it to accept a size

First sector (2048-31291391, default 2048): 7288832 +1G
Value out of range.
First sector (2048-31291391, default 2048): 7288832 +500M
Value out of range.
First sector (2048-31291391, default 2048): 7288832
Last sector, +sectors or +size{K,M,G,T,P} (7288832-31291391, default 31291391):

Created a new partition 3 of type ‘Linux’ and of size 11.5 GiB.

The reason it gave you the Value out of range error is becasue you were appending +1G
to the line asking for the first sector number.

As the line below shows, +1G is entered on the line that asks for the last sector.

Last sector, +sectors or +size{K,M,G,T,P} (7288832-31291391, default 31291391):