$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['AllownopasswordRoot'] = true;
由于我已经恢复,我已将上述代码更改为
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'Pass123';
$cfg['Servers'][$i]['AllownopasswordRoot'] = true;
现在我收到以下错误
Access denied for user ‘root’@’localhost’ (using password: YES) MysqL Error # :1045
请告诉我,这里出了什么问题.
解决方法:
在浪费了大部分时间来解决这个问题之后,事实证明我所要做的就是提供非localhost主机名.我不知道为什么(允许用户从任何主机连接),但它的工作原理!
root@base:~# MysqL -u username -h hostname -p
Enter password:
Welcome to the MysqL monitor. Commands end with ; or \g.
在PHP中:
Test 1807:
<?PHP
$username = "username";
$password = "password";
$hostname = "actualhostnamenotlocalhost";
$con = MysqLi_connect($hostname, $username, $password);
// Check connection
if (MysqLi_connect_errno($con)){
echo "Failed to connect to MysqL: " . MysqLi_connect_error();
}
MysqLi_close($con);
?>
OK.