Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use mysqldump with localhost:3307?

MySQL database was set up with Localhost:3307. I am trying to use mysqldump command to back up all the data from my coworker. I wrote the command line like this: mysqldump -u root -h 3307 -p database > "path_to_dumpfile\database.sql". then, I was prompted to enter the password (which is not asked anymore when I open the workbench). The problem is that, I get the following error message: "mysqldump: got error:2005: unknown mysql server host '3307' <2> when trying to connect" Is there something that I did wrong? or a step that I did not follow?

Thanks for your help.

like image 269
T3000 Avatar asked Jul 19 '11 18:07

T3000


2 Answers

Try adding --port=port_num to your command line instead of -h (or -P port_num if the former doesn't work) like so:

mysqldump -u root --port=3307 -p database > ..\path_to_dumpfile\database.sql

I'd recommend you take a look at the MySQL manual to learn of other possible arguments for the mysqldump command, link as follows.

Source: https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html

like image 167
Rods Avatar answered Nov 14 '22 05:11

Rods


I had the same problem, also using the --port parameter, and I solved using this suggestion from a serverfault answer:

When localhost parameter given, MySQL uses sockets. Use 127.0.0.1 instead.

like image 12
Stefano Avatar answered Nov 14 '22 07:11

Stefano