Failed to Connect to MySQL at localhost:3306 with user root

8

I use Mysql Workbench to connect my database,[Hostname Port and Username are as shown in figure ,and password is right[1]

Hostname Port and Username are as shown in figure ,and password is right.When I click Test Connection ,it show as above.But if i use 3307 in place of 3306 as port,it connect sucessfully. What matter lead that and how I fix it?

I use macbook pro and I don’t know check which my.cnf. I use sudo vim /usr/local/mysql/my.cnf in terminal .
And the my.cnf is as below:

[mysqld] 
 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES            

And I rewite it as below:

[client]
port=3306
socket=/tmp/mysql.sock

[mysqld]

port=3306 socket=/tmp/mysql.sock key_buffer_size=16M max_allowed_packet=8M

[mysqldump]

quick

But it does not work.

Leave a Comment