MySQL Tutorials - Herong's Tutorial Examples - Version 4.20, by Dr. Herong Yang
Configuring PHP for MySQL Server Access
A tutorial example is provided on how to configure the PHP engine for MySQL server connection access. Setting, extension=php_mysql.dll, needs to be turned on in the configuration file php.ini.
To use PHP programs to access MySQL servers, of course you need to install the PHP engine on you system first. If you need help on installing the PHP engine, please read my other tutorial book, "PHP Tutorials - Herong's Tutorial Examples".
Then you need to turn on the php_mysqli extension by editing \local\php\php.ini with:
You may also need to add \local\php\ext to the PATH system environment variable, because php_mysqli.dll is located in the \local\php\ext directory.
When I was ready to test the configuration, I ran this script:
<?php #- MySqlTest.php #- Copyright (c) 2015, HerongYang.com, All Rights Reserved. # $con = mysqli_connect('localhost','root','TopSecret'); print "MySQL server info = ".mysqli_get_server_info($con)."\n"; print "MySQL status = ".mysqli_stat($con)."\n"; mysqli_close($con); ?>
I got this output:
C:\herong>php -version PHP 5.6.6 (cli) (built: Feb 18 2015 16:02:19) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies C:\herong>php MySqlTest.php MySQL server info = 5.7.10-log MySQL status = Uptime: 46148 Threads: 1 Questions: 155 Slow queries: 0 Opens: 128 Flush tables: 1 Open tables: 117 Queries per second avg: 0.003
Cool, this confirmed that my PHP engine is configured to access my MySQL server.
Last update: 2015.
Table of Contents