简体   繁体   中英

Can't connect to MySQL with a new MySQL user

I work on a personal website. I just put it on the production server. When I am in the development environment I connect to MySQL with root but now I just created a user specific for this website. So I wrote this command line in MySQL:

GRANT USAGE ON portefolio.* TO 'userPortefolio'@'localhost' IDENTIFIED BY PASSWORD 'myPasswordCrypted'

The query is ok, but on my website, when I try to access a page with a query, Symfony gives me that error:

SQLSTATE[42000] [1044] Access denied for user 'userPortefolio'@'localhost' to database 'portefolio'

I tried to restart the server to be sure everything is ok but nothing. I encrypted the password with the MySQL function

password('my password not encrypt')

and in Symfony I wrote the password in non-encrypted format. Is that ok?

GRANT USAGE ON portefolio.* TO 'userPortefolio'@'localhost' IDENTIFIED BY PASSWORD 'myPasswordCrypted'

Your password should not be encrypted in this statement. MySQL crypts it automatically.

Assuming no quirks in connecting etc were made you should do a

flush privileges;

after running the grant query.

quoting from the manual : The USAGE privilege specifier stands for “ no privileges .”

so everything seems to be working as designed.

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