How To Configure PDO Mysql Driver On Ubuntu
- Last Updated On: April 30, 2013
- By: Scriptcrunch Editorial
Step 1: Check the PHP info if the PDO driver is already installed. It will be automatically installed if you installed the latest lamp server. You can check the PHP info by running the following script on the server.
<? PHP
phpinfo ();
?>
Step 2: Run the script and you will find the whole PHP info. Click cntrl+F and check for PDO. You will find the PDO info like the image below.
Step 3: Just add the following line to the php.ini file. You can find the location of the php.ini file in the phpinfo page.
extension=pdo.so
Step 4: Restart the apache server using the following command.
sudo service apache2 restart
Step 5: run the following script to see if your PDO driver and mysql connection are working or not.
<? PHP
Define ( "DB_DSN", "mysql: host=host_name; dbname=yourdb_name" );
Define ( "DB_USERNAME", "your_username" );
Define ( "DB_PASSWORD", "your_password" );
Try {
$con = new PDO ( DB_DSN, DB_USERNAME, DB_PASSWORD );
} Catch (PDOException $e) {
Echo $e->getMessage ();
}
?>
Step 6: If you get the error ” driver not found”, you have to recheck your installation.
Scriptcrunch Editorial
Other Interesting Blogs
[50% OFF] Kubernetes Certification Coupons (CKA, CKAD, CKS, KCNA and KCSA)
Looking for CKA coupon and other Kubernetes certification coupon codes? You have come to the right place. Following are the list of
[80% OFF] Linux Foundation Coupon for December 2024
Looking for CKA Coupon and other Linux Foundation certifications coupons? We got you covered. With the latest Linux Foundation Coupon, you can
[65% OFF] Linux Foundation LFCA, LFCS & LFCT Exam Voucher Codes
Linux Foundation has announced up to a $284 discount on its Linux certification programs Linux Foundation Certified IT Associate (LFCA) and Linux