简体   繁体   中英

MySQL not connecting with PHP

I installed MySQL server and everything worked fine in command line. I worked connecting MySQL to my ASP.NET application and there is no problem at all. But when I try to connect MySQL to PHP applications I am unable to connect. When I installed PHPMyAdmin I am getting error #2002 Connot log in to thie MySQL server

I browsed all the night for this error and none of Google's results helped me! :(

Anybody can you please tell me where the problem is at? I believe I must change my PHP.ini file settings in order to connect to MySQL. Anybody please help me.

There are a lot of things that can cause this type of issue. Did you make sure that you have added php-mysql drivers to your sever. Since you said your using ASP i will assume that you are using windows servers. Make sure that you also are allowing that user to connect via localhost or what ever ip the PHP is on.

In php there are to standered ways of connecting to a MySQL database.

  1. php-mysql(is going to be depercated soon).
  2. php-mysqli(OOP version of the php-mysql with lots of features).

With out one of these php will be unable to work with a MySQL database. I am not sure if phpmyadmin works with both drivers or just one of them It could be throwing a die("message") Just to let you know it is not working instead of throwing a more complex php error. You may want to see if you can incress error reporting.

You can check if your php installastion has the mysql driver by looking in your php.ini and also checking with.

phpinfo();

It is almost always about config. https://bbs.archlinux.org/viewtopic.php?id=90133

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM