4
votes

I have a mysql server with user 'root' and no password.
When I do mysql -u root -p in a terminal I can connect to my server.
When I use mysql workbench, if I test this connection, it s successful.
But when I try to connect to the server with mysql workbench I am getting this error :

Your connection attempt failed for user 'root' from your host to server at 127.0.0.1:3306: Could not open database

Please: 1 Check that mysql is running on server 127.0.0.1
2 Check that mysql is running on port 3306 (note: 3306 is the default, but this can be changed)
3 Check the root has rights to connect to 127.0.0.1 from your address (mysql rights define what clients can connect to the server and from which machines)
4 Make sure you are both providing a password if needed and using the correct password for 127.0.0.1 connecting from the host address you're connecting from

Does anybody know what's going wrong here?

[UPDATE]
I am still having this problem.
With mysql workbench : test connection is ok, but I cannot connect to mysql server.
If this can help, here is mysql server status :
mysql Ver 14.14 Distrib 5.6.28, for debian-linux-gnu (x86_64) using EditLine wrapper

Connection id:      7
Current database:   
Current user:       root@localhost
SSL:            Not in use
Current pager:      stdout
Using outfile:      ''
Using delimiter:    ;
Server version:     5.6.28-0ubuntu0.15.10.1 (Ubuntu)
Protocol version:   10
Connection:     localhost via TCP/IP
Server characterset:    latin1
Db     characterset:    latin1
Client characterset:    utf8
Conn.  characterset:    utf8
TCP port:       3306
Uptime:         50 sec

Threads: 3  Questions: 69  Slow queries: 0  Opens: 67  Flush tables: 1  Open tables: 60  Queries per second avg: 1.380

Thanks for your help.

8

8 Answers

8
votes

I just ran into this exact same problem myself.

I can overcome it by running Mysql Workbench 'as administrator'. (close any running instances. right click it from the start menu, and choose 'run as administrator'.)

It just won't connect if I don't run it with elevated privileges. So it must be some kind of flaw or bug in Workbench.

3
votes

Perhaps you set something in the:

[Preferences -> Modeling -> MySQL -> Default Target MySQL Version]

Clear it and try again.

2
votes

The last comment on this bug report worked for me ...

[7 Jul 2016 18:33] Gaurav Vasistha

Solved for windows 7 64 bit mysql workbench 6.0 CE solution is weird but it works so just give it a try

  1. Go to Start.
  2. Type %temp% in the search box and then click the Temp folder item that appears at the top.
  3. At the top of the Explorer window, in the address bar, click the folder to the left of Temp in the folder path (Local by default).
  4. In the folder list, right-click the Temp folder and then click Properties and then click the Security tab.
  5. Click the Edit button and on the next screen click Add.
  6. On the next screen, in the large text window type Everyone and then click Check Names - Everyone should then be underlined.
  7. Check the box for Full control under the Allow column, and then click OK, then OK again, and OK again to close all the windows.

I discovered this while trying to uninstall workbench in order to reinstall it and while installing it gave an error message "the installer has encountered an unexpected error installing this package 2203 windows 7"

1
votes

I have faced the very same issue

at my local instance I have started originally the mysql-workbench with sudo and because of that some directories and files were assigned to root in the ~/.mysql/workbench/ folder, so I have deleted the full directory(~/.mysql/workbench/) and all was OK at the next run

1
votes

I had the same issue, the way I solved it was to run the workbench as root command with

 sudo mysql-workbench
1
votes

I was facing the same error. I could connect using terminal but not using workbench.

In addition, I could not connect localhost with

sudo mysql-workbench

as well.

So, I follow these steps and it worked for me: https://phoenixnap.com/kb/access-denied-for-user-root-localhost

I run this command:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'insert_password';

and then it was possible to access without admin privileges using the password 'insert_password' in the workbench.

0
votes

The terminal client does an automatic fallback, which MySQL Workbench does not. If the connection via TCP/IP fails then the terminal client attempts to connect via sockets. If your server is configured to use sockets then you have to use this method also in MySQL Workbench.

0
votes

I had this problem and after trying everything suggested here, this solved my issue:

Can't connect remotely to MySQL Server with MySQL Workbench