XAMPP 上的 php/mySQL:phpMyAdmin 和 mysql_connect 的密码不同?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15272979/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 08:57:23  来源:igfitidea点击:

php/mySQL on XAMPP: password for phpMyAdmin and mysql_connect different?

phpmysqlsqlphpmyadminxampp

提问by Bernd

I am running phpMyAdmin and MySQL on XAMPP for Windows.

我在 XAMPP for Windows 上运行 phpMyAdmin 和 MySQL。

I am accessing the MySQL database in two ways. First, via localhost/phpmyadmin, and second, via a connection.phpfile (with mysql_connect('localhost','user','password')which is used by other php files for a website on the server.

我以两种方式访问​​ MySQL 数据库。首先,通过localhost/phpmyadmin,其次,通过connection.php文件(mysql_connect('localhost','user','password')其他 php 文件使用该文件用于服务器上的网站。

Both for the phpMyAdmin login and the mysql_connectI am using the root user. I know I should not be using root and that it is a security issue. But the passwords differ! I have set the password for the phpMyAdmin access via localhost/security, but I can't figure how to change the password required for the mysql_connect.

phpMyAdmin 登录和mysql_connect我都使用 root 用户。我知道我不应该使用 root 并且这是一个安全问题。但是密码不同!我已经通过 设置了 phpMyAdmin 访问的密码localhost/security,但我不知道如何更改mysql_connect.

I thought it would be the same but apparently it is not. How do I change the root password through phpMyAdmin?

我认为它会是一样的,但显然不是。如何通过 phpMyAdmin 更改 root 密码?

回答by Zim84

if you open localhost/phpmyadminyou will find a tab called "User accounts". There you can define all your users that can access the mysql database, set their rights and even limit from where they can connect.

如果您打开,localhost/phpmyadmin您会找到一个名为“用户帐户”的选项卡。在那里您可以定义可以访问 mysql 数据库的所有用户,设置他们的权限,甚至限制他们可以连接的位置。

回答by solick

You need to change the password directly in the database because at mysql the users and their profiles are saved in the database.

您需要直接在数据库中更改密码,因为在 mysql 中,用户及其配置文件保存在数据库中。

So there are several ways. At phpMyAdmin you simple go to user admin, choose root and change the password.

所以有几种方法。在 phpMyAdmin 中,您只需转到用户 admin,选择 root 并更改密码。