I recently installed a LAMP stack on an ec2 instance that's running Ubuntu Linux. I followed the instructions found here. I also installed phpmyadmin. To the best of my knowledge, while I was installing MySQL, I answered no when prompted to answer the question Disallow root login remotely? I could be mistaken though. I've read elsewhere that in order to allow root login remotely, I would need to edit the mysql .conf file found in the /etc folder somewhere and edit the bridge setting.
I've tried connecting by doing the following:
$con = mysqli_connect('ec-2 ip address', 'root', 'root', 'db_name');
if(mysqli_connect_errno($con)) {
echo mysqli_connect_error($con);
die;
}
This is the error message I get when I connect:
Can't connect to MySQL server on '54.201.165.105' (61)
I ended up answering this myself after just doing a little bit of research. Turns out that the security groups pn AWS had nothing to do with the problem. I had to go to the file at /etc/mysql/my.cnf and comment out the line that read bind_address = 127.0.0.1. Then I had to execute an SQL statement in phpmyadmin that went like this
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
Thanks for all of the help though, guys. I appreciate it.
You need modify the AWS Security Group for the instance and set firewall rules to allow 3306 inbound traffic as well as modify the OS firewall rules to allow the same traffic.
Related
I am trying to set up a database for a class project and we are using MySqlWorkbench 8.0. I am able to set up a database and connect to it locally but I cant seem to get remote connections to work. I have already researched the problem and here are a list of things I've already tried. (I am using windows 10)
I have looked at the my.ini file for the bind-adress property as this seemed to be the most common problem but it isn't even in the my.ini file.
I have added a user using this query to grant permission for others to connect using other ips
CREATE USER 'USER'#'%' IDENTIFIED BY 'PASSWORD';
GRANT ALL PRIVILEGES ON *.* TO 'USER'#'%' WITH GRANT OPTION;
FLUSH privileges;
I have tried disabling my firewalls as well as just allowing connections to port 3306 to no avail
Anything would help. All of the answers i found online were outdated or pertained to the bind-adress which i cannot find in the my.ini file
Hmm, Let double-check these points: but this's NOT a problem of MySqlWorkbench
Same as you did so far. Update bind-address to 0.0.0.0 which accept all
Yes, It's same but double check by select user, host from mysql.user;
NO disable the firewall, add TCP port of mysql
If you're using a cloud server you have to add MySQL port in network policy setting, if you're using LAN you may need to open port in the gateway
When you make sure all work then I belive that you can connect via command line or MySqlWorkbench or any SQL Tools which support MySQL.
I have a MYSQL server running on my Windows 7 and I need to access it from a Debian VM but when I try I get this error :
ERROR 2003 (HY000): Can't connect to MySQL server on 'xxx.xxx.xxx.xxx' (110)
I checked in my.ini and there is no sign of "bind-address" parameter around so I just can't figure out where the error is.. I can perfectly manage it locally from my Windows. My company is using a proxy but as my VM is on my machine it shouldn't block anything there..
Thanks for your help !
You need to change user host adress as * or given xxx.xxx.xxx.xxx IP.
Look at here: grant remote access of MySQL database from any IP address
To access MySQL from outside. you should enable MySQL remote access .
1- Comment out following lines in Mysql Config(my.cnf/my.ini(for windows))
#bind-address= 127.0.0.1 (if not exist add it and then comment out)
#skip-networking
2- Save the file and restart Mysql server
3- Update GRANT privilege
By default, mysql username and password you are using is allowed to access mysql-server locally. So need to update privilege.
Run following query to update privilege
GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'#'%' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
Change the 'USERNAME' to your Database user and 'PASSWORD' to User Password
You should check that:
"bind-address = 0.0.0.0" is present in your my.cnf
The user your are using has remote access (not just 'locahost')
Check that MySQL port (usually 3306) is opened if you have a firewall running
I would really advice to create a specific user for remote access with limited rights.
Finally I uninstalled everything and trieed again and it worked so now I close this ticket for good.
Thanks to those who have tried to help me !
I have mysql installed in an instance of google compute engine. I am able to connect to it via the shell however I want to use the MySQL workbench.
Is it possible to connect to it? I cant seem to make a connection.
Any help is appreciated,
Thanks!
Not sure if your shell is run local on host via ssh, so it's just a guess that your mysql Server is just accepting connections from localhost.
To change this open your my.cnf File (on Debian Systems saved in /etc/mysql/my.cnf) and comment the folloing Line:
change:
bind-address =127.0.0.1
to:
#bind-address =127.0.0.1
Be sure also to allow root connection from outside, modifying MySQL user table :
GRANT ALL PRIVILEGES ON . TO 'root'#'%' IDENTIFIED BY 'password';
SOehl's answer can be correct, however I did not comment. Instead i changed it to bind-address 0.0.0.0.
I want to create my own RDBMS server with remote access, which I can access and query from any computer over the internet connecting using ip address of my host pc. I installed MySQL edited my.cnf and commented the bind-address and then using MySQL Workbench connected to 127.0.0.1 i queried grant all ip address for all the databases.Then i tried connecting from another pc with my host ip address.But unfortunately it didn't connected.I even opened port through firewall but still. It didn't work. M now a lot messed up.Can you please help me to guide how do i start to create my own RDBMS server which I can access from anywhere. Or any guide. I basically want to host MySQL on my ip address which can be accessed from anywhere.
P.S. Please don't tell me about security flaws it can have.I totally considered and understood it. M trying to make project for my college.And security is not at all an issue as i have a separate old PC for server.
Thank you
If your issue is not able to remotely connect to MySQL, then try below steps. I had the same issue and got it resolved by performing below commands.
1) sudo nano /etc/mysql/my.cnf
2) # bind-address = 127.0.0.1 // comment this line out
bind-address = 0.0.0.0 //add this line just below above line
3) sudo /etc/init.d/mysql restart //restart mysql
4) sudo mysql -u root -p //login to mysql cli as user 'root'
5) GRANT ALL PRIVILEGES ON *.* TO 'root'#'%' IDENTIFIED BY 'beta' WITH GRANT OPTION;
Here 'root' is the mysql user and 'beta' is the password and here privileges are set for 'root'.Change it accordingly and execute above query in mysql cli.
Good Luck !!!
If in
/etc/mysql/my.cnf
It has the following line
!includedir /etc/mysql/mysql.conf.d/
Then make the changes in
/etc/mysql/mysql.conf.d/mysqld.cnf
I have my dev environment set up as a Ubuntu Server (with LAMP installation) inside a vmware. The vmware is running on my local windows 7 machine. When I try to access my mysql server via HeidiSQL program the connection fails. I get a:
Server Error 2003, can't connect to mysql server on <IP ADRESS HERE>
I can however access the db server via PhpMyAdmin. MySQL is running and my connection credentials and port are all correct.
I read that you should enter the IPs of the computer you are trying to connect from as the "bind address" in the my.cnf file. Which I did. I tried both the internal network IP as well as the online IP. Still no luck, same message.
Since this isn't a production environment I would ideally like to allow anyone to access that server, not limit it by IP. Especially since my ISP assigns dynamic IPS. So I would have to change it all the time, assuming that even works.
So does anyone know how I can connect to my MySQL server from a remote computer?
P.S. I assume this is something developers have to deal with that's why I posted it here and not Super User. If it must be migrated please send it to Server Fault not Super User.
Ok, be aware this gives the world and his dog access to your mysql server.
GRANT ALL ON *.* to '%'#'%' WITH GRANT OPTION;
But say you are on your home network of 192.168.1.2/16 then you can at least limit it like this.
GRANT ALL ON *.* to '%'#'192.168.%' WITH GRANT OPTION;
Another option is that you have a user and password but want to connect from anywhere
GRANT ALL ON *.* to 'mysecretuser'#'%' IDENTIFIED BY 'mysecretpassword' WITH GRANT OPTION;
first check the ip assigned to vmware using from cmd
ipconfig/all
suppose ipassigned to vmware is 192.168.11.1
now in vmware in ubuntu check the ipadress
ifconfig
suppose ip adress of ubuntu is 192.168.11.137
now open mysql configurations
sudo nano /etc/mysql/my.cnf
change the bind address to ubuntu ip address
bind-address = 192.168.11.137
restart mysql
now connect to mysql
mysql -u root -p
and create a user with all privileges and host ip of vmware i.e 192.168.11.1
GRANT ALL ON db.* TO user#'192.168.11.1' IDENTIFIED BY 'PASSWORD';
now try to connect from windows.
also open port of mysql
/sbin/iptables -A INPUT -i eth0 -p tcp --destination-port 3306 -j ACCEPT
restart mysql and try to connect on ubuntu host ip address 192.168.11.137
For Heidi SQL I was able to get it to work following the instructions on this article:
http://mysql-tools.com/en/articles/http-tunnel/73-heidisql-a-http-tunnel.html
It uses a program called HTTP Tunnel. It's a lot slower but at least it works. If you use Navicat it comes with a PHP file that you can upload to your server and it will connect via that.