MySQL MariaDB

How to Enable PHP MySQL Extension?

PHP and MySQL are considered a Good combination by many people when making a choice for a dynamic website, and a few extensions are necessary to connect PHP to MySQL. PHP MySQL extensions are considered lightweight wrappers to layer C client libraries. MySQL recommends using their Native extensions mysqlnd and using either PDO_MySQL or mysqli for connectivity instead of using their old mysql extension.

This post will teach how to enable the PHP MySQL extension in detail. Make sure that PHP is installed in your system.

Enable PHP MySQL Extension

Go to the directory where PHP is installed:


Locate the “php.ini” file and open it with the Code editor or notepad:


Press CTRL + F to find “;extension” and press the arrow key:


Remove the semicolon from the beginning of the “extension=mysqli” and “extension=pdo_mysql” lines:


The next step is to find “on windows” and hit enter. Make sure to remove semi-colon from the beginning of “extension_dir” and the correct location of the PHP extension folder is added:


In this file multiple extensions are available, if you want to enable any other extension just remove the semicolon from its beginning:


Save this file and you have successfully enabled the PHP MySQL extension.

Conclusion

To enable the PHP MySQL extension, after installing PHP go to its directory and locate the php.ini file. Open the file in any code editor and find the word extensions, remove the semicolon from the beginning of sqli and PDO_mysql extension. Make sure that extension_dir contains the location of the PHP “ext” folder, and save the file after these changes.

About the author

Abdul Mannan

I am curious about technology and writing and exploring it is my passion. I am interested in learning new skills and improving my knowledge and I hold a bachelor's degree in computer science.