-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'] = '';
Drew
  • 24,851
  • 10
  • 43
  • 78
jamane
  • 1
  • 2
  • 5
  • #2 - obviously you're using the wrong credentials, but since you've shown no code, we can't help you. – Marc B Aug 12 '15 at 14:24
  • Sorry here is my databade connection – jamane Aug 12 '15 at 14:28
  • @jamane Please edit your question to contain the code. – Csq Aug 12 '15 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. – Marc B Aug 12 '15 at 14:37
  • @jamane you need a password of root user – bicho Aug 12 '15 at 14:48
  • any example how to set the password? – jamane Aug 12 '15 at 14:54
  • /* 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'] = ''; – jamane Aug 12 '15 at 14:59
  • jamane, you really need to [edit] your question each time, not comment with that stuff – Drew Aug 12 '15 at 15:06

2 Answers2

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

Raf Zeres
  • 71
  • 3
  • 1
    if root doesn't already have those privileges, he's in trouble for a bit – Drew Aug 12 '15 at 14:51
  • 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 . – jamane Aug 12 '15 at 14:52
  • @Drew I tought that too but I don't know how his database it is, so it might be worth trying. – Raf Zeres Aug 12 '15 at 14:58
  • 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 – Drew Aug 12 '15 at 14:59
  • @jamane Try to do this: `$cn = mysql_connect("localhost", "root", ""); $db = mysql_select_db('bookaride', $cn)` and see what happens – Raf Zeres Aug 12 '15 at 15:00
  • When i try the one you sent Raf Zeres it gives thisWarning: mysql_select_db() expects parameter 2 to be resource, boolean given in – jamane Aug 12 '15 at 15:07
  • Ok, lets try something else. Reset your root password. Here's how to do it: http://dev.mysql.com/doc/refman/5.1/en/resetting-permissions.html – Raf Zeres Aug 12 '15 at 15:14
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.

al'ein
  • 1,711
  • 1
  • 14
  • 21