mysql fails to allow remote connection - mysql

I have followed the steps here:
ERROR 1130 (HY000): Host '' is not allowed to connect to this MySQL server
Carried out this activity dozens of times and it worked -- now for some reason it is not
I have done:
Comment out bind-address in my.cnf and restart service
GRANT ALL PRIVILEGES ON . TO 'root'#'%';
FLUSH PRIVILEGES;
The only difference here is that MySQL is running in a VM under VirtualBox and I am connecting to the VM mysql instance via WIndows 7.
SSH and other services work fine...
The passwords are fine as they work when I connect via SSH...
My new modem/router possibly at fault, blocking outgoing or ingoing connections on port 3306???
I assume that traffic from a host to guest still goes through the router...but the thing is...my requests are certainly making to the MySQL server as the log file shows fail requests...
WTF amm I missing???
The error I receive: Error No. 1045
Access denied for user 'root'#'my-desktop' (Using Passowrd: YES)

You also have to edit my.cnf. Change:
bind-address = 127.0.0.1
to
#bind-address = 127.0.0.1
then restart mysql. Also, if you are going to allow outside access, create a user other than root. That's always a bad idea.

By default connection from outside are not allowed for security reasons.
Because exposing your database to the public internet is never a good idea, you will need to whitelist the IP address manually to allow connection.

Related

connecting to MySQL server 8.0 from remote network (windows 10)

I want to have a database on my laptop and grant permissions and access to my friends so they can read/write from their home. What I have done so far:
Downloaded MySQL on both devices
set up user and granted permission on the local server using
CREATE USER 'MyUserName'#'%' IDENTIFIED BY 'MyPassword';
GRANT INSERT, SELECT ON *.* TO 'MyUserName'#'%';
FLUSH PRIVILEGES;
tried finding bind-address from my.ini file but there was no such line. I ran
show global variables like 'bind_address'; and I got the value * so I guess it allows remote access.
Restarted MySQL80 service on both devices
Checked that inbound firewall rules allow access to port 3306 (MySQL had already set a few rules so I left them as is)
Tried connecting from remote server using MySQL shell (i got the public IP from icanhazip.com)
\connect MyUserName#<public IP for my server 92.-.-.->
It prompts me for the password but after I enter it I get
MySQL Error 1045: Access denied for user 'MyUserName'#'<the IP address>' (using password: YES)
I tried testing connection using powershell:
test-netconnection -computername -port 3306
but it says:
WARNING: TCP connect to (<IP>) : 3306) failed
WARNING: Ping to <IP> failed with status: TimedOut
I even tried testing connection on the same local computer with the same command (using the public and private IPs) and it failed. I'm not sure where to go from here. I have looked at other similar questions on stack but they all seem to be addressing one of these things that I have done.
There was one more firewall that I forgot about which was on my default gateway. To get around this it really depends on the router but what I did was:
open cmd and type ipconfig and look for Default Gateway
type that IP in my browser and log into my router
find LAN IP Setup and reserve my IP for my device
find the security options and firewall rules and have allow inbound and outbound rules to my private IP and forward the port.

Access Denied for User 'username'#'IP' error - digtal ocean

I've currently set up a staging area for my app in Digital Ocean with LAMP stack. The Framework for my app is Laravel 5.5 and Vue 2x.
In development, I've been using remote MySQL and had no issues with the connection error. However, when I moved it to the staging env, it is giving me access denied error. When I looked at it closely to the error log, Access denied is for username#[digital-ocean-droplet-ip], whereas I have properly configured the MySQL credentials to the remote host IP under laravel's config/database file.
So, I am doubtful if I have to do any configuration under Apache to allow any external MySQL connection? I forgot the cmd but I did allow sfw firewall allow to any port 3306 to the remote server IP address in Apache.
Any help is appreciated.
Thanks!
MySQL by default does not create an user with access from remote connections.
First you need to create an user on database that allows connection from outside (%) or a specific IP
CREATE USER 'newuser'#'%' IDENTIFIED BY 'password';
Than give him privileges
GRANT ALL PRIVILEGES ON *.* TO 'newuser'#'%';
The *s could be replaced by your database and table name respectively
You might also check if in your mysql configuration(/etc/mysql/mysql.conf.d/mysqld.cnf in my case) has this line uncommented
bind-address = 127.0.0.1
Change the ip if necessary
restart mysql and apache
sudo service apache2 restart
sudo service mysql restart
Than update the user and password at your .env file and try again!

MYSQL Remote Connection Coda 2

I just bought Coda 2 and I want to try this feature about mysql database connection. I´m not able to connect. The error that appears is:
Unable to connect to host 1.2.3.4, or the request timed out.
Be sure that the address is correct and that you have the necessary privileges,
or try increasing the connection timeout (currently 0 seconds).
MySQL said: Can't connect to MySQL server on '1.2.3.4' (60)
The error takes 60 seconds to appear. For easy answers, Il´l make an example:
Server IP: 1.2.3.4
MYSQL Username: root
MYSQL Password: 1234root
I use xampp on a windows server. How can I connect to the mysql database remotely? About the privileges, the account I use for root has all privileges. Thank you and have wonderful holidays.
You need to configure your mysql server to allow remote access to root, usually a very bad idea. Remote access is bad enough. You would need to permit remote access and grant the root user at your remote address access.
see Enable remote MySQL connection: ERROR 1045 (28000): Access denied for user
This is why people usually install something like phpMyAdmin to get this kind of access. Setting up a non root user is another choice.

Remote MySQL access not respondto MySQL client

I have a remote Server which is running mysql. I have enabled remote access by changing the bind address to the public ip, and commenting the "skip-networking" line. I then used ufw (ubuntu firewall) to open the mysql port 3306
However my client times out when trying to connect to the server. So I test the connection with telnet, and I get the expect response, the same as I get on the local server.
I'm getting no errors, and no response when using a mysql client, but access would appear to be there in telnet.
Can anybody suggest what I've missed?
Thanks
If its not a firewall issue then maybe its a permission problem , try this for the user you use to connect from that host:
CREATE USER 'user'#'host' IDENTIFIED BY 'pass';
GRANT ALL on *.* to 'user'#'host';
FLUSH PRIVILEGES;
UPDATE:
Also check the bind-address from my.cnf file
For example, if you bind to 0.0.0.0, you can connect to the server
using all existing accounts. But if you bind to 127.0.0.1, the server
accepts connections only on that address. In this case, first make
sure that the 'root'#'127.0.0.1' account is present in the mysql.user
table so that you can still connect to the server to shut it down.

How to determine who is trying to access MySql

When I check the mysql query logs on our BSD server, I see, repeated again and again:
111123 8:23:11 4478 Connect Access denied for user 'Neohoo'#'localhost' (using password: YES)
4479 Connect Access denied for user 'root'#'localhost' (using password: NO)
I shut off outside access by adding the skip-networking option and restarting mysql:
cat /etc/my.cnf
[mysqld]
// The MySQL server
skip-innodb
max_connections=30
skip-networking
set-variable=local-infile=0
And verified by:
telnet bsdServer.com 3306
telnet: Unable to connect to remote host
The MySql is used with a legacy PHP application. I considered it could be an SQL injection attack but I am at a loss to find which section of the program. The mysql query logs do not show an IP address or any more useful data.
Any suggestions appreciated.
I shut off outside access by adding the skip-networking option
But these users are connecting from localhost - i.e. not across the network.
The mysql query logs do not show an IP address
Yes they do:
111123 8:23:11 4478 Connect Access denied for user 'Neohoo'#'localhost' (using password: YES)
Some client running on the machine is trying to connect.
If this machine is running a PHP webserver, particularly one facing the internet, most likely have a PHP code injection issue. Try cross referencing the timestamps on the log entries with your webserver access_log. If you've got the mysql client available on the machine, ensure that your webserver uid can't run it.