error message while connecting to phpmyadmin - mysql

i can't connect to PhpMyAdmin on my local server as shown bellow, it shows me the message "#1130 - Host 'localhost' is not allowed to connect to this MySQL server", i think the problem is with MySql, someone can help pleas ?

try given link
#1130 - Host ‘localhost’ is not allowed to connect to this MySQL server

This sounds like it might be an IPV4/IPV6 issue. Modern browser will use either, why the decide to use IPV4 or IPV6 address ranges, I dont know yet.
You can test this theory by launching phpMyAdmin like this 127.0.0.1/phpmyadmin if that works and ::1/phpmyadmin does not, then the problem is probably related to phpMyAdmin not being allowed to be run from the ::1 IPV6 address.
First make sure you have these entries in your HOSTS file \windows\system32\drivers\etc\hosts
127.0.0.1 localhost
::1 localhost
These entries will associate the domain name localhost with both the IPV4 (127.0.0.1) and IPV6(::1) loopback ip address's i.e. connect to this machine when you see the domain name localhost.
If you have to change the HOSTS file you then need to reboot or run these 2 commands from a command windows that is started using "Run as Administrator" to refresh the dnscache and pick up your changes.
net stop dnscache
net start dnscache
Next check the Alias settings for phpMyAdmin.
Edit the \wamp\alias\phpmyadmin.conf file.
Make sure that both 127.0.0.1 and ::1 are allowed to connect to Apache
If you are using Apache 2.2.x then look for this section and make sure it contains this in the Allow from line
Order Deny,Allow
Deny from all
Allow from localhost ::1 127.0.0.1
If you are using Apache 2.2.4 then look for this section and make sure it contains this in the Require line. If you still have the old Apache 2.2 syntax in here, remove it and use this instead.
Require local
The Require local covers both localhost, 127.0.0.1 and ::1 in Apache 2.4

I would help, but I can't read the text in your image and there is no code either.

Related

Cannot connect to MySQL installed on GCP Virtual Machine

I've installed MySQL on a Google Cloud Virtual Machine (debian buster). What I want to do is to make this accessible publicly (using username / password obviously).
As far as I can tell the server is visible from the outside world, as I can ping the IP and I get results, and I think I've set up a user correctly and given the appropriate permissions so I can log in.
For info, my firewall settings on GCP look like this (this is just the egress, there is one exactly the same for ingress):
Which I'm assuming is correct and leaves the correct port open?
The issue I have when I use MySQL Workbench is that when I try to create a new connection, it gives me the following error:
Your connection attempt failed for user 'username' to the MySQL server at [my ip address]:3306:
Unable to connect to localhost
Please:
1 Check that MySQL is running on address [my ip address]
2 Check that MySQL is reachable on port 3306 (note: 3306 is the default, but this can be changed)
3 Check the user username has rights to connect to [my ip address] from your address (MySQL rights define what clients can connect to the server and from which machines)
4 Make sure you are both providing a password if needed and using the correct password for [my ip address] connecting from the host address you're connecting from**
Any pointers would be gratefully received.
Update: What is really confusing me is the 'Unable to connect to localhost' error. I'm not trying to connect to localhost...?
Update 2: As per comments, results of the following commands:
Note I am trying to connect using the matprichardson username. The svc2toria user is pointing to my own IP address.
Mat, If you want to use your Google Cloud Instance Database using your MySQL workbench. I suggest you connect to it through an SSH tunnel. So, this problem won't happen. I also ran into this problem several times. Connecting through SSH made the job done.
But if your need is something else, this would not help you at all. If your only purpose is managing your database from your local machine using the MySQL workbench. This will work nicely. Create a USER in your Debian VM. and open port 22 to the public. Also, make sure to have strong credentials or a better key file when connecting through SSH. This method is working for every cloud VM database. I'm using this method for G-Cloud, Azure, and AWS. After all of your work is done. Close port 22 (SSH).
My best guess will be because of number 2. "Check that MySQL is reachable on port 3306 (note: 3306 is the default, but this can be changed)".
Your Virtual Machine will have network security controls / firewall which will be blocking port 3306 by default.
I don't use Google cloud but I believe you are looking for "network details" -> "Firewall rules".
did you change your mysqld.cnf already?
bind-address = 0.0.0.0
As none of the suggestions posted worked I went for the rather more nuclear option of deleting and rebuilding my VM and setting MySQL up again from scratch. I must have done something wrong in my initial setup, as things worked without any issues at all once I’d done this.
The location of the MySQL configuration file differs depending on the distribution.
In Ubuntu and Debian the file is located at /etc/mysql/mysql.conf.d/mysqld.cnf
while in Red Hat based distributions such as CentOS, the file is located at /etc/my.cnf
Open the file with your text editor :
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
Search for a line that begins with bind-address and set its value to the IP address on which a MySQL server should listen.
By default, the value is set to 127.0.0.1 (listens only in localhost).
In this example, we’ll set the MySQL server to listen on all IPv4 interfaces by changing the value to 0.0.0.0
bind-address = 0.0.0.0
# skip-networking
If there is a line containing skip-networking, delete it or comment it out by adding # at the beginning of the line.
In MySQL 8.0 and higher, the bind-address directive may not be present. In this case, add it under the [mysqld] section.
Once done, restart the MySQL service for changes to take effect. Only root or users with sudo privileges can restart services.
To restart the MySQL service on Debian or Ubuntu, type:
sudo systemctl restart mysql
On RedHat based distributions like CentOS to restart the service run:
sudo systemctl restart mysqld
For more Detail Read Here

How can I connect a Jupyter Notebook to a remote MySQL DB using Peewee?

I am trying Peewee to connect and retrieve data from a MySQL remote database, but I get the following error:
InternalError: (1130, "Host 'x.x.x.x' is not allowed to connect to this MariaDB server")
Could you help me?
"retrieve data from a MySQL remote database"
"Host is not allowed to connect to this MariaDB server"
Seem to point on a simple problem:
You're not allowed to connect on the DB from "outside".
By default, MySql / MariaDB are only listening on the "inside" of the server, from MariaDb doc :
MariaDB packages bind MariaDB to 127.0.0.1 (the loopback IP address) by default as a security measure using the bind-address configuration directive.
This mean apart for an application that run on the same machine (accessing 127.0.0.1 or localhost), you'll not be able to connect.
Solutions:
SSH tunnelling
This is probably the safest way to allow a connexion on a remote DB.
SSH is a protocol that allow you to connect to a server. It's mainly used on unix server to manage them, but can do a lot more.
How to use it in your case?
if you can connect with SSH to your DB server, then running this simple command on your notebook the will do the trick:
ssh -L 3306:localhost:3306 user#x.x.x.x
Lets explain a bit: first, your run SSH, then, you tell him to enable a port forwarding from your 3306 port to the localhost:3306 port of the server you connect through user#IP.
With this command running, every query from your local machine:3306 will by send to your MariaDB:3306 server, allowing you to use it as if you where on the server.
Allowing a remote-access user
This one is way more dangerous than the previous one. You'll need to take your time and think about every outcome it mean.
As already said, you're not allowed to connect from outside, ssh let you be "inside", but if you know what you do, you can just remove the security.
The point is:
to make an account that'll be able to login from a remote IP,
allow MariaDB to listen on external requests,
and at least, secure other account to disable remote connection.
[I'm not putting the how-to now, if you really need it, I'll update this answer]

mysql - Inability to connect using procedure that has been in place for years

I use a procedure during tax season to connect from a script on my workstation to a production mysql server. The procedure has been in use since 2007. This year I am unable to connect to the mysql server, getting "access denied for user 'xxx'#'localhost'". The command line is as follows:
mysql -u xxx -p -h ourmysqlserver
where "xxx" and "ourmysqlserver" are dummy names used for this question.
When I ping ourmysqlserver, it resolves to the expected IP on our VPN.
I would not expect 'xxx'#'localhost' to be able to connect, as there are no grants for 'xxx'#'localhost' because it is not appropriate. Rather we have always used 'xxx'#'10.8.0.%', where the 10.8.0 network is our VPN. It does not make sense to me have have localhost because that either implies I am coming in from an account on mysqlserver, or I am trying to connect to a local instance of mysql, neither of which I am trying to do.
On a hunch, I entered GRANTS for 'xxx'#'localhost'. You would think that that would then work. But that does not work either.
While this procedure has been in place a long time, over the years our DNS, VPN, mysql server, mysql client, and host server configurations have changed.
I am suspecting that there is something in the configuration of the mysql client that is forcing it to act in an unexpected way. But I would like to resolve this so as to be able to continue using existing procedures.
EDIT: I discovered that by switching the -h parameter to an IP address instead of a DNS name, that the connection can be made. It is still a mystery why the DNS name cannot be used in some place (it still works fine elsewhere) and why 'localhost' appears in the error message.
My immediate guess would be a dns vs hosts file issue. I may be that with the hosts file, it is resolving to the loopback adaptor and then when you try to do a reverse dns lookup, it comes back as localhost.
In other words, my guess is that this is what happens:
host ourmysqlserver probably resolves locally to 127.0.0.1
127.0.0.1 resolves to localhost via reverse dns
the ip address resolves to the correct hostname via reverse dns
The problem is probably in /etc/hosts

Connect MySQL through localhost not working but 127.0.0.1 is working

OS: Ubuntu 14.04 LTS
php version control : phpbrew
php version : 5.5.10
I pinged localhost which resolved to 127.0.0.1.
This indicates that my host (/etc/hosts) file is correct.
127.0.0.1 localhost
Whenever I try connecting to MySQL using a php script like the one below it doesn't work and gives me the error: no such directory.
//connect to the database
mysql_connect("localhost","root","password") or die(mysql_error());
However, when I connect via 127.0.0.1 it will work
//connect to the database
mysql_connect("127.0.0.1","root","password") or die(mysql_error());
Additionally, my phpmyadmin does not work when logging in using "localhost" i had to change the file to add 127.0.0.1 option during log on.
How can I use localhost to connect to the MySQL database?
PHP is still trying to use the default socket location. This problem can appear if you have moved the MariaDB/MySQL folder from /var/lib/mysql to another location. In order to solve the problem you have to define the new socket's location in the /etc/php.ini file.
mysqli.default_socket =/newDBLocation/mysql/mysql.sock
Watch out, depending on which driver you use, you may have to specify the pdo_mysql.default_socket=!
In order to check your current directory run the following command in mysql:
select ##datadir;
In many cases localhost is a hint to use the UNIX socket to connect to the MySQL server process, where 127.0.0.1 forces a TCP connection. Sometimes the UNIX socket is in an unexpected place, or simply isn't accessible, which results in the "file not found" error.
The socket is typically something like /tmp/mysql.sock or could be in some other place depending on your distribution and how much you've customized it.
Keep in mind that access via UNIX socket, which is local to the server by definition, and TCP are controlled by two different rules. localhost in a GRANT refers to UNIX socket. % or some specific host name refers to remote via TCP.
The answer to this problem was that in the my.cnf located within
/etc/mysql/my.cnf
the line was either
bind-address = 127.0.0.1
or
bind-address = localhost
it should have been
bind-address = 0.0.0.0
which will allow all connections

Can't connect to mysql server on 'localhost' (10061) after replacing localhost at etc/hosts

I am adding the facebook authentication to my django application using the link http://goo.gl/hQ5nx5. I am using Wampserver for Mysql. There's a direction in the above link at step-4 to add an entry in the C:/Windows/System32/drivers/etc/hosts file that maps 127.0.0.1 to something like test1.com. But after this when I run my server through cmd, it gives the error: Can't connect to mysql server on 'localhost' (10061).
Kindly suggest me the solution to this problem. Thanks.
Is your settings.py pointing at localhost? You could adjust it
to point to test1.com, but that's likely to then cause issues when
you change back, so a better answer is:
/etc/hosts supports multiple hostnames for an ip address. You probably want a line like
127.0.0.1 localhost test1.com