Connection to MySQL database using PHP is very simple and includes only few steps. First of all we establish a connection to database using username and password. Then we select the database that is already created using MySQL console or PhpMyAdmin. Then some operations are performed on data and finally we close the connection.
For the connection to MySQL, we need a database. So lets create a database with name testDB having one table user with three fields id, username and password using MySQL console. Enter the following command in MySQL console and hit Enter. (MySQL console is generally located in C:\wamp\bin\mysql\mysql5.1.36\bin in WAMP server, the mysql version may be different in your case)
mysql> CREATE DATABASE testDB;
It creates a database with name testDB. In order to perform the operations on a database we must use the database. So to use the database testDB, insert the following command and hit enter.
mysql> USE testDB;
Now we create a table with fields id, username and password.
تعليقات: 0
إرسال تعليق