I have a MySQL database on Azure, using the Azure managed database service, and two Ubuntu 20.04 VMs (running PHP applications) in the same VNET. I can connect to the database from both PHP, and from a remote GUI client (SequelPro), so I'm confident the firewall is configured correctly and I'm using the right details.
However, when I try to connect using the mysql CLI client on either of the VMs, it just hangs with no output. I've tried on both VMs, I get the same behaviour.
The command I'm using is:
mysql -u "username#hostname" -p -h "ip_address" -P 3306 database_name -e "SHOW TABLES"
It prompts for the password, so I enter it... and then nothing. On top the mysql process is consuming 100% of CPU.
I can telnet port 3306 on the IP address, I get the usual gibberish asking for mysql_native_password.
If I change the hostname part of the username#hostname to an invalid hostname, then it says "The servername cannot be found". Whereas if I enter an invalid username (or an invalid password) then it hangs just the same. So I'm guessing this has something to do with the gateway part of Azure managed database service that's trying to resolve that name. Everything was working normally up until a few days ago.
There's nothing in any of the logs, and no output on the screen, so I can't work out where to begin trying to fix this.
This appears to be due to https://bugs.mysql.com/bug.php?id=105288 assuming your client is 8.0.27, i hit the same issue today.
Related
I have an application which uses LocalDB and runs fine on a Windows PC, however I am trying to run this through my mac.... I'm struggling with connecting the application to a mySQL server which sits on docker. I have been following the other guides such as (https://learn.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker?view=sql-server-ver15&pivots=cs1-bash) related to this topic with no luck...
Here's what I've done so far, through terminal:
sudo docker pull mcr.microsoft.com/mssql/server:2019-CU5-ubuntu-18.04
sudo docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<MyPassword123!>"
-p 1433:1433 --name sql_container
-d mcr.microsoft.com/mssql/server:2019-CU5-ubuntu-18.04
Verified this is running by using sudo docker ps -a
Also verified by using Kitematic, container seems to be running well
MySQL looks well set-up in System Preferences
I am able to connect to the container through Azure Data Studio using IP address as server name, as shown below
Within the Application, this is is what the ConnectionStrings look like within the appsettings.json folder...
However, when I run the application and try and hit the container, through a GET request OR on Swagger, I am met with the following reply; "error": "Cannot connect to SQL Server Browser. Ensure SQL Server Browser has been started."
I have researched this and tried the solution of including the port number after the IP number as such Server=(19X.XXX.X.XX, 1433) but this also comes back with the error; "error": "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 25 - Connection string is not valid)"
I'm not sure where to go from here... any help to get this working would be greatly appreciated!
As trivial as it was, the correct syntax to make this work is Server=XXX.XXX.X.XX,1433
DO NOT INCLUDE PARENTHESES AND NO SPACE BETWEEN IP AND PORT
I'm currently trying to run an application on a server but my customer is very 'picky' about their data and wish to store the database on their own internal office server. I've installed MySQL and can get the application to run locally but for a few specific reasons the application needs to run else where.
I basically can't get access to MySQL from a different location. I think my main stumbling block is port forwarding to the correct location. MySQL is installed on a mac mini with local IP address 192.168.1.242 and the router/modem is an Apple Time Capsule. I've tried looking at tutorials but they all have options that I don't have access to. I've attached a screenshot of the options I have access to and the settings I've tried so far.
Other information possibly needed is:
I need to connect from PHP
I've set a user up within MySQL with a wildcard (%)
I'm testing it using the following: command on my local machine in CMD: mysql -u username -h remote_ip_address -p
I get the following error: ERROR 2003 (HY000): Can't connect to MySQL server on 'REMOTE_IP_ADDRESS' (10061)
Firewall is turned off completely on the Mac Mini
There is nothing in the my.cnf file
OS is Sierra
That's all I can think of at the moment but any advice would be greatly appreciated and any more information required can be provided.
PS. evidently I'm not very good with MAC machines/networks
For anyone that reads this I had a very specific issue. I installed MySQL using homebrew. Homebrew binds MySQL to 127.0.0.1 therefore will only allow connections to MySQL from the same machine no matter what you try to do. To fix it I've had to edit /usr/local/Cellar/mysql//homebrew.mxcl.mysql.plist and replace --bind-address=127.0.0.1 with bind-address=*.
MySQL has an internal firewall of users/IPs. Even if you can connect locally, you might not have permission remotely:
Try this as root user on the MySQL server (locally first!)
GRANT ALL ON <db>.* TO '<user>'#'<remoteIP>' IDENTIFIED BY '<password>';
Where
<db> is the name of the DB
<user> is name under which you connect
<remoteIP> is your external office IP FROM which you are trying to connect
<password> should be self-explanatory!
This will explain the options better
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.
I have created a VM with all the specs from this post to a T:
http://azure.microsoft.com/blog/2014/09/02/create-your-own-dedicated-mysql-server-for-your-azure-websites/
The one item that I have not completed "sudo ssh -fNg -L 3307:127.0.0.1:3306 azurevmuser#servername" I am not sure what to put for "azurevmuser#servername" Should this be a user on my server or a mysql?
I also I would like to run it at 3306 I believe I would just make it "3306:127.0.0.1:3306"
Also I have created the endpoints in Azure so 3306 is listed as the mysql post on private and public.
My current error in workbench is cannot not connect. I have added my user with a wild card "%" I believe I am just fuzzy on the port binding and is that necessary every time i need to connect a port to the outside world.
I had the same issue once and got around it by using the Standard TCP/IP over the SSH option in connection mode.
Simply provide your SSH username and password or specify a SSH key file, if you are using one instead of a password, along with your MySQL credentials.