ERROR to access to Mysql via PHP due to password

Hi,

I tried to connect to MySql Xampp via PHP but I got this message

Warning: mysqli::mysqli(): (HY000/1045): Access denied for user ‘root’@‘localhost’ (using password: YES) in C:\xampp\htdocs\createDB\index.php on line 15

Notice: Undefined variable: conn in C:\xampp\htdocs\createDB\index.php on line 17

Notice: Trying to get property of non-object in C:\xampp\htdocs\createDB\index.php on line 17
Connection failed:

I search for a solution and I found many people said , password in confing.in.php must to be changed to “root” as example. I change it but I got another .I cannot access to admin page for mySql and I got this message

MySQL said: Documentation

Cannot connect: invalid settings.
phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.

Can you help me,please?

I don’t know what your code is, but your error specifically says the credentials are incorrect.

Regarding the password you should use, XAMPP defaults to no password I believe.

Thank you for your response.

From the file config.in.php code is

[php]<?php
/*

  • This is needed for cookie based authentication to encrypt password in
  • cookie
    /
    $cfg[‘blowfish_secret’] = ‘xampp’; /
    YOU SHOULD CHANGE THIS FOR A MORE SECURE COOKIE AUTH! */

/*

  • Servers configuration
    */
    $i = 0;

/*

  • First server
    */
    $i++;

/* Authentication type and info */
$cfg[‘Servers’][$i][‘auth_type’] = ‘config’;
$cfg[‘Servers’][$i][‘user’] = ‘root’;
$cfg[‘Servers’][$i][‘password’] = ‘’;
$cfg[‘Servers’][$i][‘extension’] = ‘mysqli’;
$cfg[‘Servers’][$i][‘AllowNoPassword’] = true;
$cfg[‘Lang’] = ‘’;

/* Bind to the localhost ipv4 address and tcp */
$cfg[‘Servers’][$i][‘host’] = ‘127.0.0.1’;
$cfg[‘Servers’][$i][‘connect_type’] = ‘tcp’;

/* User for advanced features */
$cfg[‘Servers’][$i][‘controluser’] = ‘pma’;
$cfg[‘Servers’][$i][‘controlpass’] = ‘’;

/* Advanced phpMyAdmin features */
$cfg[‘Servers’][$i][‘pmadb’] = ‘phpmyadmin’;
$cfg[‘Servers’][$i][‘bookmarktable’] = ‘pma__bookmark’;
$cfg[‘Servers’][$i][‘relation’] = ‘pma__relation’;
$cfg[‘Servers’][$i][‘table_info’] = ‘pma__table_info’;
$cfg[‘Servers’][$i][‘table_coords’] = ‘pma__table_coords’;
$cfg[‘Servers’][$i][‘pdf_pages’] = ‘pma__pdf_pages’;
$cfg[‘Servers’][$i][‘column_info’] = ‘pma__column_info’;
$cfg[‘Servers’][$i][‘history’] = ‘pma__history’;
$cfg[‘Servers’][$i][‘designer_coords’] = ‘pma__designer_coords’;
$cfg[‘Servers’][$i][‘tracking’] = ‘pma__tracking’;
$cfg[‘Servers’][$i][‘userconfig’] = ‘pma__userconfig’;
$cfg[‘Servers’][$i][‘recent’] = ‘pma__recent’;
$cfg[‘Servers’][$i][‘table_uiprefs’] = ‘pma__table_uiprefs’;
$cfg[‘Servers’][$i][‘users’] = ‘pma__users’;
$cfg[‘Servers’][$i][‘usergroups’] = ‘pma__usergroups’;
$cfg[‘Servers’][$i][‘navigationhiding’] = ‘pma__navigationhiding’;
$cfg[‘Servers’][$i][‘savedsearches’] = ‘pma__savedsearches’;
$cfg[‘Servers’][$i][‘central_columns’] = ‘pma__central_columns’;
$cfg[‘Servers’][$i][‘designer_settings’] = ‘pma__designer_settings’;
$cfg[‘Servers’][$i][‘export_templates’] = ‘pma__export_templates’;
$cfg[‘Servers’][$i][‘favorite’] = ‘pma__favorite’;

/*

  • End of servers configuration
    */

?>[/php]

I change the password and make allow password to false but it still not working

my code is

[php]<?php

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    $c = filter_input(INPUT_GET, ‘c’);
    $e = filter_input(INPUT_GET, ‘e’);
    $p = filter_input(INPUT_GET, ‘p’);
    $localhost = ‘localhost’;
    $dusername = ‘root’;
    $dpassword = ‘root’;
    $database = ‘lab3’;
    $connection = new mysqli($localhost , $dusername , $dpassword,$database);
    if ($connection->connect_error) {
    die("Connection failed: " . $conn->connect_error);
    }
    echo “Connected successfully”;
    $quiry = ‘INSERT INTO lab3 (Credit_Number,Email,Password)’; // col in database
    $quiry .= “VALUES (‘12345’,‘[email protected]’,‘M0dfj’)”;
    $result = mysqli_query($connection, $quiry);
    if (!$result)
    {
    die(“Query Faile”. mysqli_errno($connection));
    }
    //else
    //{
    // echo ‘You information was entered seccssfuly’;
    //}
    ?>
    [/php]

can you log into phpmyadmin thru XAMPP?

if I make config.in.php as default. yes

if I put in password root or change allow password to false . no

Next step is to try and log into the Db with the console.

Can you do that?

Then those are the credentials you should use in your script.

PHPmyadmin is just another PHP script, it acts just the same as a PHP script you write yourself.

It seems your mysql server is set up with no root password, if you want to set a password for the root mysql user you need to do this in mysql, not in the PHPmyadmin config. You will need to update that config afterwards though so PHPmyadmin can connect to mysql using the new password

From command line I can access if I do not change any thing in confing.ini.php

If I change the file I cannot even access localhost/phpmyadmin

I will get message

Cannot connect: invalid settings.
phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.

The problems is fixed now. I tried to change password from phpmyadmin and its work

Tank you astonecipher and JimL for helping

Sponsor our Newsletter | Privacy Policy | Terms of Service