Problem:
Using mysql -u -h -p I can connect with localhost but cannot connect with external IP
I check connection for both localhost and external IP where MySQL is installed
What I have set up:
user with host as % (accepts everything)
granted user with host as % (all privileges)
flushed privileges
restarted mysql
checked tablesip and ufw
Any help would be appreciated :) 3 days and counting.
Comment the bind address 127.0.0.1 in mysql configuration file on your remote server.
Generally the file is located at /etc/mysql/my.cnf
on ubuntu system.
EDIT: Restart MySql after done.
Success! Oh my gosh.. there we're two bind address I had to comment out!!
So what I did:
netstat -l Checks to see what IP MySQL is listening to
Checked my.cnf and other linked cnf files
Commented out second bind-address
Done!
Related
I'm trying to make a MySQL database on my Raspberry Pi 4, but it isn't going very well, using localhost instead works perfectly but I want to remote control it from my Windows 10 computer on the same internet. When I create a user with the address of 192.168.1.15 by doing this:
sudo mysql -u root
CREATE USER 'lasse'#'192.168.1.15' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'lasse'#'192.168.1.15';
FLUSH PRIVILEGES
exit
I try to login again using this:
mysql -u lasse -h 192.168.1.15 -ppassword // didnt work, error: ERROR 2002 (HY000): Can't connect to MySQL server on '192.168.1.15' (115)
mysql -u user -h 192.168.1.2 -P 3306 -ppassword // didnt work either, same error.
I have these packages installed:
mariadb-client
mariadb-server
default-mysql-server
In the file /etc/mysql/mariadb.conf.d/50-server.cnf (Raspi-os 2021-03-04 with MariaDB installed), you should replace the line "bind-address = 127.0.0.1" (localhost) by "bind-address = 0.0.0.0" (all). After, you should restart your MySQL server : $ sudo service mariadb restart
Error 115 is returned from socket operation (EINPROGRESS), which means that your client can't physically connect to the specified server and port.
The MariaDB database server is not configured correctly, since it doesn't accept remote connections. Please login locally and check the following variables:
SHOW VARIABLES LIKE 'skip_networking' (result should be off)
SHOW VARIABLES LIKE 'bind-address' (should not be 127.0.0.1)
Since these are read only variables, you need to change them (or comment them out with a #) in your my.cnf configuration file.
ERROR 2002 is "Can't connect" error. Check out /etc/my.cnf, look for listen line. It may be listening localhost or 127.0.0.1. You need to change it to listen 0.0.0.0.
There are three things
You need to set the bind-address to 0.0.0.0 (or 192.168.1.15 to be exact and specific)
You might need to set the firewall to allow port 3306 ( or iptables --flush as shortcut )
You need to create a global user (root#'%') in the mysql database or some user like 'root#192.168.1.15' with a password
when all conditions are fulfilled, you should be able to connect to mysql database on 192.168.1.15
What is most likely the case is that the server is not listening on port 3306. As in both lines you implicit or explicit use port 3306. As it is the only constant in the two lines most likely the culprit.
The default port for clients is specified in my.ini in the [client] section, the port used by the server is in the [mysqld] section. They don't necessarily have be the same so check both.
To make absolutely sure what is going on the server — assuming it is linux — use this to list all listening ports:
sudo netstat -tnlp
There, saved you a walk to the docs.
Login to the MariaDb server and edit the file /etc/mysql/my.cnf
Edit the row bind-address=YOUR_SERVER_IP
Restart the server using '/etc/init.d/mariadb restart' or 'systemctl restart mariadb.service'
My mysql server is installed in Ubuntu 16.04
I used mysql -h 192.168.1.3 -u username -p then following error shows
ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.1.3'
(10061)
I tried to comment the bind-address, it didn't worked.
Thanks in Advance
192.168.1.3 is local ip address, you might not be connected to same network. You need to access it through public ip address. You might also need to create one user and grant permission to that user to access it from outside.
This worked for me:
Out of the box, MySQL will only allow access from the localhost address 127.0.0.1. To change this, you need to open the /etc/mysql/mysql.conf.d/mysqld.cnf file and change the line:
bind-address = 127.0.0.1
to:
bind-address = 0.0.0.0
Save and close that file. Restart the MySQL server with the command:
systemctl restart mysql.service
here is the source : solution
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'm currently trying to setup a remote connection to a mysql database. I've done this before, and wrote down some steps to follow for next time, but I can't seem to get this one working. Here's the process I've taken so far.
For the purposes of this question, we'll say that my DB is at ip 100.100.100.100 and the remote host I'm trying to connect from is 100.100.100.200.
Ubuntu Server using Mac OSX terminal:
MySQL is installed, and I've logged in as the root
I've edited my /etc/mysql/my.cnf file to look like this
bind-address = 100.100.100.100
there is no --skip-networking field in my file
Restart mysql
create a new user and grant privileges
CREATE USER 'user1'#100.100.100.200
GRANT ALL ON . to 'user1'
then I update the iptables
/sbin/iptables -A INPUT -i eth0 -p tcp --destination-port 3306 -j ACCEPT
after all this is finished, I log out of mysql, and try to connect from the remote server with the new user
while on ip 100.100.100.200
mysql -h100.100.100.100 -uuser1
and I get this error message
ERROR 2003 (HY000): Can't connect to MySQL server on '100.100.100.100' (110)
is there something I've missed in the process, or could it be something with the servers firewall? I've been scouring the internet for hours trying to figure this out, so the next step was to ask a question. Thanks in advance for any help you can give!
Man that was a pain.
The problem was in the iptables. I simply restarted the server and re-ran the iptable command.
Restarting the server clears all the iptable rules unless they have been explicitly saved.
Here's the resource I used to find out more about iptables.
https://www.digitalocean.com/community/articles/how-to-set-up-a-firewall-using-ip-tables-on-ubuntu-12-04
sudo reboot - restart the server
/sbin/iptables -A INPUT -i eth0 -p tcp --destination-port 3306 -j ACCEPT - add rule to iptables
Not sure what was going wrong, but after a restart and a reinsert of the rule, everything worked like a charm.
I have a unix server with mysql which I am trying to access from my machine. To clarify, access the mysql server. When I do I get this error.
Connecting to MySQL server 192.168.1.25...
Can't connect to MySQL server on '192.168.1.25' (10061)
Here are my credentials:
username: root
port: 3306
The server is running because I am able to remotely login onto the machine (with ip: 192.168.1.25" and then run mysql from root. What do you think is going on:
Is it a firewall issue?
Accessing as 'root' is being denied?
I am new to mysql.
1)
check the logs
you can see where the logs are by checking the my.cnf file.
mysqld.log might be the file name, but where
2)
a. see if it's a network issue.
telnet 192.168.1.25 3306
b. see if the service is at that port.
ssh to the box
# from the local host
mysql -u root
telnet 127.0.0.1 3306
ps auxw|grep mysql
you should hopefully have enough diagnostic info at this point to figure it out.
Probably because remote root login is not allowed. You can try this article on how to enable remote root:
http://benrobb.com/2007/01/15/howto-remote-root-access-to-mysql/
i have this problem and fix it by
first you must grant all to user
GRANT ALL PRIVILEGES ON databasename. TO 'user'#'%' IDENTIFIED BY 'password';
then
FLUSH PRIVILEGES;
and change the mysql config using
sudo nano /etc/mysql/my.cnf
find "bind-address" row and comment it.
save config and restart mysql using
sudo /etc/init.d/mysql restart
hope solve problem :)
The Message (10061) is do to offline severs or firewall blockage
If you get -the name of your pc - can not connect, then mysql is rejecting the connection and you will have to create a 'user' in the mysql database mysql, table user using the IP of the remote connection', and restart the database service
but for error 10061 check The Firewall in both machines.
Masters PC per say, is the one with the phpmyadmin installation
Allow Destination ip-[the remote] and port 3306 on the Master Machine
and
Allow source ip-[the masters]/with any port, and check your destination port(3306) too. destination ip can also be set on some firewalls.
And if you can, search in your firewall for logs, settings, recent activity, etc... to see what and how you are being blocked.