用户'root'@'localhost'拒绝访问(使用密码:YES)

时间:2015-10-19 06:15:06

标签: php mysql localhost wamp

我知道标题看起来很熟悉但没有。我正在开发一个Web应用程序,当我运行它时,它说:用户'root'@'localhost'拒绝访问(使用密码:NO)。我搜索了一些网站,他们说我应该使用密码。所以我用mysql控制台更改了密码。比我收到此消息访问被拒绝用户'root'@'localhost'(使用密码:YES)。当我重新进入mysql控制台并输入密码时,它会发出哔哔声而不是关闭。我收到了这个事件日志:

Log Name:      Application
     

来源:.NET Runtime   日期:2015年10月18日下午7:12:51   事件ID:1026任务类别:无级别:错误关键词:   经典用户:N / A计算机:TOSHIBA-TOSH描述:   应用程序:MySQLWorkbench.exe Framework版本:v4.0.30319   描述:由于未处理的异常,进程终止。   异常信息:System.Runtime.Remoting.RemotingException Stack:at   System.Runtime.Remoting.Channels.Ipc.IpcServerChannel.StartListening(System.Object的)   在   MySQL.Workbench.ApplicationInstanceManager.RegisterRemoteType(System.String)   在   MySQL.Workbench.ApplicationInstanceManager.CreateSingleInstance(System.String,   System.String [],   System.EventHandler`1)
  在MySQL.GUI.Workbench.Program.Main(System.String [])

     

事件Xml:
                1026       2       0       0x80000000000000              537897       应用       东芝TOSH                    应用程序:MySQLWorkbench.exe Framework版本:v4.0.30319描述:由于未处理,进程终止   例外。异常信息:System.Runtime.Remoting.RemotingException   堆栈:at   System.Runtime.Remoting.Channels.Ipc.IpcServerChannel.StartListening(System.Object的)   在   MySQL.Workbench.ApplicationInstanceManager.RegisterRemoteType(System.String)   在   MySQL.Workbench.ApplicationInstanceManager.CreateSingleInstance(System.String,   System.String [],   System.EventHandler`1< MySQL.Workbench.InstanceCallbackEventArgs&GT)   在MySQL.GUI.Workbench.Program.Main(System.String [])
   

有任何帮助吗?我卸载了所有东西(wamp,mysql,dreamweaver,.........)但仍然遇到了同样的问题。当我输入密码This error时,mysql工作台会出现此错误。

我尝试使用config.inc.php解决方案但仍然相同。

2 个答案:

答案 0 :(得分:0)

也许来自localhost的root没有访问数据库所需的授权。

尝试在mysql控制台上运行以下命令:

GRANT ALL ON <yourdb>.* TO 'root'@'localhost';
FLUSH PRIVILEGES;

答案 1 :(得分:0)

请按照以下步骤操作:

转到mysql服务器控制台并按照以下步骤操作:

步骤1:打开配置文件,在[mysqld]部分添加以下行并保存文件。

skip-grant-tables
skip-networking

Step2:重新启动你的mysql服务,如果使用linux,你可以使用下面的命令。

service mysqld restart 

步骤3:现在通过以下命令连接mysql -

mysql -uroot

Step4:上面的命令将连接你的mysql,并将显示如下的mysql提示 -

mysql>

步骤5:现在按照以下更改root密码 -

mysql> update mysql.user set password = password('root123') where user='root';
OR 
mysql> update mysql.user set password = password('root123') where user='root' and host = 'localhost';

mysql> flush privileges;

mysql> exit;

步骤6:现在从配置文件中删除新添加的行,然后按照步骤2重新启动mysql服务。

最后,您现在可以将您的网站或phpmyadmin与root用户连接。