Django - Connection refused mysql on ubuntu subsystem windows 10 - mysql

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

Related

I cant access my mysql server hosted on azure from remote

Good evening all, i have set up an azure server with ubuntu server and have installed MySQL with some python code I need to run , I have turned off the firewall on Ubuntu and setup port forward on azure and i still can not connect to MySQL from my pc using workbench, I installed PHPMyAdmin as well and I was not able to connect to that either, I am not sure what else I can try, I have started setting up a new server on a local pc but I would it on the cloud
I created a Linux (ubuntu 18.04) VM ,set up a mysql on it and access it on my local successfully. This is my steps below :
1.Enable 3306 port on Azure portal :
2.Connect to Azure VM , and run command below to install mysql :
sudo -i
apt install mysql-server
3.After your mysql is installed , modify “bind-address” directive in /etc/mysql/mysql.conf.d/mysqld.cnf , modify 127.0.0.1 to 0.0.0.0 to make sure your mysql server will listening on all your VM's ips :
vim /etc/mysql/mysql.conf.d/mysqld.cnf
save your modify and restart your mysql server :
systemctl restart mysql
This time , can ping 3306 port of my vm successfully :
If your mysql server is running on your VM successfully , but you can not ping it,if the error info is timeout , pls check your firewall settings , if the error info is remote server refused your request , this means there is no service listening on 3306 port.
4.Create a user on mysql so that we can use this account connect to mysql from local:
CREATE USER 'stan'#'%' IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON *.* TO 'stan'#'%' WITH GRANT OPTION;
Well , try to connect to mysql from local using navicat :
Connect to mysql on Azure Linux VM from local successfully :
Hope it helps .

Mac OS Yosemite : How to start mysql and connect Sequel Pro?

I have just installed MySQL using the installation documentation.
MySQL is installed in the directory /usr/local as indicated in the documentation.
I attempted to start MySQL using the following command on the command line:
/Library/StartupItems/MySQLCOM/MySQLCOM start
Is it normal that I did not receive a message in the terminal that MySQL has started.
Where is the configuration file location (where do I find the root user account)?
After running the MySQL start command, I launched Sequel Pro, but I cannot connect to 127.0.0.1. How can I connect to this? Here is a screenshot of what happens when I attempt to connect:
I would just like to to start mysql and connect a gui client, what am I missing?
you need to be root to start the service.
type sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
MySQL is configured to listen to port 3307 when installed on Yosemite. After you verify that effectively you started the service, change the Port parameter on your Sequel Pro access window and try again.

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

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.

nitrous.io and mysql workbench

I've installed MySQL using the instructions on nitrous.io using autoparts. Once installed and running, is it possible to use your local MySQL workbench to connect to the MySQL Server installed on that nitrous.io environment?
So you could ssh into your nitrous.io box from your local machine, but can you do the same and connect to MySQL using your local machine? If so, what credentials would you use?
You can use MySQL Workbench and other apps if you establish SSH tunneling with your Nitrous box. Run the following command in your Unix console, replacing the variables with the actual values found on your boxes page:
ssh -N -p <box_port> action#<box_host> -L <local_port>/localhost/<remote_port>
From there you can open up MySQL Workbench and connect to host 127.0.0.1 on port 3306. You will also need to ensure your MySQL database on Nitrous is running. Run parts start mysql to start up the database.
Take a look at the Nitrous.IO guide for a complete walkthrough.

Having issue accessing mysql server from other machine

I have installed mysql server and workbench on a machine that is running on Ubuntu Linux platform.I also have installed mysql server and workbench on my machine that is running with Windows 7 OS.Both the machine are connected to network.I want connect to the mysql server from my machine.i tried changing the bind address of mysql server according to the machine's ip, and gave that ip as host name while connecting through mysql workbench from my machine.But i am not able to connect successfully.Please Help
Well, IMHO, the only problems that could be are ither:
Username does not have enough priveleges
Server does not accept connections
Firewall Blocking port
You should investigate each of these cases