PHP not connecting to a MySQL database server
Q. I have Apache Web server and MySQL configured. Everything works fine except I am not able to connect to a MySQL database server (I am able to connect mysql server with mysql client). So how do I configure or connect PHP scripts?
A. You need to install MySQL module for php4 or php5. Without php-mysql shared object or module, php scripts won't able to connect to MySQL database server.
Debian / Ubuntu Linux User
To install type the following command:
# apt-get install php4-mysql
if you are using PHP5, enter:
# apt-get install php5-mysql
RHEL <= 4 user
If you are using Red Hat Linux:
# up2date php-mysql
If you are using Fedora / CentOS / RHEL 5 Linux:
# yum install php-mysql
Restart apache to take effect. Now you will be able to connect MySQL via PHP scripts.
# service httpd restart
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Other Helpful FAQs:
- How do I access MySQL server from the shell prompt (command line)?
- MySQL empty database / delete all tables
- Mysql user creation - setting up a MySQL new user account
- MySQL Change root Password
- Restore a backup of a MySQL Database Server
Discussion on This FAQ
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: apache web server, CentOS, fedora, install mysql, install php, linux user, mysql client, mysql database server, mysql module, mysql server, php mysql, php scripts, php4, php5, red hat linux, rhel 5, shared object, Ubuntu Linux, up2date, yum



December 20th, 2007 at 4:25 pm
I m not able to connect localhost. error 3306