Php MySQL CentOS:拒绝用户访问''@';本地主机';到数据库
我使用Php MySQL CentOS:拒绝用户访问''@';本地主机';到数据库,php,mysql,database,centos,Php,Mysql,Database,Centos,我使用sudo-yum-install-MySQL-server在CentOS中安装了MySQL,并使用MySQL-u root-p登录MySQL,并给出了空密码。它不允许我使用MySQL数据库或选择用户/更新密码/创建数据库 mysql>select user(); +----------------+ |用户()| +----------------+ | root@localhost | +----------------+ 一行一组(0.00秒) mysql>使用mysql; 错误104
sudo-yum-install-MySQL-server
在CentOS中安装了MySQL,并使用MySQL-u root-p
登录MySQL,并给出了空密码。它不允许我使用MySQL数据库或选择用户/更新密码/创建数据库
mysql>select user();
+----------------+
|用户()|
+----------------+
| root@localhost |
+----------------+
一行一组(0.00秒)
mysql>使用mysql;
错误1044(42000):拒绝用户“@'localhost”访问数据库“mysql”
mysql>UPDATE user SET Password=Password('*****'),其中user='root';
错误1046(3D000):未选择任何数据库
mysql>show-grants;
+--------------------------------------+
|@localhost的授权|
+--------------------------------------+
|将**上的使用权授予'@'本地主机'|
+--------------------------------------+
一行一组(0.00秒)
[centos@****~]$sudo/sbin/service mysqld stop
重定向到/bin/systemctl stop mysqld.service
[centos@****~]$sudo mysqld_safe
151026 14:40:32 mysqld_安全登录到“/var/log/mysqld.log”。
151026 14:40:32 mysqld_safe mysqld进程已存在
[centos@******~]$mysql-u root
欢迎使用MySQL监视器。命令以结束;或\g。
您的MySQL连接id是152
服务器版本:5.6.27 MySQL社区服务器(GPL)
版权所有(c)20002015,Oracle和/或其附属公司。版权所有。
Oracle是Oracle公司和/或其子公司的注册商标
附属公司。其他名称可能是其各自的商标
业主。
键入“帮助;”或“\h”以获取帮助。键入“\c”以清除当前输入语句。
mysql>使用mysql;
错误1044(42000):拒绝用户“@'localhost”访问数据库“mysql”
mysql>
再次出错:
[centos@~]$ sudo /sbin/service mysqld stop
Redirecting to /bin/systemctl stop mysqld.service
[centos~]$ sudo mysqld_safe --skip-grant-tables &
[1] 25678
[centos~]$ 151026 14:53:07 mysqld_safe Logging to '/var/log/mysqld.log'.
151026 14:53:07 mysqld_safe A mysqld process already exists
[1]+ Exit 1 sudo mysqld_safe --skip-grant-tables
[centos@~]$ sudo mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 160
Server version: 5.6.27 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use mysql;
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
请让我知道如何解决这个问题
sudo/etc/init.d/mysql-stop
sudo mysqld\u safe——跳过授权表&
sudomysql-u root
use mysql;
update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
flush privileges;
quit
sudo/etc/init.d/MySQL Stop
(如果出现任何错误,请使用sudo
)sudomysql-uroot-p
如果没有设置密码,则不能使用mysql命令提供-p参数。仅使用mysql-u root启动它您不需要手动更改用户数据库<代码>设置密码root@localhost=密码('*****')当我这样做时,它会抛出一个错误。mysql>为设置密码root@localhost=密码('**');错误1133(42000):在用户表中找不到任何匹配行步骤1、2和3成功。但在第4步中,当我运行“使用MySQL”时,我得到了一个错误。mysql>使用mysql;错误1044(42000):拒绝用户'@'localhost'访问数据库'mysql'mysql>use mysql;错误1044(42000):用户“@'localhost”对数据库“mysql”的访问被拒绝。我编辑了我的问题,并包括了您提到的步骤。如果您需要更多信息,请告诉我。感谢你不用
使用mysql代码>没有“使用MySQL”,它不会向我抛出任何数据库选择错误。mysql>update user set password=password(“****”),其中user='root';错误1046(3D000):未选择任何数据库