Bill Noble
Bill Noble

Reputation: 6744

Can't connect to MySQL using command line but can using MySQL Workbench

I am successfully using MySQLWorkbench to access and manage a database at 127.0.0.1:3307.

However if I try to access it using the command line:

mysql -u admin -h 127.0.0.1:3307 -p

I get the error message:

ERROR 2005 (HY000): Unknown MySQL server host '127.0.0.1:3307' (0)

Why does it work with MySQLWorkbench and not with the command line?

I am running on OSX

Upvotes: 7

Views: 6203

Answers (2)

ivancho
ivancho

Reputation: 899

Because MySQLWorkbench parses out the port number, and the CLI tool doesn't. There is a separate option --port for providing it. Try

mysql --user admin --host 127.0.0.1 --port 3307 --password

Upvotes: 7

sashaboulouds
sashaboulouds

Reputation: 1854

Try to specify connection protocol

mysql -uroot -h127.0.0.1 -p --port=3307 --protocol=tcp

mysql -uroot -h127.0.0.1 -p --port=3307 --protocol=socket

Upvotes: 6

Related Questions