php - 无法在 Windows 上本地使用 phpMyAdmin 配置 MySQL

标签 php mysql phpmyadmin

我正在尝试使用二进制版本的 PHP、Apache、MySQL 和 phpMyAdmin 在 Windows 7 上配置我自己的本地服务器。我成功使用 PHP 配置并运行了 Apache。

现在我想配置 MySQL 和 phpMyAdmin。首先,我使用代码创建了 my.cnf 文件

[mysqld]
bind-address = 127.0.0.1
default_authentication_plugin = mysql_native_password

接下来我运行 CMD 命令

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

并获得D:Server/mysql/data文件夹,其中包含文件

我的 HTML 文件将位于 D:/Server/localhost 文件夹中。因此,我在那里插入了解压的 phpMyAdmin 文件夹,并将以下几行添加到其 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;

然后我用命令启动MySQL

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

在命令提示中我得到

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

但是现在,如果我尝试使用 root 用户名和空密码登录 phpMyAdmin,则会收到错误

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

在那里我读到https://stackoverflow.com/a/52364450/3208225但我已经在 my.cnf 中添加了 default_authentication_plugin= mysql_native_password

我还读到我们可以以 root 身份登录并设置密码,但我真的不明白该怎么做

最佳答案

好的,问题是我使用命令初始化了 data 目录

>mysqld.exe --initialize --console

它会生成一个临时密码,但我希望无需任何密码即可登录。因此,如果我们想使用空密码,我们必须使用命令初始化数据目录

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

我们可以稍后设置密码

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

关于php - 无法在 Windows 上本地使用 phpMyAdmin 配置 MySQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55598238/

相关文章:

PHP 解析一个 CSV 文件——它应该存储在数据库中吗

php - MySQL 缺勤报告脚本

php - 如何从子域上传表单将上传的文件存储在主域的目录中

Java - Spring Boot - Mysql/Java - 从表的列中获取车辆类型并从另一个表中获取其总计数(数量)

mysql - JSF 托管 bean 中的 SQL WHERE LIKE 子句

mysql MyISAM 数据库和外键关系在 phpmyadmin 中如何工作? MyISAM 有更新吗?

mysql - 手动将外键插入表时允许自由输入

php - SQL - 为什么我的 INSERT 查询死了?

php - WordPress、Apache、MySQL 和 Mac

php - 如何删除列的字段前缀