php MySQL数据库 - 访问被拒绝

im using phpmyadmin to access my database but when i try to access the website i am getting the following error:

     MySQL said: Documentation
#1045 - Access denied for user 'root'@'localhost' (using password: NO) 

the code to connect the php to sql is the following:

    <?php
/*
 * Generated configuration file
 * Generated by: phpMyAdmin 3.2.5 setup script by Piotr Przybylski <piotrprz@gmail.com>
 * Date: Sun, 21 Feb 2010 12:43:50 +0100
 */

/* Servers configuration */
$i = 0;

/* Server: localhost [1] */
$i++;
$cfg['Servers'][$i]['verbose'] = 'localhost';
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['nopassword'] = true;

$cfg['Servers'][$i]['AllowNoPassword']      = true;
$cfg['Servers'][$i]['pmadb']            = 'phpmyadmin';
$cfg['Servers'][$i]['bookmarktable']    = 'pma_bookmark';
$cfg['Servers'][$i]['relation']         = 'pma_relation';
$cfg['Servers'][$i]['table_info']       = 'pma_table_info';
$cfg['Servers'][$i]['table_coords']     = 'pma_table_coords';
$cfg['Servers'][$i]['pdf_pages']        = 'pma_pdf_pages';
$cfg['Servers'][$i]['column_info']      = 'pma_column_info';
$cfg['Servers'][$i]['history']          = 'pma_history';
$cfg['Servers'][$i]['designer_coords']  = 'pma_designer_coords';
$cfg['Servers'][$i]['tracking']         = 'pma_tracking';




/* End of servers configuration */

$cfg['blowfish_secret']  = 'noFb57s3pq83MQVUDh9D2YLve1r8kUL2Bs27q32uBekGEzD33iTYs757G2nMt7n8';
$cfg['DefaultLang'] = 'en-utf-8';
$cfg['ServerDefault'] = 1;
$cfg['UploadDir'] = './tmp/';
$cfg['SaveDir'] = './tmp/';
$cfg['CheckConfigurationPermissions'] = false;
$cfg['AllowUserDropDatabase'] = true;


$cfg['MySQLManualBase'] = 'http://dev.mysql.com/doc/refman/5.1/en';
$cfg['MySQLManualType'] = 'searchable';

?>

the connection is a local one and there is no password to enter it, therefore i believe that the database should authenticate and authorize the access, original it used to work fine, but now and for some reason, i get access denied. any help is appreciated.

doupaoshu8334
doupaoshu8334 您可能需要将根访问位置更改为%-它对localhostvs127.0.0.1非常敏感
7 年多之前 回复
duankang8114
duankang8114 在我看来,它与你的主人有关。你创建了这个用户吗?
7 年多之前 回复

3个回答

Password or Username is incorrect in this case. Try confirming this and try connecting again. The given script uses the following credentials:

Username:root

Password:< None >

Probably you are missing the correct password



首先,验证是否安装了另一个MySQL实例。 它发生在我身上。</ p>

如果您的系统中只有一个MySQL,并且您使用的是WAMP之类的东西,请打开config.inc.php并查找密码。</ p>
</ div>

展开原文

原文

First, verify if you have another MySQL instance installed. It occurred to me.

If you have only one MySQL in your system and if you're using something like WAMP, open your config.inc.php and look for the password.

doujubeng2942
doujubeng2942 出了什么问题?
7 年多之前 回复
duandui2803
duandui2803 如果有帮助,请将答案标记为解
7 年多之前 回复
dua55014
dua55014 谢谢那些最终奏效的家伙
7 年多之前 回复



您的应用程序使用root帐户并不是一个好主意。 始终为您的应用使用不同的用户! 每个应用程序至少有一个。</ p>

我打赌MySQL会阻止root登录。</ p>

 #1045  - 用户'root'拒绝访问 @'localhost'(使用密码:NO)
</ code> </ pre>

让我担心的是“使用密码:否” - root没有密码? </ p>

尝试创建新用户,授予他正在处理的数据库的权限,然后重试。</ p>
</ div>

展开原文

原文

It's not good idea to use root account by your applications. Always use different users for your apps! At least one for each app.

I bet that MySQL blocks root login.

#1045 - Access denied for user 'root'@'localhost' (using password: NO)

what worries me is "using password: NO" - root without password?

Try to create new user, grant him permissions to database that you're working on and try again.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐