Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Error is Error creating database: Access denied for user ''@'localhost' to database 'my_db'

Code is

{

<?php

$link=mysql_connect ("localhost", "cpuser_dbuser", "password") or die
 ('I cannot connect to the database because: ' . mysql_error());
 mysql_select_db ("cpuser_db");    


$sql = 'CREATE DATABASE my_db'; if (mysql_query($sql, $link)) {
    echo "Database my_db created successfully\n"; } else {
    echo 'Error creating database: ' . mysql_error() . "\n"; } ?> }

I have replaced all the credentials here.

Please help me solving this error.

share|improve this question
    
<?php $link=mysql_connect ("localhost", "cpuser_dbuser", "password") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("cpuser_db"); $sql = 'CREATE DATABASE my_db'; if (mysql_query($sql, $link)) { echo "Database my_db created successfully\n"; } else { echo 'Error creating database: ' . mysql_error() . "\n"; } ?> –  Himanshu Dhingra Mar 20 at 9:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.