Asday Posted July 11, 2007 Share Posted July 11, 2007 <?php $sqlCon=mysql_connect("localhost", "asday", "***"); if (!$sqlCon) { die("Fark! " . mysql_error()); } else { mysql_query("CREATE DATABASE people"); } ?> outputs: Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'asday'@'localhost' (using password: YES) in C:\xampp\htdocs\SQL\index.php on line 3 Fark! Access denied for user 'asday'@'localhost' (using password: YES) What's wrong? Quote Link to comment Share on other sites More sharing options...
Vibralux Posted July 11, 2007 Share Posted July 11, 2007 Are you on shared hosting? Quote Link to comment Share on other sites More sharing options...
Asday Posted July 11, 2007 Author Share Posted July 11, 2007 On localhost - Dedicated hosting. I don't understand that. Geniuses near me told me. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 11, 2007 Share Posted July 11, 2007 Have you set the correct permissions for the user to access the database? Quote Link to comment Share on other sites More sharing options...
Asday Posted July 11, 2007 Author Share Posted July 11, 2007 Have you set the correct permissions for the user to access the database? How do I do that? (googling didn't help) Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 11, 2007 Share Posted July 11, 2007 If you go to cPanel you can set them from there. Quote Link to comment Share on other sites More sharing options...
keeB Posted July 11, 2007 Share Posted July 11, 2007 Permission issue. GRANT ALL ON <database>.<tablename> TO Asday Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 11, 2007 Share Posted July 11, 2007 Thanks keeB, I can never remember how to set it in PHP. Quote Link to comment Share on other sites More sharing options...
Asday Posted July 11, 2007 Author Share Posted July 11, 2007 That won't help, as I can't connect to the database. Also, can't find cPanel, but mySQL did ask for a username and pass when I started it up. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 11, 2007 Share Posted July 11, 2007 Have you got MySQL and PHP installed on your computer or are you running live? Quote Link to comment Share on other sites More sharing options...
Asday Posted July 11, 2007 Author Share Posted July 11, 2007 Everything's local. Put it this way, if I suddenly lost the internet, everything (that works now) would still work. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 11, 2007 Share Posted July 11, 2007 1. Have you created a user and set a password for it? 2. Have you got the correct username and/or password? 3. Are the permissions set? 4. If you installed WAMP go into cPanel which gives you access to phpMyAdmin. From there you can check everything via a GUI which will make everything a lot easier. Quote Link to comment Share on other sites More sharing options...
Asday Posted July 11, 2007 Author Share Posted July 11, 2007 1. Have you created a user and set a password for it? 2. Have you got the correct username and/or password? 3. Are the permissions set? 4. If you installed WAMP go into cPanel which gives you access to phpMyAdmin. From there you can check everything via a GUI which will make everything a lot easier. 1) Yes 2) Yes 3) Don't know 4) Didn't install WAMP (Going home now, so no PC) Quote Link to comment Share on other sites More sharing options...
Asday Posted July 12, 2007 Author Share Posted July 12, 2007 (Going home now, so no PC) (Back now!) Quote Link to comment Share on other sites More sharing options...
keeB Posted July 14, 2007 Share Posted July 14, 2007 By default, the mysql root password is empty. To check this out, open the command prompt and do the following: cd c:\path\to\mysql\bin mysql -u root If this logs you in, then you need to do the following GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost' IDENTIFIED BY 'some_pass' WITH GRANT OPTION; Also, make sure to update the root password: UPDATE mysql.user SET password = PASSWORD('new_pass') where mysql.user = 'root'; Good luck Quote Link to comment Share on other sites More sharing options...
Asday Posted July 18, 2007 Author Share Posted July 18, 2007 By default, the mysql root password is empty. To check this out, open the command prompt and do the following: cd c:\path\to\mysql\bin mysql -u root If this logs you in, then you need to do the following GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost' IDENTIFIED BY 'some_pass' WITH GRANT OPTION; Also, make sure to update the root password: UPDATE mysql.user SET password = PASSWORD('new_pass') where mysql.user = 'root'; Good luck Would that be Linux or windoze command prompt? Quote Link to comment Share on other sites More sharing options...
keeB Posted July 18, 2007 Share Posted July 18, 2007 If you're running Linux, mysql should be in the PATH by default. so in that case, it would just be mysql -u root In windows, if not apart of the PATH, you must open a command prompt at c:\program files\mysql server 5.0\bin (or equivalent) and run the same command mysql -u root Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.