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
Featured Articles:
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- My 10 UNIX Command Line Mistakes
- 10 Greatest Open Source Software Of 2009
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- Top 20 OpenSSH Server Best Security Practices
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Linux Video Editor Software
- Email FAQ to a friend
- Download PDF version
- Printable version
- Comment RSS feed
- Last Updated: 11/10/07



{ 6 comments… read them below or add one }
I m not able to connect localhost. error 3306
I reat the following message and am having the same problem. I used XAMPP to install the group for windows vista. I have also installed them individually for the internet and also from a disk I got from a SAMs book.
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?
I don’t understand the following answer, do I need to re-install MySQL or can I modify it? I would like to get all of them installed and be able to use mysqli functionality.
I have followed all of the different install proceedures and still can not get it to worl.
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.
i have my own domain and webserver i cant understand that why connection cannot be made to database of mysql with php
I am using wamp server and netbeans ide to write php. I am new to php development. I am not able to connect mysql to php. I don’t know what is happening? I am not able to insert data into mysql.
why this error message in happens:
Could not connect: Access denied for user ’sss’@'localhost’ (using password: YES)
hi i m new user to ubuntu.i could not connect to mysql server through php.
i have installed php5 ,mysql server ,apache server.
somebody can help me?????