skip to Main Content

I’m trying to configure my own local server on Windows 7 with binary versions of PHP, Apache, MySQL and phpMyAdmin. I configured and run Apache with PHP successfully.

Now I want to configure MySQL and phpMyAdmin. First I created the my.cnf file with the code

[mysqld]
bind-address = 127.0.0.1
default_authentication_plugin = mysql_native_password

and next I run the CMD command

D:/Server/mysql/bin/mysqld.exe --initialize --console

and got the D:Server/mysql/data folder with files therein

My HTML-files will be in the D:/Server/localhost folder. So I inserted unpacked phpMyAdmin folder there and added the following lines to its config.in.php

...
$cfg['Servers'][$i]['verbose'] = '';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['nopassword'] = true;
$cfg['Servers'][$i]['AllowNoPassword'] = true;
$cfg['Servers'][$i]['ServerDefault'] = 1;

Then I started MySQL with the command

D:/Server/mysql/bin/mysqld.exe --console

and in the command promt I get

.../mysqld.exe ready for connections
... X Plugin ready for connections

But now if I try to log in to phpMyAdmin with root username and empty password I get the error

mysqli_real_connect(): The server requested authentication method
unknown to the client [caching_sha2_password]

mysqli_real_connect():
(HY000/2054): The server requested authentication method unknown to
the client

There on SO I read https://stackoverflow.com/a/52364450/3208225 but I already have the line default_authentication_plugin= mysql_native_password in my.cnf

I also read we can log in as root and set a password but I really don’t understand how can I do that

2

Answers


  1. Chosen as BEST ANSWER

    Ok, the problem was I initialized the data directory with the command

    >mysqld.exe --initialize --console
    

    which generates a temporary password, but I expected to log in without any password. So if we want to use empty password, we have to initialize the data directory with the command

    >mysqld.exe --initialize-insecure --console
    

    and we can set a password later

    Reference: https://dev.mysql.com/doc/refman/8.0/en/data-directory-initialization.html


  2. try setting your ['auth_type'] to: $cfg['Servers'][$i]['auth_type'] = 'config';.

    When I installed phpmyadmin, I made the same mistake.
    Hope it works, for me it worked.

    Kind regards.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search