Failed to connect to MySQL on localhost: 3306 as root

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

The port name and username are shown as shown in the figure, and the password is right. When I click "Test Connection", it displays as above. But if I use 3307 instead of 3306 as a port, it successfully connects. What is the matter and how can I fix it?

I am using macbook pro and I do not know whose my.cnf is. I am using sudo vim / usr / local / mysql / my.cnf in a terminal.
And my.cnf looks like this:

[mysqld] sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

And I rewrite 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 that will not work.

+6
source share
9 answers

Steps:

1 - Right-click on the taskbar → Launch Task Manager

2 - Click the Services button (bottom).

3 - Search MYSQL57

4 - Right click on MYSQL57 -> Start

Now run mysql-cmd-prompt or MYSQL WorkBench again

+4
source

Go to System Preferences> MySQL> Initialize Database> Use Outdated Password

+2
source

Try the following command in your terminal:

 mysql -h localhost -P 3306 -u root -p 

If you successfully connected to your database, the same thing should happen with the Mysql Workbench .

If you cannot connect, I think port 3306 received by another process.

Find which process is running on port 3306 . If necessary, grant administrator rights using sudo .

 netstat -lnp | grep 3306 

Complete this process and restart the MySQL server. Are you ready to go


Run the command below to find the my.cnf file on macbook.

 mysql --help | grep cnf 

You can change the MySQL port to any available port on your system. But after that, be sure to restart the MySQL server.

+1
source

Go to system preferences, then "MySQL"

Click on "Start MySQL Server"

Go to system settings, then "MySQL". Click "Launch MySQL Server".

+1
source

The default port for MySQL is 3306, but for some reason it may not be available, try restarting the computer. Also sesrch for your MySQL configuration file (should be called "my.cnf") and check if the port used is 3306 or 3307, if you can change 3307 to 3306, then reboot your MySQL server.

0
source

On the right side in Navigator → Instance-> Click on "Start / Shutdown" → Click on "Start Server"

Will work for sure

0
source
  1. go to the apple icon in the upper left corner and click "System Preferences"

  2. find "Mysql" below and click on it

  3. "start mysql server"

0
source

This failed because no servers were installed on your computer. You need to download 'MySQL Community Server 8.0.17' & reboot your server.

0
source

Go to> system settings> mysql> database initialization

-Change password -Click use old password -Click start sql server

it should work now

0
source

All Articles