Skip to main content
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Export Datbase using ssh



I have managed wordpress website which has over 5k posts and db is so big that I cannot download it from phpmyadmin , Other option I have is to download DB from ssh using mysqlpdump command which gives me following error


Got error: 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) when trying to connect


I am using the right command but don't have any idea how to fix this.... Any help would be appreciated

Helper VI

Hello @therider


Maybe this will help you

***Signature: -> Do not assume anything! If you want help, explain your problem. If my post helped you, give it a Kudo. If you have the solution, mark the topic as Solved.
Community Manager

Hi @therider. Thanks for being part of GoDaddy Community. 


I looked into this, and you should be able to export your database via SSH. However, you may need to get in touch with support if you need help getting specific information. Here is the command you should be able to use once you log in via SSH:


mysqldump -u [database username] -p -h [database hostname] -P 3306 [database name] > backup.sql

You can find your database username and hostname by checking your /wp-config.php file. 


JesseW - GoDaddy | Community Manager | 24/7 support available at | Remember to choose a solution and give likes.

//Connect To the Database with PHP and MySQL
// very important -p must be followed by the password, no spaces between

// $output, $return_val are not relevant to the execution of the script

$hostname="your host name";
$username="your user name";
$password="your password";
$dbname="your database name";

$filename='your name'.date('G_a_m_d_y').'.sql';
$command = "mysqldump --opt -h $hostname -u $username -p$password $dbname > $filename";



I want to share this phh script to dump the contents of a mysql database with the community. I hope it helps other users.


The current GoDaddy technical support team is only trained to SELL MORE PRODUCTS. In the recents weeks I called several times, only to be told that the company does not support helping customers with coding. The only thing I was asking was the correct syntax for a script that is published on their knowledge base.

The solution was very simple, -p followed by the password without spaces between. Yet either they did not know or did not want to share. In any case, they were not very friendly.


What a SHAME for a big public company like GoDaddy.