SlideShare a Scribd company logo
PHP – Database connection with mysql Harit Kothari [email_address]
Agenda Installation service, port, Running through WAMP Database creation Table creation mysqldump and mysqlimport utility phpmyadmin utility
Installation Download mysql database installation pack Install it by following manual steps Start mysql service by using appropriate menu
service, port, Running through WAMP mysql runs as a OS service This service provides access to database To access, we require 2 parameters: Service host name Port PHP supports many RDBMS mysql is most suitable and famous with PHP
Database & Table creation Either use phpmyadmin to create / alter OR Go to mysql prompt and execute as under: shell>create database db_name shell>create table table_name (colname datatype [size] [, ....] constraints...)
Data source names / DSN Syntax: dbsyntax://username:password@protocol+hostspec/database Where: dbsyntax represents RDBMS name Username & password of database user for authentication Protocol is optional – e.g. TCP Hostspec is hostname on which datbase service is running Database is actual database name under dbsyntax
DSN Examples mysql:///webdb mysql://localhost/webdb mysql://bondview@localhost/webdb mysql://bondview@tcp+localhost/webdb mysql://bondview:007@localhost/webdb
Syntax DataBase Mysql MySQL Pgsql PostgreSQL Ibase InterBase Msql Mini SQL Mssql Microsoft SQL Server oci8 Oracle 7/8/8i Odbc ODBC Sybase SyBase Ifx Informix Fbsql FrontBase
Database connection $db = DB::connect(DSN [, options ]); DB::isError($db) This will return if any error occurred while connecting to DataBase with DSN Options are: persistent - Connection persists between accesses optimize - What to optimize for debug - Display debugging information
Mysqldump – Dumping DataBase A utility to dump database for backup or offline modification A CLI utility that can be executed from SQL prompt to take regular backup of database / table as per requirements
Ways to dump sql DB shell> mysqldump [options] db_name [tables] shell> mysqldump [options] --databases db_name1 [db_name2 db_name3...] shell> mysqldump [options] --all-databases
Play with PHP Connect to database : mysql_connect("host_name", "db_username", "db_password"); Select Database : mysql_select_db("db_name");
Mysqlimport – Import data Import database, by importing one oe more text files Syntax: shell> mysqlimport options db_name input_file Useful especially while importing data from CSV files that contains data
phpmyadmin Manage mysql database – an administration tool Tool itself written in PHP to manage DataBase effectively and easily Supports operations like create, modify, dump and delete database, table, views etc Very easy to use, GUI
Summary
Whats next?

More Related Content

What's hot (19)

PDF
lab56_db
tutorialsruby
 
PPT
Php MySql For Beginners
Priti Solanki
 
PPT
MySQL
Gouthaman V
 
PPTX
Mysql
lotlot
 
PPT
PHP and MySQL
webhostingguy
 
PPT
PHP - Getting good with MySQL part II
Firdaus Adib
 
PPT
PHP - PDO Objects
AJINKYA N
 
PPT
Php classes in mumbai
aadi Surve
 
PDF
PDO Basics - PHPMelb 2014
andrewdotcom
 
PPTX
Cake PHP 3 Presentaion
glslarmenta
 
PPT
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
webhostingguy
 
PPT
Synapse india reviews on php and sql
saritasingh19866
 
ODP
Adodb Pdo Presentation
Tom Rogers
 
PDF
MySQL for beginners
Saeid Zebardast
 
PPTX
Php and database functionality
Sayed Ahmed
 
PPTX
Learn PHP Lacture2
ADARSH BHATT
 
PDF
backend
tutorialsruby
 
lab56_db
tutorialsruby
 
Php MySql For Beginners
Priti Solanki
 
Mysql
lotlot
 
PHP and MySQL
webhostingguy
 
PHP - Getting good with MySQL part II
Firdaus Adib
 
PHP - PDO Objects
AJINKYA N
 
Php classes in mumbai
aadi Surve
 
PDO Basics - PHPMelb 2014
andrewdotcom
 
Cake PHP 3 Presentaion
glslarmenta
 
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
webhostingguy
 
Synapse india reviews on php and sql
saritasingh19866
 
Adodb Pdo Presentation
Tom Rogers
 
MySQL for beginners
Saeid Zebardast
 
Php and database functionality
Sayed Ahmed
 
Learn PHP Lacture2
ADARSH BHATT
 
backend
tutorialsruby
 

Similar to Database Connection With Mysql (20)

PPT
Mysql DBI
Joe Christensen
 
PPT
My sql with querys
NIRMAL FELIX
 
PPT
MYSQL
Ankush Jain
 
PPTX
Phpmyadmin administer mysql
Mohd yasin Karim
 
ODP
My sql Syntax
Reka
 
PPT
Mysql
Rathan Raj
 
PDF
lab56_db
tutorialsruby
 
PPT
Lecture 15 - MySQL- PHP 1.ppt
TempMail233488
 
PPT
qwe.ppt
Heru762601
 
PPT
Download It
webhostingguy
 
PDF
MySQL Backup and Security Best Practices
Lenz Grimmer
 
PDF
Sqlite perl
Ashoka Vanjare
 
PPTX
MySQL DBA OCP 1Z0-883
Kwaye Kant
 
ODP
My sql
Nadhi ya
 
PDF
BITS: Introduction to relational databases and MySQL - Schema design
BITS
 
PPT
My sql presentation
Nikhil Jain
 
PPTX
Chapter 3.1.pptx
mebratu9
 
PPTX
Exporting And Importing Data In Mysql
mysql content
 
Mysql DBI
Joe Christensen
 
My sql with querys
NIRMAL FELIX
 
Phpmyadmin administer mysql
Mohd yasin Karim
 
My sql Syntax
Reka
 
Mysql
Rathan Raj
 
lab56_db
tutorialsruby
 
Lecture 15 - MySQL- PHP 1.ppt
TempMail233488
 
qwe.ppt
Heru762601
 
Download It
webhostingguy
 
MySQL Backup and Security Best Practices
Lenz Grimmer
 
Sqlite perl
Ashoka Vanjare
 
MySQL DBA OCP 1Z0-883
Kwaye Kant
 
My sql
Nadhi ya
 
BITS: Introduction to relational databases and MySQL - Schema design
BITS
 
My sql presentation
Nikhil Jain
 
Chapter 3.1.pptx
mebratu9
 
Exporting And Importing Data In Mysql
mysql content
 
Ad

More from Harit Kothari (9)

PPTX
Key areas for successful software delivery
Harit Kothari
 
PPTX
Basic Intro to iOS
Harit Kothari
 
PPT
Introduction to Handoff
Harit Kothari
 
ODP
Free & Open Source - an introduction
Harit Kothari
 
PPT
OWASP Top 10 : Let’s know & solve
Harit Kothari
 
ODP
Form Processing In Php
Harit Kothari
 
ODP
Session Management & Cookies In Php
Harit Kothari
 
ODP
Coding In Php
Harit Kothari
 
ODP
Starting With Php
Harit Kothari
 
Key areas for successful software delivery
Harit Kothari
 
Basic Intro to iOS
Harit Kothari
 
Introduction to Handoff
Harit Kothari
 
Free & Open Source - an introduction
Harit Kothari
 
OWASP Top 10 : Let’s know & solve
Harit Kothari
 
Form Processing In Php
Harit Kothari
 
Session Management & Cookies In Php
Harit Kothari
 
Coding In Php
Harit Kothari
 
Starting With Php
Harit Kothari
 
Ad

Recently uploaded (20)

PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 

Database Connection With Mysql

  • 1. PHP – Database connection with mysql Harit Kothari [email_address]
  • 2. Agenda Installation service, port, Running through WAMP Database creation Table creation mysqldump and mysqlimport utility phpmyadmin utility
  • 3. Installation Download mysql database installation pack Install it by following manual steps Start mysql service by using appropriate menu
  • 4. service, port, Running through WAMP mysql runs as a OS service This service provides access to database To access, we require 2 parameters: Service host name Port PHP supports many RDBMS mysql is most suitable and famous with PHP
  • 5. Database & Table creation Either use phpmyadmin to create / alter OR Go to mysql prompt and execute as under: shell>create database db_name shell>create table table_name (colname datatype [size] [, ....] constraints...)
  • 6. Data source names / DSN Syntax: dbsyntax://username:password@protocol+hostspec/database Where: dbsyntax represents RDBMS name Username & password of database user for authentication Protocol is optional – e.g. TCP Hostspec is hostname on which datbase service is running Database is actual database name under dbsyntax
  • 7. DSN Examples mysql:///webdb mysql://localhost/webdb mysql://bondview@localhost/webdb mysql://bondview@tcp+localhost/webdb mysql://bondview:007@localhost/webdb
  • 8. Syntax DataBase Mysql MySQL Pgsql PostgreSQL Ibase InterBase Msql Mini SQL Mssql Microsoft SQL Server oci8 Oracle 7/8/8i Odbc ODBC Sybase SyBase Ifx Informix Fbsql FrontBase
  • 9. Database connection $db = DB::connect(DSN [, options ]); DB::isError($db) This will return if any error occurred while connecting to DataBase with DSN Options are: persistent - Connection persists between accesses optimize - What to optimize for debug - Display debugging information
  • 10. Mysqldump – Dumping DataBase A utility to dump database for backup or offline modification A CLI utility that can be executed from SQL prompt to take regular backup of database / table as per requirements
  • 11. Ways to dump sql DB shell> mysqldump [options] db_name [tables] shell> mysqldump [options] --databases db_name1 [db_name2 db_name3...] shell> mysqldump [options] --all-databases
  • 12. Play with PHP Connect to database : mysql_connect("host_name", "db_username", "db_password"); Select Database : mysql_select_db("db_name");
  • 13. Mysqlimport – Import data Import database, by importing one oe more text files Syntax: shell> mysqlimport options db_name input_file Useful especially while importing data from CSV files that contains data
  • 14. phpmyadmin Manage mysql database – an administration tool Tool itself written in PHP to manage DataBase effectively and easily Supports operations like create, modify, dump and delete database, table, views etc Very easy to use, GUI