简体   繁体   English

MySQL / phpMyAdmin-只有root用户可以登录

[英]MySQL/phpMyAdmin - Only root user can log in

I've been having some issues trying to log in as non-root users from a .php file onto phpMyAdmin. 我一直试图以非root用户身份从.php文件登录到phpMyAdmin时遇到一些问题。

I've set up a login form that uses the root user to check if the login that someone uses matches an entry in the mysql.User table and then stores the username and password as session variables which I'm using to try and log in to MySQL and perform user specific tasks later. 我已经建立了一个登录表单,该表单使用root用户来检查某人使用的登录名是否与mysql.User表中的条目匹配,然后将用户名和密码存储为会话变量,以用于尝试登录到MySQL并稍后执行用户特定的任务。

This is the code I'm having issues with: 这是我遇到的代码:

$host = "localhost"; // Host name 
$username = $_SESSION['myusername']; // Mysql username 
$password = $_SESSION['mypassword']; // Mysql password 
$db_name = "gcim"; // Database name 
$tbl_name = "permissions"; // Table name 

// Create connection
$conn = new mysqli($host, $username, $password, $db_name);

myusername and mypassword are just the session variables I've stored and they're set to the values exactly how they should be, "gcim" is the database I'm trying to access and "permissions" is the table myusername和mypassword只是我存储的会话变量,它们被设置为与应有的值完全相同的值,“ gcim”是我要访问的数据库,“ permissions”是表

Trying to execute the code results in the following: 尝试执行代码将导致以下结果:

Warning: mysqli::mysqli(): (HY000/1045): Access denied for user 'BUT03'@'localhost' (using       password: YES) in C:\xampp\htdocs\gcim\permissions\permissions.php on line 12
Connection failed: Access denied for user 'BUT03'@'localhost' (using password: YES)

I'm pretty sure that the issue isn't a wrong hostname, username or password because even if I change the connection line to: 我很确定问题不是主机名,用户名或密码错误,因为即使我将连接线更改为:

$conn = new mysqli("localhost", "BUT03", "test", "gcim");

it still gives me the same error 它仍然给我同样的错误

Here's the setup of my mysql.User table: http://puu.sh/dDxd3/5e25f315f4.png 这是我的mysql.User表的设置: http ://puu.sh/dDxd3/5e25f315f4.png

Anyway, any help would be very much appreciated, Thanks 无论如何,任何帮助将不胜感激,谢谢

EDIT: I've been experimenting and I've come to the conclusion that the ONLY way to get a successful login to MySQL is using the root account with no password, any attempt to log in with a password will give me the same error, as well as removing the password from a non-root account and trying to log in with no password which gives me the following error: Connection failed: Access denied for user ''@'localhost' to database 'gcim' 编辑:我一直在试验,我得出的结论是,成功登录MySQL的唯一方法是使用没有密码的root帐户,任何使用密码登录的尝试都会给我同样的错误,以及从非root用户帐户中删除密码并尝试不使用密码登录,这会给我以下错误:连接失败:拒绝用户“ @'localhost”访问数据库“ gcim”

I have a feeling that there's some issue with the server settings, was I meant to change anything from the default phpMyAdmin settings? 我感觉服务器设置存在一些问题,是否意味着要更改默认的phpMyAdmin设置?

EDIT: I just tried to log in to phpMyAdmin itself as 'BUT03'@'localhost' and I appear to have no privileges at all even though everywhere I can see I've granted all possible privileges to that account, could this be affecting anything and does anyone know what could be causing it? 编辑:我只是尝试以'BUT03'@'localhost'身份登录phpMyAdmin本身,即使我到处都能看到我已授予该帐户所有可能的特权,但我似乎根本没有任何特权,这可能会影响任何事情有人知道会导致什么吗?

I assume passowrds are saved not in plain text, but hashed. 我假设passowrds不是以纯文本格式保存的,而是散列的。 That would mean your hashed password is 'test', and you actual password is something unknown. 那意味着您的哈希密码是“ test”,而您的实际密码是未知的。 Change your password to test with this function 更改密码以使用此功能进行测试

 SET PASSWORD FOR 'BUT03'@'localhost' = PASSWORD('test');

see: http://dev.mysql.com/doc/refman/5.0/en/set-password.html 参见: http : //dev.mysql.com/doc/refman/5.0/en/set-password.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM