PHP and MySQL won't communicate with one another
I've installed Apache, MySQL and PHP on my Windows 2000 box. (Hopefully Linux will come soon.) All three are working fine. I know Apache is working because I can access localhost/ though my browser. I know PHP is working because I can get it to print out a page using phpinfo(). And I know MySQL is working because I can create, modify and use databases and tables from the command line.
The problem is they won't work together! I've tried a very simple PHP script (copied from a book) that should connect to my database. But, it instead gives me the following error message: :: Quote :: Warning: mysql_connect(): Client does not support authentication protocol requested by server; consider upgrading MySQL client in D:\Apache\Apache2\htdocs\index.php on line 19I'm positive there must be an easy solution to this one somewhere, but after hours of crawling over the manuals and a few forums, I've been unable to find the answer. What do I need to do to make this stuff work? Thanks in advance, Matthew Back to top |
|||||
It's hard to say right off. Did you install mysql, apache, and php separately, from install package binaries downloaded from their respective sites?
Did you install an all in one package like XAMP? When you install components this is the order you do it in: mysql, test and debug, make sure it runs. Once running: apache. once running, php. There's some required reading in this process, for example connecting php to apache is not automatic on install. First thing to do is test that php works, I assume it does, but double check using the classic <?php echo 'hello world'; ?> on the test localhost page, that's the default. You want to get off those defaults asap, by the way, configuring the virtual hosts files is the way to go. The problem was I am going to guess that when you installed apache it couldn't find mysql, possibly, quite likely, because you haven't started mysql as a service in windows 2k/nt. If it's not running as a service it's not running for apache. You can start it as a service from the command line in windows, or using the services and controller apps in your admistrative tools package, the windows one that is. Administrative tools -> services scroll down to mysql. Is it there? You need to set it as a service first, and an nt service, not a standard windows one, it's a different command line argument: c:\mysql\bin\mysqld-nt hopefully you installed it on the root, it's kind of a pain if you didn't. From mysql.com: :: Quote :: Before installing MySQL as a Windows service, you should first stop the current server if it is running by using the following command:
C:\> C:\mysql\bin\mysqladmin -u root shutdown This invokes the MySQL administrative utility mysqladmin to connect to the server and tell it to shut down. The command connects as root, which is the default administrative account in the MySQL grant system. Note that users in the MySQL grant system are wholly independent from any login users under Windows. Now install the server as a service: Note: Important, for Windows NT you need to add this to mysqld-nt where it says mysqld below: C:\> mysqld --install If you have problems installing mysqld as a service using just the server name, try installing it using its full pathname: C:\> C:\mysql\bin\mysqld --install Once this is installed, you should be able to go to the services app in administrative tools and right click on mysql, it should be running, and it should show you the command that starts it, and it should be set to start automatically. Please note, I'm doing this off the top of my head, so I might be missing some pieces. Once mysql is definitely running as a service, apache finds it if I remember right, might be one configuration tweak, you need to do, I'll check. Read this from mysql.com for further trouble shooting Here's another install procedure for setting up the whole package. Once mysql is running as a service I believe Apache finds it fine, could be wrong on that. Back to top |
|||||
Hi, thanks for your reply. I was hoping this was a quick tweak to the Apache .conf file or something but I guess it isn't.
I installed Apache, PHP and MySQL separately, in that order. From your instructions, it looks like I may have done it all wrong. I think I'll try uninstalling Apache, then reinstall it to start with. Maybe it will pick up on MySQL that way. Otherwise I guess I'll start over. MySQL is running as a service, I checked that several times. But Apache hasn't picked up on it yet, so I guess it isn't automatic. (Incidentally, how does one delete services from Windows? I can't find a way to do it . . . ) Unfortunately I may have to wait awhile before I can get back to this. I had a little time yesterday, but I'm not likely to have more "free time" for this kind of thing for a week or more. I'll post back here when I get it working (or don't, whichever comes first! ;) ) Back to top |
|||||
All times are GMT - 8 Hours
|