简体   繁体   中英

Access is denied (MySQL)

I'm having a problem where I create a user in MySQL, and I try to access localhost with it on the web. However, it just throws at me:

Access denied for user 'default_user'@'localhost' (using password: YES)

Here is the user creation:

    mysql> CREATE USER default_user;
           Query OK, 0 rows affected (0.00 sec)

    mysql> GRANT SELECT, UPDATE, INSERT ON test.*
        -> TO 'default_user'@'localhost'
        -> IDENTIFIED BY 'bacon';
    Query OK, 0 rows affected (0.00 sec)

And the PHP:

    <?php

DEFINE('DB_USER', 'default_user');
DEFINE('DB_PASSWORD', 'bacon');
DEFINE('DB_HOST', 'localhost');
DEFINE('DB_NAME', 'test');

$dbconnect = @mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
OR die('Connection aborted' . mysqli_connect_error());

 ?>

Thanks in advance!

Thanks everyone for the help! I simply fixed it by backing up my data, and reinstalling MySQL through Homebrew then restarted to make sure all processes were killed!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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