How to connect databases using PHP on Linux (CentOs 7)?

The truth is that connecting by command line with MySQL and connecting by PHP has little to do.

If you have a PHP script that you want to connect against the database you have to write the connect statement in PHP.

$mysqli = mysqli_connect(“localhost”, “username”, “password”, “database”);

As simple as that. Then you already use the PHP functions to work with MySQL, which are documented on the PHP website in .

In this WebDevelopment article you also have something: And in the more detailed information, only that some articles use the old MySQL extension that was “mysql” instead of “mysqli”.

And then, if you asked how to run that on Linux? (Centos or any other distribution is the same), you need a web server and have installed the PHP extension. Typical is Apache. You have more info here: but be aware that the versions of PHP or MySQL are changing, so you would still have to look for the appropriate commands for modern versions.

See also  What is a Webmaster
Loading Facebook Comments ...
Loading Disqus Comments ...