-1

I have two questions.

1) In phpmyadmin each time I log in it gives this error

Connection for controluser as defined in your configuration failed.

2) I'm trying to register an html form to the database but i got this warning says:

Warning: mysql_connect(): Access denied for user 'root'@'localhost' (using password: NO)

The Code:

<?php 
    mysql_connect("localhost", "root", ""); 
    mysql_select_db("bookaride"); 
?>

Edit:

/* Authentication type and info */ 
$cfg['Servers'][$i]['auth_type'] = 'cookie'; 
// Authentication method (config, http or cookie based) 
$cfg['Servers'][$i]['user'] = 'root'; 
$cfg['Servers'][$i]['password'] = ''; 
$cfg['Servers'][$i]['extension'] = 'mysqli'; 
$cfg['Servers'][$i]['AllowNoPassword'] = true; 
$cfg['Lang'] = '';
8
  • #2 - obviously you're using the wrong credentials, but since you've shown no code, we can't help you. Commented Aug 12, 2015 at 14:24
  • Sorry here is my databade connection <?php mysql_connect("localhost", "root", ""); mysql_select_db("bookaride"); ?> Commented Aug 12, 2015 at 14:28
  • @jamane Please edit your question to contain the code. Commented Aug 12, 2015 at 14:31
  • 3
    well, obviously your root account either doesn't have access (very unusual), or you haven't provided the required password. that's not something we can help you with. Commented Aug 12, 2015 at 14:37
  • @jamane you need a password of root user Commented Aug 12, 2015 at 14:48

2 Answers 2

0

Open you Mysql console, if you are using WAMP should be here (C:\wamp\bin\mysql\mysql5.6.17\bin) or something like that

After you open the console, enter this:

GRANT ALL PRIVILEGES ON bookaride TO 'root'@'%' WITH GRANT OPTION;

Try to run your script again

Sign up to request clarification or add additional context in comments.

7 Comments

if root doesn't already have those privileges, he's in trouble for a bit
I'm using XAMPP. I wanted to put the php code but stackoverflow tells that some is wrong in the code i cant post it .
@Drew I tought that too but I don't know how his database it is, so it might be worth trying.
well how would he connect with root to issue it :> Just to point out, he is dying in source code on the connect, not db change, not queries. Just having fun Raf
@jamane Try to do this: $cn = mysql_connect("localhost", "root", ""); $db = mysql_select_db('bookaride', $cn) and see what happens
|
0

1) Beware the use of PHP "mysql" functions, it's deprecated since Dec/12 and will be soon removed. You better chose from mysqli like

$conn = new mysqli('localhost', 'root', '');

or PDO, like

try
{
    $conn = new PDO("mysql:host=localhost;dbname=bookaride", 'root', '');
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e)
{
    echo $e->getMessage();
}

unless you're using an older version of PHP.

2) Your error implies your credentials are wrong. You can try to reset your root credentials following these instructions.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.