How to Connect MySQL Database with PHP Websites?
What is PHP?
PHP is a general purpose server side scripting language that we can use to develop dynamic web sites and applications. PHP only needs to be installed on the web server that will host the web application and client applications can access the server resources via web browsers. The diagram shown below illustrates the basic architecture of a PHP web application.

Why PHP?
You have obviously the head of a number of programming languages out there; you may be wondering why we would want to use PHP over other languages to develop our video library application? PHP just like MySQL is open source and free, you don’t need to pay for you to get PHP; all you have to do is download it. Packages such as XAMPP come bundled already with a web server, MySQL and PHP among others. This is also unbelievably free. This makes PHP a cost-effective choice compared to other scripting languages such as CFML or ASP.
Another benefit that you get with PHP is that it’s a server-side scripting language; this means you only need to install it on the server and client computers requesting for the resources from the server do not need to have PHP installed; only a web browser would be enough.
PHP also has inbuilt support for working hand in hand with MySQL; this doesn’t mean you can’t use PHP with other database management systems.
PHP is cross-platform which means you can deploy your application on a number of different operating systems such as Windows, Linux, Mac OS etc[Ref.].
What is MySQL?
MySQL is the popular DBMS today, that can be used for all types and all size Projects. It can handle a huge volume of Data any problem for Newbies or Professionals.
MySQL is a relational database management system based on SQL – Structured Query Language. It used in all most all areas Like; Insurance, Banking, Universities, Student Projects, Data Mining, Data Warehousing etc. The most common use for this is for the purpose of a web database. It can be used to store anything from a single record of information to an entire inventory of available products for an online store.
Many of the world’s largest and fastest-growing organizations including Facebook, Google, Adobe, Alcatel Lucent and Zappos rely on MySQL to save time and money powering their high-volume Web sites, business-critical systems and packaged software[Ref].
Why Choose MYSQL?
1) Secure Money Transactions
2) On-Demand Scalability
3)High Availability
4)Rock-Solid Reliability
5)Quick-Start Capability
6)Performance & Scalability
7) Open Source
PHP and MySQL
PHP and MySQL are like two different sides of the same coin. Just like MySQL has built-in functions for data manipulations, so does PHP has built-in functions for connecting to MySQL server and manipulating the data in the database. Let’s now look at some of the PHP functions that allow us to manipulate MySQL databases
Advantages of Using PHP and My SQL
1) Flexibility
2) Supports Multi-Database
3) Easy Implementation
4) Open Source
Basic Requirement for PHP and My SQL
- WAMP Server
- LAMP Server
- MAMP Server
- XAMPP Server
- Text Editor
In this article, I’ll discuss how to connect MySQL Database on different servers and I’ll also give you an overview of connecting Database in Tow Ways.
- Connect MySQL using Localhost Server
- Connect MySQL using Remote MySQL
