Create DB via PHP = Access Denied!

1

I'm trying to create a DB via PHP script, but it is returning ACCESS DENIED.

<?php
   $dbhost = 'localhost';
   $dbuser = 'usuario_root';
   $dbpass = 'senha_root';

   $conn = new mysqli($dbhost, $dbuser, $dbpass);
   if($conn->connect_error )
   {
     die('Could not connect: %s' . $conn->connect_error);
   }
   echo "Connected successfully\n\n";


   $sql = "CREATE DATABASE novobd";

   if($conn->query($sql)===TRUE){

     echo "Created the database\n";

   }

   else {
     echo "Failed to create the database: ".$conn->error;
   }

   //Close the database
   $conn->close();
 ?>

ERROR:

  

Connected successfully Failed to create database: Access denied   for user 'user_root' @ 'localhost' to database 'novobd'

Would it be some configuration in CPanel, or in PHP.ini?

    
asked by anonymous 26.09.2017 / 15:52

1 answer

1

Can you share a print of the error screen?

Usually this error occurs in situations:

  • You used incorrect database access credentials (host, username, and / or password).
  • Or for some reason that only your host would know how to respond you do not have permissions to access / use the database.
  • The user you are trying to connect to does not have these persmissions.
  • 26.09.2017 / 15:56