0

I've read through several posts on here targeted at my exact same issue, but none of the answers I've read have worked for me.

I'm trying to access a database on my network that I created using the following command:

$con=mysqli_connect("1.2.3.4","user","pass","db_name");

All of the data in the query is correct, but I'm getting the error:

Warning: mysqli_connect(): (HY000/1130): Host '4.3.2.1' is not allowed to connect to this MySQL server in C:\xampp\htdocs\ajax_refresh.php on line 4

line 4 is the $con statement above.

I've gone into the MySQL shell and typed in:

# mysql -u user -p -h 1.2.3.4

and it connects just fine. I've also accessed the database ON this remote computer through an application I wrote in Excel which connects and loads data, so I know my computer has the correct access rights to the server.

I've also added the section here into my httpd-xampp.conf file:

Alias /phpmyadmin "C:/xampp/phpMyAdmin/"
    <Directory "C:/xampp/phpMyAdmin">
        AllowOverride AuthConfig
    Allow from all        
    Require all granted
    </Directory>

to allow access from an external source, and created this user 'user'@'1.2.3.4' which matches the username and IP address I am connecting from.

What am I doing wrong?

lordterrin
  • 165
  • 2
  • 2
  • 10
  • So my first line: `I've read through several posts on here targeted at my exact same issue, but none of the answers I've read have worked for me.` might indicate that I've read through the solutions I found on here and they didn't work. But you can just mark it as a duplicate instead I guess....... – lordterrin Dec 01 '14 at 21:35

1 Answers1

-1

MySql doesn't allow connections other than from localhost to connect to it

P Yo
  • 15
  • 2
  • wrong. this isn't true. You need to follow this instruction word by word: http://www.rackspace.com/knowledge_center/article/mysql-connect-to-your-database-remotely i have done this 10 times and I was successfully able to connect to a remote collocated mysql database from my localhost or any host. you need to make sure that you issue all the commands in mysql with the incoming ip address that's trying to connect to mysql. its a mysql security feature this way not just anyone can connect to the db. – unixmiah Dec 01 '14 at 21:39
  • Of course it does - I've accessed the server remotely already through an Excel macro, as I stated in the original post. – lordterrin Dec 01 '14 at 21:40
  • this is your problem: Host '4.3.2.1' is not allowed to connect , you have to go into the mysql database mysql and update the user and db table with the ip address. make sure you flush privileges afterwards. – unixmiah Dec 01 '14 at 21:41
  • I've done this as well - I updated my original post to that point. – lordterrin Dec 01 '14 at 21:49
  • Well, I figured it out, but I can't answer the question since @GolezTrol marked this as a duplicate. The actual user I was connecting as was not my IP, it was my computer name on my work's domain. Once I created a new user in the host DB coming from the host ComputerName.domain.company.com, it worked just fine. Interestingly enough, I don't see this as an answer or suggestion in any of the posts I've "duplicated"......... – lordterrin Dec 01 '14 at 22:09