My job is on the line - Error establishing a database connection


Hello C9, I have a client’s website currently displaying the error “Error establishing a database connection” since yesterday which ought to be presented before deploying to the live environment. We have done all we could to resolve the issue but to no avail. It appears MySQL server has issues.

Please help because my job is on the line because of this.

Thank you


Not much info to go on.

Can you still connect to the DB via phpMyAdmin or any other tool ?


Thanks for your response David,

We only tried to restart the mysql server after we noticed it wasn’t
working, as suggested in this thread
phpMyAdmin stopped working.

We can’t access phpmyadmin. The database server. The database server isn’t


What is the hostname and port for your database that you are trying to connect to from inside of your code?

If you’re running the database server on your hosted workspace you should ensure that your database server is listening to the port that you expect. You can do this by typing sudo netstat -tulpn | grep <port number here> on the command-line, and you should see your database server’s process listening on the expected port.

If you’re running the database server somewhere else then you’ll need to ensure that your hosted workspace can connect to the database server hostname and port. You can test this by typing nc -w5 -zv <hostname here> <port number here> on the command-line.


Hello Abailiss;

I apologise for the late response.

c9 generated the database, we did not create it.


Hello Abailiss,

I’m still expecting your positive feedback.

Can you assist in helping me get my database? If we can get the database, we can progress from there. Please check my workspace and assist it getting the database.

Anyone who can help us retrieve our database? I’m really under pressure.

Thanks in advance.


Hello c9;

The problem is still outstanding. Can anyone offer to help? If you can send me the database It will go a long way to resolve the issue.

Please check my workspace


Hello Ronynx;

I’m not sure if you got my reply.

I can’t connect using any other tool, I do not even know the database name since it was autogenerated when I started the project. Currently, if we can download the database file, we can proceed. I have tried to access /var/lib/mysql but it appears I do not have the permission to do so, we do not even have the permission to write files.

Can you please help me? I need to secure my job. Anyone, please!


Cloud9 doesn’t “auto-generate” any databases, so I’m not sure what you are referring to exactly. What makes you think that we generate databases?

Try using the root user to access /var/lib/mysql. You’ll see this directory is owned by the root user, so you’ll need to use that user to read/write from/to it.


Hello Abailiss;

Thanks for the clarification. The point I’m trying to make is that I have no idea my database name and password.

my user account name is and it’s what I’m using, yet I’m still denied to access /var/lib/mysql. Can you help download the database from your end? You can check my work area, please.



You can access /var/lib/mysql by using the root user in your workspace. Type sudo su and then cd /var/lib/mysql for example.

Our documentation for setting up a MySQL database in your workspace might be useful to you :slightly_smiling_face:.


Hello Abailiss;

Thanks for your feedback.

I was able to access the files using the below root environment.

rdmdevelopers:~/workspace $ sudo-i

“inlaks-db.sql” might be the backup file found and I want to download or read the file and I have tried commands like “Type” or “Read” but none worked. See attached screenshot

Please, can you guide me on how I can download the backup file?

Or is there a GUI interphase we can use to access the files and download them?

Please advise.

Thanks in advance.


After getting root permissions (sudo), you should be able to copy ( the database to your workspace folder. (The folders that you can see at the left side of the screen.)

Then, you can right click on the folder and press on “Download”



We successfully copied it. However, it was not displayed in our workspace, could not find it in the folder tree.

I have copied the file using the below command.


And it was copied successfully.


However, I tried to checked but it did not show at the tree by the left

Can you please guide me on how to move the files in my workspace (Inlaks -, what is the path to this workspace?



The problem here is that you’re still logged in as the root user. To fix this, just keep in mind that the root home folder is different from the ubuntu home folder. Try the following command:

cp inlaks-db.sql /home/ubuntu/workspace


Thanks for your reply Danny.

I was able to download the SQL file, but it appeared blank. So we decided to copy the entire database in db-backups, tried to add file in data of mysql, and extracted the sql file using phpmyadmin

However, what we downloaded is an .FRM file, and tried to export it, but it gave the below error depicted in the screenshot below. Based on my research, .MYI and .IBD files ought to be included as well, but it was missing. Can you please guide me on how to get these files (.MYI and .IBD) related to the database tables?



This case has been escalated to the extent that the Lawyer of the company I work is considering a lawsuit if we do not get the database. Please, we have taken to long on this, can you help download the MYI file of my workspace and send to me? Its a matter of urgency now.

PLEASE!!! @dannytech stefnotch @abailiss @Ronynx @_phred


To expatiate @dannytech @abailiss @stefnotch @Ronynx @_phred

We require the MYI and IDB file for each table like that of FRM file… please see the below mysql file extension detail

The *.frm files contain the table definitions. Your *.myi files are MyISAM index files. Your *.myd files contain the table data

As we tried to found MYD file but did not work.

Generally, each FRM file is related to MYI and IDB file and its located in the same folder but here only FRM file visible, so maybe the database row file is saved in another location or maybe MYI and IDB file hidden. Whichever the case, please help us get the MYI and IDB file and send to us, please.

Thanks in advance.


I just want to clear all doubts that I was referring to myself here, not to anyone mentioned. Apologies if it was misconstrued. I hope someone helps me with those files requested, a plead!



You could copy the entire folder.

cp -r /var/lib/mysql/ /home/ubuntu/workspace

And download all the files.