villermen Posted June 27, 2009 Share Posted June 27, 2009 I've just installed MySQL on my computer, and got it all running now.The problem is when I try to connect to MySQL via PHP, it gives an error message.The error message given is: Could not connect: Access denied for user 'ODBC'@'localhost' (using password: NO)PHP Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'ODBC'@'localhost' (using password: NO) in [[path to file (hid it)]] on line 2 The .php file run only contains the following part from the MySQL connect tutorial: <?php$con = mysql_connect();if (!$con) { die('Could not connect: ' . mysql_error()); }?> Why and how is the acces denied?I can't find out where the problem lies, can anybody help me fixing it?Website:IIS (run from localhost)PHP 5.2.10 (run from localhost/linked to IIS/working fine/mysql extension supported)MySQL 5.1 (configured with no password and username)Gr.Villermen Link to comment Share on other sites More sharing options...
Ingolme Posted June 27, 2009 Share Posted June 27, 2009 The mysql_connect() function has three parameters:mysql_connect(server,username,password) Link to comment Share on other sites More sharing options...
villermen Posted June 27, 2009 Author Share Posted June 27, 2009 Those parameters are optional...mysql_connect() sets the parameters at his default: localhost:3306,no username,no password (like I configured my MySQL server) Link to comment Share on other sites More sharing options...
Ingolme Posted June 27, 2009 Share Posted June 27, 2009 It's trying to connect with the user "ODBC", is that the username of your MySQL server? Link to comment Share on other sites More sharing options...
villermen Posted June 27, 2009 Author Share Posted June 27, 2009 I don't know, where can I see/change the servername? It's not in the configuration file Link to comment Share on other sites More sharing options...
Synook Posted June 28, 2009 Share Posted June 28, 2009 Just fill in the parameters of mysql_connect() it's trying to do mysql_connect("localhost", "ODBC", ""), because, if you read the manual for mysql_connect() http://www.php.net/mysql_connect it doesn't actually use "localhost:3306,no username,no password" as default, it uses values from php.ini.Try entering the correct details and seeing what happens Link to comment Share on other sites More sharing options...
villermen Posted June 28, 2009 Author Share Posted June 28, 2009 Thank you, but what is my username? Just the name of my computer? Link to comment Share on other sites More sharing options...
Ingolme Posted June 28, 2009 Share Posted June 28, 2009 I'm not sure about IIS. The default username when I installed WAMP is "root" Link to comment Share on other sites More sharing options...
villermen Posted June 28, 2009 Author Share Posted June 28, 2009 I'll try to find my username, any hints on where I can find it are welcome =) Link to comment Share on other sites More sharing options...
villermen Posted June 28, 2009 Author Share Posted June 28, 2009 It's the same with me.I just tried the username "root", and it worked fine.I don't know yet why, but I can live with thatThanks all Link to comment Share on other sites More sharing options...
Synook Posted June 28, 2009 Share Posted June 28, 2009 You can change the username and password, or add new users.http://www.cyberciti.biz/faq/mysql-change-root-password/ (works for Windows too, cd into the mysql\mysqlx.x.xx\bin\ directory). Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.