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? Link to comment https://forums.phpfreaks.com/topic/59420-mysql/ Share on other sites More sharing options...
Vibralux Posted July 11, 2007 Share Posted July 11, 2007 Are you on shared hosting? Link to comment https://forums.phpfreaks.com/topic/59420-mysql/#findComment-295234 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. Link to comment https://forums.phpfreaks.com/topic/59420-mysql/#findComment-295237 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? Link to comment https://forums.phpfreaks.com/topic/59420-mysql/#findComment-295246 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) Link to comment https://forums.phpfreaks.com/topic/59420-mysql/#findComment-295255 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. Link to comment https://forums.phpfreaks.com/topic/59420-mysql/#findComment-295257 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 Link to comment https://forums.phpfreaks.com/topic/59420-mysql/#findComment-295264 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. Link to comment https://forums.phpfreaks.com/topic/59420-mysql/#findComment-295267 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. Link to comment https://forums.phpfreaks.com/topic/59420-mysql/#findComment-295286 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? Link to comment https://forums.phpfreaks.com/topic/59420-mysql/#findComment-295290 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. Link to comment https://forums.phpfreaks.com/topic/59420-mysql/#findComment-295301 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. Link to comment https://forums.phpfreaks.com/topic/59420-mysql/#findComment-295304 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) Link to comment https://forums.phpfreaks.com/topic/59420-mysql/#findComment-295495 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!) Link to comment https://forums.phpfreaks.com/topic/59420-mysql/#findComment-296200 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 Link to comment https://forums.phpfreaks.com/topic/59420-mysql/#findComment-297942 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? Link to comment https://forums.phpfreaks.com/topic/59420-mysql/#findComment-301043 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 Link to comment https://forums.phpfreaks.com/topic/59420-mysql/#findComment-301285 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.