Tag Archives: mysql

MySQL – Load data from csv

The LOAD DATA INFILE statement will reads rows from a text/csv file and insert the data into a table at high speed. We need to pass the complete path/location of the file in the query. LOAD DATA INFILE is similar to that of SELECT … INTO OUTFILE. To write data from a table to a… Read More »

MySQL Insert Query

In this post we will know about MySQL Insert Query by using select query. There are multiple ways to insert data in a table as shown below. INSERT INTO table_name (col1,col2) VALUES(val1,val2); OR INSERT INTO table_name (col1,col2) VALUES(row1_val1,row1_val2),(row2_val1,row2_val2),(row3_val1,row3_val2); In the same way we can use the select the query to insert the data from one… Read More »

Mysql Storage Engines

MySQL supports multiple storage engines. Storage Engines are MySQL components that handle the SQL operations for different table types and helps us to increase the database performance. So it is necessary to know about the MySQL storage engines so that we can use the right storage engines for our tables in the database. MySQL storage engines… Read More »

PHP : Connect to the MySQL Server – Part 3

PDO’s:- The PHP Data Objects new way to connect the Database in php programming. As the mysql_connect() is deprecated and mysqli_connect() functions do not support transaction mechanism PDO came into picture. PDO’s support  transactions - auto-commit, prepared statements, calling stored procedures and error handling. The easy way to use the PDO’s <?php $db = new PDO(‘mysql:host=localhost;dbname=testdb;charset=utf8′,… Read More »

PHP : Connect to the MySQL Server – Part 2

As mysql_connect() is deprecated from the PHP 5.5 version and above . So we use the mysqli_connect() function to connect the MySQL server. mysqli_connect() example :- Syntax:- mysqli_connect(<Server name/Host name >,<MySQL – Username>,<MySQL – Password>,<databsename>); <?php $dbLink = mysqli_connect( ‘localhost’, ‘username’, password’,’testDB’); if (!$dbLink ) {     die(‘Could not connect to the MySQL  Server: ‘ . mysqli_connect_error()); } echo ‘Database connection is successful.’; mysqli_close($dbLink ); ?> The… Read More »

PHP : Connect to the MySQL Server – Part 1

In order to connect to MySQL database using PHP we have multiple options. Before this we must have XAMPP installed in our system. 1. mysql_connect () - This extension is deprecated as of PHP 5.5.0, and will be removed in the future. 2. mysqli_connect — Alias of mysqli::__construct() 3. PDO -  PHP Data Objects (PDO). mysql_connect() example :- Syntax:- mysql_connect( <Server name/Host name >,<MySQL… Read More »