-3

MY ERROR is Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/1130): Host '31.170.160.209' is not allowed to connect to this MySQL server in /home/a6962874/public_html/social/includes/class-db.php on line 5

Free Web Hosting Connect failed Host '31.170.160.209' is not allowed to connect to this MySQL server and my code is $mysqli = new mysqli('findus.comxa.com', 'root', '', 'social'); what is the error what is the error in mysql > CREATE users 'usman'@'root' IDENTIFIED BY 'some_pass';

gagan mahatma
  • 336
  • 2
  • 9
  • 1
    http://dev.mysql.com/doc/refman/5.7/en/create-user.html -- Check an example for the syntax – apokryfos Jan 08 '16 at 14:16
  • Also check what mysql port it is using and make sure your firewall isn't blocking it. http://stackoverflow.com/questions/3736407/mysql-server-port-number – Dr. Aaron Dishno Jan 08 '16 at 14:22

2 Answers2

2

First of all it's not users but USER (without the final s) !

CREATE USER 'usman'@'root' IDENTIFIED BY 'some_pass';

@'root' should be 'findus.comxa.com' or '31.170.160.209' in your case.

CREATE USER 'usman'@'31.170.160.209' IDENTIFIED BY 'some_pass';

Note that the MySQL documentation says:

If you specify only the user name part of the account name, a host name part of '%' is used.

That's mean that you can create the user without specifying the domain:

CREATE USER 'usman' IDENTIFIED BY 'some_pass';

Then, do not forget to grant privileges:

GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'localhost';
ponsfrilus
  • 1,010
  • 1
  • 17
  • 25
  • What would be the correcrion in this in my case :mysql> CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass'; mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost' -> WITH GRANT OPTION; mysql> CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass'; mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%' -> WITH GRANT OPTION; – Muhammad Usman Memon Jan 09 '16 at 06:13
  • SQL query: mysql > CREATE USER 'usman'@'31.170.160.209' IDENTIFIED BY 'some_pass'; MySQL said: Documentation #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysql> CREATE USER 'usman'@'31.170.160.209' IDENTIFIED BY 'some_pass'' at line 1 any error – Muhammad Usman Memon Jan 09 '16 at 06:29
0

i suggest that you check your credentials username, password, maybe a port and server

here a little example for connect to database with mysqli

<?php
$link = mysqli_connect("127.0.0.1", "my_user", "my_password", "my_db");

if (!$link) {
    echo "Error: Unable to connect to MySQL." . PHP_EOL;
    echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
    echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
    exit;
}

echo "Success: A proper connection to MySQL was made! The my_db database is great." . PHP_EOL;
echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL;

mysqli_close($link);
?>

with PDO

<?php
try {
    $dbh = new PDO('mysql:host=localhost;dbname=test', $user, $pass);
    foreach($dbh->query('SELECT * from FOO') as $row) {
        print_r($row);
    }
    $dbh = null;
} catch (PDOException $e) {
    print "Error!: " . $e->getMessage() . "<br/>";
    die();
}
?>

TRY AND good luck

PDO CONNECT

MYSQLI CONNECT

BlackHack123
  • 349
  • 1
  • 10