php - 在终端中重置密码时如何修复用户'root'@'localhost'的访问被拒绝不起作用
问题描述
我对设置 WebServer 不熟悉,所以我看了这篇关于如何使用 PHPMyAdmin 和 MySQL 的教程。
我使用 macOS High Sierra。
这是我到目前为止所做的:
- 须藤 apachectl 开始
- 须藤纳米/etc/apache2/httpd.conf
- 删除#LoadModule php5之前的#…</li>
- 须藤 apachectl 重启
- 须藤纳米/etc/apache2/httpd.conf
- 在 DirectoryIndex 行中添加 index.php
- 须藤 apachectl 重启
- sudo nano /Library/WebServer/Documents/index.php
- 在 localhost 创建 Hello World php 文件
- 下载Mysql:https ://dev.mysql.com/downloads/
- 保存密码
- 须藤 mkdir /var/mysql
- sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
- 启动mysql服务器
- cd /usr/local/mysql/bin
- sudo ./mysql -u root -p
- 更改由 'newpassword' 标识的用户 'root'@'localhost;
- 下载phpmyadmin:https ://www.phpmyadmin.net
- 复制粘贴到 Documents 文件夹并重命名为 phpMyAdmin
- cd /图书馆/网络服务器/文档/
- cd phpMyAdmin
- 须藤 mkdir 配置
- 须藤 chmod o+x 配置
- 打开 localhost/phpmyadmin
- 在身份验证下,输入 mysql 密码
- 下载配置
- 复制/粘贴配置到配置文件夹
我想知道配置文件是否包含一些阻止我成功的错误。config.inc.php 文件存储在Macintosh HD > Library > WebServer > Documents > phpMyAdmin > config下。当我从 config 文件夹中删除此文件并将其放在常规 phpMyAdmin 文件夹下时,我收到了相同的错误消息。
config.inc.php 中的服务器配置可能是问题所在。
/* Servers configuration */
$i = 0;
/* Server: localhost -> 127.0.0.1 [1] */
$i++;
$cfg['Servers'][$i]['verbose'] = 'localhost';
$cfg['Servers'][$i]['host'] = 'localhost'; /* was previously = 'localhost'; */
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'password';
我希望使用用户名登录:root 和密码:密码没有任何问题。
相反,我收到错误mysqli_real_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES)
几周前我在 StackOverflow 上查找了这个问题,但似乎解决这个问题的人正在使用 XAMPP。安装 XAMPP 可能会使事情变得更糟,因为我已经安装了 config.inc.php,并且默认设置与来自 XAMPP 的设置不同。
我遵循了有关如何刷新权限和更改密码以访问 MySQL 的教程,但我的终端无法识别这些命令。我收到不存在这样的命令的错误。
解决方案
推荐阅读
- angular - ionic 4 tabbar - 如何始终显示标签根而不是标签子页面
- postgresql - 使用 PostgreSQL 从许多表中选择并合并相同的属性
- sql - 查询数据时忽略大小写
- node.js - 如何使用 Node.js SDK v3.5.2 将 PartitionKey 分配给 CosmosDB 查询
- c - win api - 如何为树视图实现单独的事件过程
- javascript - stopPropagation 在组件的层次结构中不起作用
- logging - 计费 - 将历史 BQ 日志从旧表复制到新表。谷歌云平台
- mongodb - 如何在可选属性上使用 $currentDate 修复 Mongo 更新的打字稿
- algorithm - 混合快速/合并排序在随机数据上的性能
- python - 未找到带有参数“(”,)”的“结果”的反向。尝试了 1 种模式:['polls/(?P
[0-9]+)/结果/$']