1

i cannot seem to create a connection to Mysql database from the following code. Can you please let me know if there is anything missing from this code. Since i have not used php code much i might have missed out something.

on submitting code im getting the following error Warning: mysql_connect() [function.mysql-connect]: Host '31.170.160.80' is not allowed to connect to this MySQL server in /home/a5847996/public_html/check_db.php on line 15

here is the code im using

<body>
    <?php
     $server   = "-";
     $database = "-";
     $username = "-";
     $password = "**************";

     $mysqlConnection = mysql_connect($server, $username, $password);
      if (!$mysqlConnection)
      {
       echo "Please try later.";
      }
      else
      {
       mysql_select_db($database, $mysqlConnection);
      }
   ?>
    </body>
Daedalus
  • 7,586
  • 5
  • 36
  • 61

1 Answers1

2

Go to your MySQL Prompt and issue this command.

$ mysql -u root -p
Enter password:

mysql> use mysql

mysql> GRANT ALL ON *.* to root@'31.170.160.80' IDENTIFIED BY 'your-root-password'; 

mysql> FLUSH PRIVILEGES;

Don't forget to assign your parameters !

Shankar Narayana Damodaran
  • 68,075
  • 43
  • 96
  • 126