5

I have a code to create VIEW in mysql database which is working fine on my local server. It creates and crop view normally. But on my Online server it gives error

"CREATE VIEW command denied to user"

for online database I manually create VIEW in Database form PHPmyAdmin [Myadmin is in localhost online] it creating, SO i have permission to create VIEW on online database.

But with php mysql_query it is giving command denied error. is there any service to be on for creating view with php.

2 Answers 2

8

This message says that user doesn't have enough permissions to create view. Permissions are granted to particular user @ particular host. You must execute

GRANT CREATE VIEW ON *.* TO 'username'@'host'; 

where host is hostname from where your CREATE VIEW is executed

Also, user must have SELECT privilages on all tabels and columns involved

Sign up to request clarification or add additional context in comments.

2 Comments

I give permission from cPanel, i can create view manually form myadmin but not from php code.
than I would expect that you connect with different users.
0

I was doing this from CPanel / phpMyAdmin web interface because my create script had the name of the database embedded in it that was not the same as my wordpress mysql database. I.e "CREATE VIEW blog.vwMyView ....".

I had a local MySql Database on my computer that was named blog, which was different than my WordPress MySQL database. So naturally it gives an security error instead of saying the database was invalid. Silly me for not catching it sooner.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.