I have built an SQL query and sent it to the MySQL Server using a PHP program/script. Everything was working fine and the connection was good until I attempted to CREATE DATABASE. Then I got this error:
Error: Access denied for user ''''@''localhost'' to database ''petcatalog''
Does anyone know why I am not connecting and how I fix this?
Thanks
P.S.
I know I can use the command prompt to build a database but I would like to complete this project of building a database using php scripts to connect with mysql server.
解决方案What is the full error message? It''ll include something like ''USING PASSWORD yes''.
it also looks like there’s no login name passed.
Note that you need to have the CREATE privilege for the database before you create it. Meaning that, before you create the database, a user with the GRANT privilege (like root) needs to issue a GRANT command, giving the user you are using in your scripts permission to create the database.
Because of this, you are generally just better of creating the database using the admin user. You are going to have to use it to grant the privileges anyways.