0

I have the latest version of Apache (Apache 2.4), latest version of PHP (PHP7), and latest version of MySQL (not sure the version but I have WorkBench version 6.3). In the past, when I checked if my PHP was working by this line of code <?php phpinfo(); ?> it would show that I have MySQL / mysqli installed and ready to go. But with PHP7 it shows mysqlnd.

I try using mysqli commands to check if I can connect to my database by mysqli_ping() and I also tried connecting to the database using server, user, pass. I keep getting errors such as Class mysqli not found. Or Call to undefined function mysqli_ping(). I've tried searching the net for some answers and All I could find was that I need to install MySQL (but a few sites said it was deprecated).

Am I able to get mysqli for PHP7? Or do I use mysqlnd? What is mysqlnd? Is it a new version of MySQL/mysqli?

Dharman
  • 30,962
  • 25
  • 85
  • 135
Vince
  • 2,596
  • 11
  • 43
  • 76
  • Mysqlnd is mentioned in php docs, so you can easily find an answer to some of your questions. About mysqli: Have you tried to just install mysqli extension? I would suggest to use PDO, but if you feel comfortable with mysqli and it's something small, you can still use mysqli. – Mateusz Sip Apr 16 '17 at 02:41

3 Answers3

1

Update 2020

For Windows 10 users I strongly recommend windows subsystem for linux (WSL 2) and setup your server there.

If you need php and mysql access in windows environment, then the fastest way is to install Wampserver. If you also need access to php through console then add php location (like C:\wamp64\bin\php\php7.4.11) to environment variables.

If that doesn't suit you and you need full setup always enabled on your system then follow install with choco.


To work properly with apache and load all needed extensions (including php_mysqli) you need ThreadSafe version of PHP, so make sure to download correct version or if you use Chocolatey to manage your windows applications, then just install php with this command:

choco install php --package-parameters='"/ThreadSafe "'.

This will install php in C:\tools\php72 directory, but you can overwrite it with another parameter:

choco install php --package-parameters='"/ThreadSafe ""/InstallDir:C:\PHP"""'.
Sharak
  • 888
  • 8
  • 17
0

The mysqlnd extension is part of PHP. It was developed as an alternative to bundling the libmysqlclient, because that library had license conditions that made it awkward to bundle with PHP.

You won't use mysqlnd directly. It's an internal library that is used by mysqli and pdo_mysql as a means to communicate with the MySQL Server.

As for mysqli, yes, it's available for PHP 7. I don't use Windows, but apparently not all extensions are enabled by default.

You probably need to edit your php.ini and uncomment the line

extension=ext_mysqli.dll

or whatever it is for that extension. It might already be in the file, but commented out. So go take a look and see.

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
  • I did that already. That was the first thing I checked. I think theres something wrong with my mysql installation. I just tried accessing from the command line and it's saying it can't connect to MySQL server on 'localhost'. I tried looking for how to start mysql (in case its not started) and everything points to calling mysqld (which isn't showing up for me) – Vince Apr 16 '17 at 03:00
  • Refer to https://dev.mysql.com/doc/refman/5.7/en/windows-start-service.html for help on starting MySQL Service on Windows. – Bill Karwin Apr 16 '17 at 04:42
0

Check if your system path environmental variable includes the PHP installation directory. That worked for me on with PHP 7.1 / Apache 2.4 / Windows Server 2016.

emanresu
  • 141
  • 2
  • 5