Unable to connect to MySQL in CentOS VM from the host Windows machine - mysql

I wanted to test my eJava application in CentOS, so I installed CentOS 6.5 in Oracle Virtual box locally in my laptop (Windows 8.1). I configured the network in the virtual machine and it is able to ping google.com as well as the host windows machine. I then installed MySQL in the CentOS VM and modified the my.cnf to edit the bind-address. Also updatd the iptables to allow input and output connections. I tried connecting to the databse from the windows host using the command
mysql -u supplychain -h 10.0.2.15 -P 3306 -p
where 10.0.2.15 is the ip address of the centos VM. I am getting the error
ERROR 2003 (HY000): Can't connect to MySQL server on '10.0.2.15' (10060)
If I run the same command in the centos host it logs into the MySQL. Any idea how this can be fixed? I already confirmed that skip-networking is removed from the my.cnf.

Related

Django - Connection refused mysql on ubuntu subsystem windows 10

I'm using xaamp for MySQL DB and I run my server on both cmd and ubuntu subsystem but my ubuntu says
django.db.utils.OperationalError: (2003, 'Can't connect to MySQL server on '127.0.0.1' (111 "Connection refused")')
The reason is SubSystem Ubuntu is in another network layer. So those cannot connect.
Connecting to Windows network applications/servers from Ubuntu in WSL2
WSL2 is actually running on a separate, virtualized, NAT'd network from your Windows host. As such, you need to determine the proper IP address to use for the Windows host in order to connect to it from the WSL2 network.
Assuming a default WSL/Ubuntu installation on a supported Windows release, mDNS is usually the best option.
The mDNS name of your Windows host that you can use from within Ubuntu will look like:
MyComputerName.local
As long as you haven't changed the DNS resolver from the WSL default, that will be the same as what you see when you run hostname in Ubuntu.
You can determine this programmatically by:
Obtaining the hostname in your programming language / environment
Appending .local
For instance, in Bash, to connect to a Windows MySQL server:
Install the MySQL client in Ubuntu:
sudo apt install mysql-client
Connect to Windows MySQL server via "$(hostname).local":
mysql --hostname=$(hostname).local --user=me -p mydb
Reference: https://askubuntu.com/questions/1411512/how-to-connect-local-windows-applications-like-conda-and-mysql-from-ubuntu-on-ws

Problem with remote connection to MySQL database (Error 1045)

I installed MySQL Server 8.0 on Windows Server 2019, during installation I created user 'superna' # ' %' with DBAdmin rights. When connecting from a local machine, there are no problems (mysql -u superna -p), but when trying to connect from a remote machine (mysql -h 10.165.1.20 -u superna -p), error 1045 is returned.
I checked the availability of port 3306 using nmap, port is open.
When installing mysql server on Windows 10, such problems are not observed, the connection from the remote machine works correctly. Can you tell me what point in the settings I might be missing?
Can you confirm if your my.cnf file have this line? If it hasn't, add it and restart mysql.
bind-address = 0.0.0.0
Problem solved. The server was configured to NAT port 3306 to another machine on the network.

How can I connect to Mysql of my of my local from the EC2 ubuntu system?

I am having mysql server in my premise which is running on windows. Now I want connect this mysql database from an ubuntu ec2 instance but it is giving can't connect to mysql server at my IP (110 connection error)
Can some one help me to connect from ubuntu to my local window.
For your info: I am not able even ping from ubuntu instance to my local IP
Add MySQL IP on EC2 security group and port will be 3306
then
Use the below command to install the MySQL client on your ec2 instance.
sudo apt install mysql-* -y
after installation of mysql on ubuntu try to connect with the MYSQL using below command.
mysql -h hostname -u username -p password -P Portno
Hope so this will help you.
In able to connect to an MySQL server exists in EC2 instance you should provide some main parameters like:
Connection Method: Standard TCP/IP over SSH
SSH Hostname: the public ipv4 address of your EC2 Ubuntu instance
SSH Username: ubuntu
SSH Key File: your AWS credentials (key pair) file
And enable rules for connecting to MySQL server in your SecurityGroup:
(TCP on port 3306).
and you should be able to connect smoothly.
And for more information refer to this link:
reference

Connecting to a MySQL Server over WAN

I have setup a MySQL 5.6 Server on an Ubuntu 14.04 Server distribution on Virtualbox, and am trying to connect to it via TCP/IP from the host Linux Mint 17 Desktop OS over the WAN.
Connection through the MySQL client on the VM works fine, but whenever a connection is attempted from the host machine (via mysql-client-5.6 package) an error comes back with one of 2 errors:
INPUT: $ mysql -u client -p
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
or
INPUT: $ mysql -u client -p protocol=tcp -h 127.0.0.1
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)
Server Setup:
Fresh Ubuntu 14.04 Server installation with only mysql-server-5.6 and openssl packages installed from Ubuntu APT repository.
Users created are 'root'#'%' and 'client'#'%', both with full privileges given to them.
Iptables was modified to try and fix the issue (it came completely stripped) and shows: accept tcp connection from mysql and shows:
target: ACCEPT prot: tcp opt: -- source: anywhere destination: anywhere tcp dpt:mysql .
Configuration file "/etc/mysql/my.cnf" was hardly touched, only tried to change bind-address to values 127.0.0.1 , 0.0.0.0 , commented : all unsuccessful. Server and Client socket is set to 3306.
"service mysql status" returns output: "mysql start/running, process 10650"
Checked that tcp port 3306 is being listened to through "netstat -tulpn" command. returns output: PID=tcp6 Local Address=:::3306 Foreign Address=:::* State=LISTEN .
Client Setup:
Installed package mysql-client-5.6 from Ubuntu APT repository
All configurations are preset and untouched.
Would like an affirmation on the following: Was getting the idea that connecting through Unix socket is only possible through the OS hosting the server (internally), while any external OS has to use TCP/IP and so I tried the "protocol=tcp" bit in my 2nd input.
Was searching for a solution for over 2 days now, starting to feel really frustrated. Any useful help would be greatly appreciated!

How do I connect to my local MacBook MySQL form Vagrant VM Box?

I've set up Vagrant VM, it's working well for me.
Local MySQL is working good too when connection via localhost.
But I can't find a way how to connect via vagrant to macbook local MySQL.
The only visible IP to my vagrant is my local IP address of macbook: 10.0.0.4
It pings it, but this IP is not answering any requests to port 3306, though my.cnf config is set to:
bind-address = 0.0.0.0:3306
and Mac firewall switched off for a test.
I'm not sure what info to provide, let me know in comments and I will expand my question.
Thanks a lot
In terms of being able to access the instance of mysql running on your VM's host machine, you can use the ip that vagrant uses for its natted interface.
mysql -uroot -h 10.0.2.2
If you've configured a bridged interface for your vagrant machine then you can use the ip that your host has on the interface that you have bridged to with vagrant.
I've tested this with the brew installed version of mysql and it works when the mysql server on the host is bound on 0.0.0.0 or 127.0.0.1, i.e. mysql.server start --bind-address=127.0.0.1
You can connect from your vagrant box to local mysql using
mysql --host=10.0.2.2 -uroot -p