tags:

views:

72

answers:

2

Hi I have installed php5 and mysql5 on my server , I can login to mysql from command, but when I try to connect using php I got this error message:

Access denied for user 'root'@'localhost' (using password: YES)PHP Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in D:\HostingSpaces\law-training\lawtraining.ir\wwwroot\includes\class.php on line 279 PHP Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in

I dont use 'ODBC'@'localhost' in my code at all. I check using phpmyadmin , also I can't use it and can't connect to server.I use port 3309 for mysql , and from local or remote php can't login. I use also mysql4 on this server on port 3306 and I can use it without problem. how can i fix this problem?

Thanks

+1  A: 

Try logging in to localhost:3309, I think you'll find that you're running it on a non-standard port, so you need to tell PHP where to look for the server.

ie.

mysql_connect("localhost:3309", "root", "mypassword");

As a sidenote, the ODBC@localhost connection is what mysql_query tries to use if there's no connection already open.

Matthew Scharley
A: 

Is this a brand new MySQL 5 installation, and you have no means to log into it? You may want to reset the root password.

http://dev.mysql.com/doc/refman/5.1/en/resetting-permissions.html

That should enable you to access MySQL using the command line. Then, make sure you have a root@localhost user and grant the relevant permissions to that user. For example:

mysql> GRANT ALL PRIVILEGES ON . TO 'root'@'localhost' -> IDENTIFIED BY 'some_pass' WITH GRANT OPTION;

If the problem persists with odbc connections, make sure your odbc data access product is fully compatible with your version of MySQL 5.x

Regards, Netrista Khatam Technical Services Manager OpenLink Product Support