I have a project running on Docker and I'm able to connect to the database through the terminal:
mysql -h localhost -P 33060 --protocol=tcp -u 'notmyrealusername' -p
This works fine and I'm able to show the tables from the database.
However, when trying to connect via SequelPro, I get the following error:
Unable to connect to host 127.0.0.1, or the request timed out.
Be sure that the address is correct and that you have the necessary privileges, or try increasing the connection timeout (currently 10 seconds).
MySQL said: Protocol mismatch; server version = 11, client version = 10
Note that the project is running on MySQL 5.7.34 and the version on my computer is 8.0.23.
OS: Mac OS Catalina
What I have tried:
From this thread, I have tried also with the port of 2200 and, well, SequelPro won't let me use 127.0.0.1. So, I couldn't try the second one.
I have also granted all privileges to both 'notmyrealusername'#'127.0.0.1' and 'notmyrealusername'#'localhost', but that didn't seem to fix it either.
Replying to Philippe's questions:
Yes, If I try mysql -h 127.0.0.1, then I get the same error:
ERROR 2007 (HY000): Protocol mismatch; server version = 11, client
version = 10
Question:
Does anyone know either how to connect to 'localhost' and not '127.0.0.1' on SequelPro or why I can't seem to connect to this database on SequelPro, when, with the same data, I can easily connect via terminal?
Thanks in advance for all of the help/suggestions you can provide!
Thanks!
I have finally found the solution. For anyone wondering, the key here is that I am using Docker. In this case, as outlined in this forum post, we need to:
Use the IP address of the machine where the database is running (the
real one, not localhost) as host address.
How?
Go to your terminal and use the command ifconfig . You'll get a bunch of data, but what you're looking for is the local network IP address. This usually looks like either 192.x.x.x or 10.x.x.x.
Then, in Sequel Pro or whatever GUI you are using, use this address (192....) instead of localhost.
I hope this helps someone and saves you time :)
Happy coding!
I have created 2 Ubuntu 20.04 VMs using VirtualBox. I have a Django App on one VM and MySQL DB on the other VM. How do I access the MySQL DB using the first VM?
I used the inet from the output of ifconfig for the IP Address
What I tried:
On the VM having MySQL DB:
-> Change the 'bind_adress' field to '0.0.0.0' in '/etc/mysql/mysql.conf.d/mysqld.cnf'
-> Created a new user using CREATE USER 'test'#'IP_Address1' IDENTIFIED BY 'password';
-> Ran "sudo ufw allow from IP_Address1 to any port 3306"
On the VM having the Django App:
-> Tried to connect to the Virtual Machine using mysql -u 'test' -h 'IP_ADDRESS2' -p
The error I'm getting:
"Unknown MySQL host 'address'"
PS:
I created a NAT network on VirtualBox using File->Preference->Network and attached both the VMs to the network and set Promiscuous Mode to "Allow All"
How or where are you defining IP_Address1 and IP_ADDRESS2?
Specifically, your DB machine needs to know what the IP address of the client machine is when you use your CREATE USER query. So, IP_Address1 must be "known" to that machine. Maybe you just hid the IP address when you posted the question, but it might be easier to use actual IP addresses in both cases until you get connectivity.
For example, if your DB machine is 172.18.1.1 and your client machine is 172.18.1.2, then you should use those IP addresses in your commands listed above
Created a new user using
"CREATE USER 'test'#'172.18.1.2' IDENTIFIED BY 'password';"
...here you're defining the IP address of the client connection.
Then in the client machine:
"mysql -u 'test' -h '172.18.1.1' -p"
...here, telling the client the IP address of the DB machine
More importantly, you might also have to expose the DB to the local network in its configuration settings. You'll also have to deal with any routing issues if the two machines are not on the same local subnet.
There are several articles describing how to configure MySQL for network access, such as: https://www.digitalocean.com/community/tutorials/how-to-allow-remote-access-to-mysql
What have you tried? Can you connect from the command line on the .5 machine? There's a mysql command line tool you can use to connect, which might give you some more information, or have you looked at the MySQL logs to see what it's unhappy about?
It could be something like a permissions issue for the user - creating a user alone is not enough to allow them access to database resources. Maybe try something like:
GRANT ALL ON Database.* TO test#'172.25.1.5' IDENTIFIED BY 'PASSWORD';
I was assuming you had configured the various permissions on the database and were only seeing connectivity issues, but from your responses, it's not clear.
Basically, you need to isolate whether the problem is a user permission issue, an IP restriction issue, a VM issue, a coding issue with your app or something else.
Please provide more feedback about what you've tried if you're still struggling, but this could be one of a number of issues.
I have a remote mysql instance (not on the local machine, but on the same subnet as my testing platform) that I'm using for testing. So that I can mimic the real database in the application, I've modified /etc/hosts with the following two entries:
192.168.1.249 macduff
192.168.1.249 dc2-mysql-01.kattare.com
Everything works fine when I attempt to access the database remotely using
mysql -h 192.168.1.249 -u myusername -pThePassword
and
mysql -h macduff -u myusername -pThePassword
However, when I use
mysql -h dc2-mysql-01.kattare.com -u myusername -pThePassword
The mysql monitor seems to connect, but it then hangs. It prints the usual password warning but doesn't print the Welcome to the MySQL monitor message, for example. The monitor also doesn't respond to any input. I'm assuming that I've got the user set up properly, given that I can access the instance using the IP address and the single-word alias. I have a single % as the host name associated with the user. If it matters, I'm using a Homebrew install of mysql 5.7.12 on a mac running El Capitan on both the local and remote machines.
MORE INFO:
Just tried creating a user with the dc2... address listed explicitly as a host, but that didn't help (which seems to imply that this isn't a CREATE USER or GRANT issue). I let mysql run for a while, and eventually something timed out and I got a
ERROR 2003 (HY000): Can't connect to MySQL server on
'dc2-mysql-01.kattare.com' (60)
Which implies a DNS problem, but the dc2... address works fine in the browser, so it appears to be something mysql related. DNS in mysql is enabled (it recognizes the single-word alias macduff without difficulty).
Any idea what's going on?
I have a MySQL database server on a remote AWS Linux Machine. I can access this server by SSH.
However, I need to access this from my Windows computer and it's not working (using mysql -u root -p -h remoteAddress where remoteAddress in the IP address of my remote server). I also have a local MySQL server installed so mysql -u root -p -h localhost on Windows works normally.
I have read a lot on this but no solutions are working for me. The error I'm getting is:
Error 2003 (HY000): Can't connect to MySQL server on 'remoteAddress' (10060)
Now I have bind-address commented out in my my.cnf file and in addition using phpmyadmin, I can confirm that root can be accessed from anywhere (i.e. it says from %).
Even if I turn off the iptables service, I still get the same error.
Furthemore, if I type in netstat -tln | grep 3306, I get:
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
I don't care about the safety implications presently, I just want to get this working.
After reading the comments on my question I had an idea which led me to the solution. Everything on the server was set up properly except that AWS places a level of security on top of things which needs to be changed.
I simply added MySQL to the list of inbound traffic allowed in the security group settings and that solved it. I should have done this when creating the instance but didn't know that I would be using MySQL on the server at the time.
So I modified the security group to add MySQL traffic.
I know this was a really niche problem but I hope it helps someone if they find themselves in the same situation.
Could you help me solve this problem ?
When I try to click "query database" under database menu in Mysql workbench. it gives me an error:
Cannot Connect to Database Server
Your connection attempt failed for user 'root' from your host to server at
127.0.0.1:3306:Can't connect to mysql server on '127.0.0.1'(10061)
Please:
Check that mysql is running on server 127.0.0.1
Check that mysql is running on port 3306 (note: 3306 is the default, but this can be changed)
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)
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
The issue is likely due to socket authentication being enabled for the root user by default when no password is set, during the upgrade to ubuntu 16.04.
The solution is to revert back to native password authentication. You can do this by logging in to MySQL using socket authentication by doing:
sudo mysql -u root
Once logged in:
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
which will revert back to the native (old default) password authentication.
Now use password as the password whenever required by MySQL.
Try opening services.msc from the start menu search box and try manually starting the MySQL service or directly write services.msc in Run box
It looks like there are a lot of causes of this error.
My Cause / Solution
In my case, the cause was that my server was configured to only accept connections from localhost. I fixed it by following this article: How Do I Enable Remote Access To MySQL Database Server?. My my.cnf file had no skip-networking line, so I just changed the line
bind-address = 127.0.0.1
to
bind-address = 0.0.0.0
This allows connections from any IP, not just 127.0.0.1.
Then, I created a MySql user that could connect from my client machine by running the following terminal commands:
# mysql -u root -p
mysql> CREATE USER 'username'#'1.2.3.4' IDENTIFIED BY 'password';
-> GRANT ALL PRIVILEGES ON *.* TO 'username'#'1.2.3.4' WITH GRANT OPTION;
-> \q
where 1.2.3.4 is the IP of the client you are trying to connect from. If you really have trouble, you can use '%' instead of '1.2.3.4' to allow the user to connect from any IP.
Other Causes
For a fairly extensive list, see Causes of Access-Denied Errors.
Did you try to determine if this is a problem with Workbench or a general connection problem? Try this:
Open a terminal
Type mysql -u root -p -h 127.0.0.1 -P 3306
If you can connect successfully you will see a mysql prompt after you type your password (type quit and Enter there to exit).
Report back how this worked.
I had a similar issue on Mac OS and I was able to fix it this way:
From the terminal, run:
mysql -u root -p -h 127.0.0.1 -P 3306
Then, I was asked to enter the password. I just pressed enter since no password was setup.
I got a message as follows:
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL
connection id is 181. Server version: 8.0.11 Homebrew.
If you succeeded to log into mysql>, run the following command:
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
You should get a message like this:
Query OK, 0 rows affected (0.19 sec)
Now, your password is "password" and your username is "root".
Happy coding :)
Run the ALTER USER command. Be sure to change password to a strong password of your choosing.
sudo mysql # Login to mysql`
Run the below command
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
Now you can access it by using the new password.
Ref : https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-18-04
I had to start Workbench as Administrator. Apparently it didn't have the required permissions to connect to my localhost database server process.
Right-click the Workbench shortcut and select Run as Administrator. In the shortcut's Properties window, you can click on "Advanced" and tick the box next to "Run as Administrator" to always run the Workbench with Admin privileges.
The error occur because the mysql server is not starting on your computer. You should start it manually. Do following steps:
Download and install wamp server according to your bit version(32bit or 64bit) in your computer(http://wampserver-64bit.en.softonic.com/) this link allows you to download wamp server for 64bit.
As soon as you install it you can double click and run it..(you can see a icon in the right hand of the taskbar.It may be hidden .so you can click the arrow which show you the hide apps runing).So click the icon and go to Mysql
Then go to Service and there you can find Start/Resume Services click on it..
And now it is done.Open mysql workbench and see.It will work..
I had same problem with Workbench on Ubuntu, problem was with permission.
Find Workbench app
Click button Permissions
Give all permission for this app
I struggled with this problem for awhile and did several reinstalls of MySQL before discovering this.
I know that MySQL server was running OK because I could access all my DB's using the command line.
Hope this works for you.
In MySQL Workbench (5.2.47 CE)
click Mange Server Instances (bottom right corner)
click Connection
in the Connection box select:
Local Instance ($ServerName) - root#127.0.0.1:3306 '<'Standard(TCP/IP)>
click Edit Selected...
under Parameters, Hostname change localhost or 127.0.0.1 to your NetBIOS name
click Test Connection
If this works for you, great. If not change the hostname back to what it was.
Even I faced a similar error when I opened MySQL Workbench.
The solution that worked for me was:
Click on the Start button on a Windows machine
Type services and press Enter
Find MySQL and click on it
On the top side of the left panel, you will find an option as Start the service
Click on Start which is visible as a hyperlink
Forr me reason was that I tried to use newest MySQL Workbench 8.x to connect to MySQL Server 5.1 (both running on Windows Server 2012).
When I uninstalled MySQL Workbench 8.x and installed MySQL Workbench 6.3.10 it successfully connected to localhost database
For those who ignored that the initial error message displaying is the following one:
The name org.freedesktop.secrets was not provided by any .service files
Make sure to install gnome-keyring using the following
sudo apt install gnome-keyring
I tried these steps -
Step 1 : Go to Ubuntu Software Center
Step 2 : Searched for MySql Workbench
Step 3 : And Click on Permissions
Step 4 : Enable Read, add, change or remove saved passwords
Then, enter Login Password
And then, I found that my problem solved
The problem is that MySQL server is not installed.
You can get the installer from here.
Then watch this 6-minute installation tutorial.
If then creating a new connection in MySQL Workbench is not working, make sure you run that connection as root as show below:
If you don't find your .ini file, check this answer (also written below).
Enter "services.msc" on the Start menu search box.
Find MySQL service under Name column, for example, MySQL56.
Right click on MySQL service, and select Properties menu.
Look for "Path To Executable" under General tab, and there is your .ini file, for instance, "C:\Program Files (x86)\MySQL\MySQL Server 5.6\bin\mysqld.exe" --defaults-file="C:\ProgramData\MySQL\MySQL Server 5.6\my.ini" MYSQL56
I was in similar situations before and last time I found it was some Windows update issue(not sure). This time, I opened MySQL workbench and found no connection to my local database. I cannot see my tables, but yesterday I could connect to the database.
I found that my cause is that, after letting my computer sleeping for some time and wake it again, the mysql service is not running.
My solution: restart the service named "mysql" and rerun the workbench. Restarting the service takes a while, but it works.
To be up to date for upper versions and later visitors :
Currently I'm working on a win7 64bit having different tools on it including python 2.7.4 as a prerequisite for google android ...
When I upgraded from WB 6.0.8-win32 to upper versions to have 64bit performance I had some problems for example on 6.3.5-winx64 I had a bug in the details view of tables (disordered view) caused me to downgrade to 6.2.5-winx64.
As a GUI user, easy forward/backward engineering and db server relative items were working well but when we try to Database>Connect to Database we will have Not connected and will have python error if we try to execute a query however the DB server service is absolutely ran and is working well and this problem is not from the server and is from workbench. To resolve it we must use Query>Reconnect to Server to choose the DB connection explicitly and then almost everything looks good (this may be due to my multiple db connections and I couldn't find some solution to define the default db connection in workbench).
As a note : because I'm using latest Xampp version (even in linux addictively :) ), recently Xampp uses mariadb 10 instead of mysql 5.x causes the mysql file version to be 10 may cause some problems such as forward engineering of procedures which can be resolved via mysql_upgrade.exe but still when we try to check a db connection wb will inform about the wrong version however it is not critical and works well.
Conclusion : Thus sometimes db connection problems in workbench may be due to itself and not server (if you don't have other db connection relative problems).
My problem was that the MySQL server wasn't actually installed. I had run the MySQL Installer, but it didn't install the MySQL server.
I reran the installer, click "Add", and then added MySQL server to the list. Now it works fine.
In my case I have just installed MySQL Workbench but after uninstalling MySQL Workbench and installing MySQL installer and is same for both 32 and 64 bit then after it working like a charm. Hope it could be useful.
I just use:
sudo snap connect mysql-workbench-community:ssh-keys
sudo snap connect mysql-workbench-community:password-manager-service
I also struggled with this problem for quite a while.
I came accross this interesting thread from MySQL forum: http://forums.mysql.com/read.php?11,11388,11388#msg-11388
I also came accross (obviously) some good SO Q/A.
It seems that the message mentioned in "user948950" 's question can be coming from a wide range of reasons: log file too big, incorrect mysql.ini file values, spaces in the file path, security/acl issue, old entries in the registry, and so on.
So, after trying for 3h to fix this... I abandonned and decided to do a good old re-install.
This is where this post from (again) this MySQL thread came in useful, I quote:
Gary Williams wrote: Hi Guys,
I've had exactly the same problem and this is how I got it working
for me, starting with a non working installation.
Stop the windows service for any existing mysql installation.
Uninstall Mysql.
As with most uninstalls, old files are left behind. If your directory
is C:\mysql\ etc then delete the innob, etc, files but leave the
directories themselves as well as any existing databases in 'data'.
If your directory is C:\Program Files\ etc, delete all the mysql
directories.
It's now worth running regedit to make sure the old registry entries are deleted as well by the uninstall. If not, delete them.
It's ok to use the new .msi installer (essential files only), however ....
Do not use their default install path! Some genius set a path with spaces in it! Choose the custom install and select a sensible path,
ie, C:\mysql (note from Adrien: C:\mysqldata for ... the data)
Do not choose to alter the security settings. Uncheck the relevant box and the install will complete without having to set a root
password.
I think I have remembered everything.
Good luck
Gary
I did get into troubles when simply copy/pasting the databases I had in my previous "data" directory to the new one. So the work around I found was to export each database (I know... a lot of fun) and then re-import them one by one.
FYI: I used the following command to import C:/<MySQLInstallDir>/My SQL Server x.x/bin/mysql -u root -p <dbName> < "<dirPathOfDump>\<dumpName>.sql", that is for instance C:/mysql/MySQL Server 5.6/bin/mysql -u root -p mySupaCoolDb < "C:\mySupaCoolDbDump20130901.sql"
2022 and beyond this works for me:
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
change
bind-address = 127.0.0.1
to
bind-address = 0.0.0.0
Then remember to restart mysql sudo systemctl restart mysql
Initially I was confused, but I was able to solve the problem.
If your workbench was downloaded through the Snap package manager you could easily use this command to solve the problem, very simple:
sudo snap connect mysql-workbench-community:password-manager-service :password-manager-service
Go to services.msc and find MySQL.
If "Log on As" section is 'Network Service', then:
Double click on the MySQL row to open a pop-up
go to "Log on" tab
Select Log on as: "Local System account" and check "Allow service to interact with desktop"
VoilĂ , now you can start your service on localhost and make sure you enter correct root/user password on your MySQL Workbench, and you are good to go.
If you are using snap to install mysql workbench, try this:
sudo snap connect mysql-workbench-community:password-manager-service :password-manager-service to allow sandboxed package to access password service
askubuntu.com/a/1242777/1621549
This Solution was made as a comment before by Rohim Chou