![]() |
access denied for new user, Chapter 3
Hi -
Regarding Chapter 3 pg 93-96 - I created the two files createmovie.php and moviedata.php. At the top of createmovie.php I have the following: <?php //connect to MySQL using my username and password $connect = mysql_connect("localhost", "bp5am", "bp5ampass") or die ("Hey loser, check your server connection."); //create a new main database if it doesn't already exist $create = mysql_query("CREATE DATABASE IF NOT EXISTS moviesite") or die (mysql_error()); //make sure our properly created database is the active one mysql_select_db("moviesite"); >>>>>> As requested on page 93, I went into MySQL and created a new user 'bp5am' on 'localhost' with password 'bp5ampass' and granted this user Select, Insert, and Update privileges. When I run createmovie.php in my browser, I get the message 'Access denied for user 'bp5am'@'localhost' to database 'moviesite'. And nothing else. What have I done wrong here? I tried the code I typed AND the code I downloaded with the same result. Please help. Debbie |
I have the same problem with Linux and Windows
|
Hey Deb whats up? I was surfing around on here and I saw your problem. Troubleshooting this stuff can be a pain from time to time. Im not sure exactly what it can be, but it sounds like it could possibly be a password problem... I want to see if you can log into your mysql in windows using the command prompt... If you are using windows xp...Click on start----Accessories--->click on "command prompt." then type this in cd\ then hit enter..your screen should look like this C:\> 1)now type in net start mysql 2) then hit enter... you should again get that c:\> prompt...this time type in right next to the C:\> C:\mysql\bin\mysql -h localhost -u bp5am -p then hit enter... a message should pop up asking for your password...type in your password which should be bp5ampass and hit enter...if the password doesn't work you should get a message saying Acess denied for user etc etc... reply back to this board and let me know what happens. As in if you got an error.
|
Debbie I think I know what the problem is.... Scratch out what I wrote in the above message... Go into the "command prompt" using the steps I showed you in the post above... once in the command prompt it should display C:> if not type cd\ and hit enter... now it should be C:\> now type c:\mysql\bin\mysql -h localhost -u root -p and hit enter... you must enter the password you created for your root log in password... if you don't know it, it may be bp5ampass as well...but if its not, look in the book and it might show what the password was when going through the steps to set up your mysql... Anyways if you are successful and knew the password you should be logged in now under root as the user (hence the "-u root" part)now your screen should look like this mysql> okay, now the reason you were getting that access denied part was because although you setup a user account in mysql the privileges you gave bp5am were limited you only gave the user bp5am limited privileges such as Select, Insert, and Update... because of this you weren't able to create a new database such as moviesite because you didnt give those privileges when you created the user bp5am...The book kind of screwed up at that part... So what we need to do now is give it those privileges... But I suggest we make a new user... so lets name it "Debbie" because its a nice name. so sense you are logged in as root right now and your screen looks like this mysql> type this in
GRANT ALL PRIVILEGES <---hit enter after that ON *.* <----hit enter after this TO debbie@localhost <----hit enter after that IDENTIFIED BY 'enteryourpasswordhere'; <---dont forget to add those ' ' and ; like I did in the example where your password goes... now hit enter...and it should show you a query result or something... now in the php code for createmovie and moviedata change it so it looks like this $connect = mysql_connect ("localhost", "debbie", "passwordgoeshere") and it should work...Good Luck! |
Page 24 (for my Italian translation):
Quote:
Quote:
Quote:
Quote:
Code:
GRANT ALL PRIVILEGES Code:
GRANT CREATE, SELECT, INSERT, UPDATE |
hahah thats crazy..I didnt even see when she posted it...how did the post make it all the way to the top? haha Hey Lanc I like your CREATE part too.. I should of done that as well.. But I kinda thought it might have been cool to create a user to have all the privileges for this book just incase. Thanks for replying also! Its hard to get a reply sometimes.
-TheDudeTux |
All times are GMT -4. The time now is 03:08 PM. |
Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.