I'm new to php. I don't understand why database can still be connected when I use any username. for example, when I tried:
我新的php。我不明白为什么当我使用任何用户名时数据库仍然可以连接。例如,当我尝试:
mysql_connect('localhost','zcvbfd','');
there is no any error message shown up. the return value is: Resource id #3
没有出现任何错误消息。返回值是:资源id #3。
1 个解决方案
#1
2
Many default MySQL installations allow for userless, passwordless connections to MySQL from localhost.
许多默认的MySQL安装允许从本地主机到MySQL的无用户连接。
Best practice is to disable this. You can run: sudo mysql_secure_installation
最好的做法是禁用它。您可以运行:sudo mysql_secure_install。
OR Login as root or another privileged mysql user and run:
或以root身份登录,或使用其他特权mysql用户并运行:
SELECT host FROM mysql.user WHERE user = '';
And then for each hostname it gives you run:
然后为每个主机名运行:
DROP USER ''@'hostname-here';
#1
2
Many default MySQL installations allow for userless, passwordless connections to MySQL from localhost.
许多默认的MySQL安装允许从本地主机到MySQL的无用户连接。
Best practice is to disable this. You can run: sudo mysql_secure_installation
最好的做法是禁用它。您可以运行:sudo mysql_secure_install。
OR Login as root or another privileged mysql user and run:
或以root身份登录,或使用其他特权mysql用户并运行:
SELECT host FROM mysql.user WHERE user = '';
And then for each hostname it gives you run:
然后为每个主机名运行:
DROP USER ''@'hostname-here';