Enter your Sign on user name and password.

Forgot password?
Sign In | Subscribe
Start learning today, and be successful in your academic & professional career. Start Today!
Use Chrome browser to play professor video
Matthew M.

Matthew M.

Introduction to MySQL

Slide Duration:

Table of Contents

I. Advanced PHP with MySQL
Course Introduction

13m 36s

Intro
0:00
Advanced PHP w/ MySQL
0:13
Course Introduction
0:14
Course Content
0:59
Web Application: Educator Store
1:45
Web Application: Educator Store
1:46
Object-Oriented Programming
6:09
Object-Oriented Programming Overview
6:10
MySQL
6:50
MySQL Overview
6:51
Example: Command Prompt & MySQL
8:34
What You Will Learn
9:34
What You Will Learn
9:35
Course Prerequisites
11:52
Course Prerequisites
11:53
Advanced Course Development Environment

18m 46s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
Development Environment Setup
1:36
Firefox Web Browser, XAMPP, and PSPad Text Editor
1:37
Course Directory Structure
4:36
Course Directory Structure
4:37
phpDocumentor
7:23
phpDocumentor Overview
7:24
Parsing Source Code
7:44
docs Subdirectory
9:06
Asvanced PHP Course Documentation Example
10:21
Previous Educator PHP Students
14:14
Lib Directory Changes
14:38
Images Directory Changes
14:57
VERSION Constant
15:40
Comments Noting a Specific Version Number
17:04
Homework Challenge
17:30
Homework Challenge
17:31
Introduction to File I/O

35m 37s

Intro
0:00
Lesson Overview
0:10
Lesson Overview
0:11
File I/O
1:34
File I/O Overview
1:35
Performing file I/O: 3 Steps
1:52
File Permissions
2:28
Read Permission & Write Permission
2:29
fopen()
4:47
fopen()
4:48
Two Required Parameters
5:01
Successful fopen(): File Handle and Resource
5:21
FALSE and E_WARNING Error
6:00
Example
6:39
File Paths
7:10
File Paths
7:11
File Access Modes
9:18
File Access Modes
9:19
Coding Example: fopen()
10:31
Using Relative and Absolute Path & Non-Existent File
10:32
File Pointers
15:55
File Pointers
15:56
Example File
16:11
Opening a File with fopen() Using 'r' as the Access Mode
16:22
fgets()
17:55
fgets() Overview
17:56
Coding Example: fgets() - Reading a Line at a Time
18:26
feof()
20:10
feof() Overview
20:09
Coding Example: feof()
20:50
fclose()
23:43
fclose() Overview
23:44
Coding Example: fclose()
25:02
Coding Example: Current Stock
26:10
Coding Example: Current Stock
26:11
trim ()
31:39
trim () Overview and Example
31:40
Homework Challenge
33:35
Homework Challenge
33:36
Web Application Development

36m 36s

Intro
0:00
Lesson Overview
0:16
Lesson Overview
0:17
Version 1.0 Changelog
0:31
catalog.php
0:32
Function Library: fileLIB.php
5:00
Version 1.1 Changelog
27:12
createItemDataArray() and createDeptDataArray()
27:13
outputSimpleItemLink() and outputSimpleDeptLink()
32:06
HTTP & the POST Method

34m 36s

Intro
0:00
Lesson Overview
0:10
Lesson Overview
0:11
HTTP Model
1:28
HTTP Model
1:29
Client-Server Model 2 Steps Process
2:00
HTTP Messages
2:23
HTTP Messages
2:24
HTTP Requests
3:09
HTTP Requests
3:10
Example: HTTP Request Header
3:17
Coding Example: HTTP Requests
4:29
HTTP Responses
7:15
HTTP Responses
7:16
Example: HTTP Response (Header & Body)
8:00
header()
11:47
header() Overview
11:48
Coding Example: header
14:02
Coding Example: header() Error
14:52
GET Method
18:55
GET Method
18:56
Coding Example: GET Method
20:13
POST Method
21:09
POST Method
21:10
Coding Example: Sample Form Using the POST Method
23:50
Accessing POST Data in PHP
26:38
Accessing POST Data in PHP
26:39
Coding Example: Accessing POST Data via $_POST
28:15
GET vs. POST
29:54
GET vs. POST
29:55
Example: Accessing POST Data via $_POST
31:20
Example: Accessing POST Data via $_POST
31:21
Homework Challenge
33:00
Homework Challenge
33:01
Web Application Development

14m 11s

Intro
0:00
Version 2.0 Changelog
0:09
Updating the Site's Current Form to Use the POST Method
0:10
Creating Admin Website
2:55
Dynamically Generated Department List
12:40
Writing to Files

17m 38s

Intro
0:00
Lesson Overview
0:09
Lesson Overview
0:10
Review of File I/O
0:40
Review of File I/O
0:41
fwrite()
1:38
fwrite()
1:39
fputs()
2:20
'r+'
2:31
Coding Example: fwrite()
2:59
fopen() Access Modes
8:41
'a' and 'a+'
8:42
'w' and 'w+'
11:34
Homework Challenge
14:47
Homework Challenge
14:48
Web Application Development

28m 14s

Intro
0:00
Lesson Overview
0:08
Lesson Overview
0:09
Updated Open File Functions
0:19
openItemsDataFile ( ), openDeptsDataFile ( ), and openLastAddedFile ( )
0:20
insertItem()
6:25
insertItem() Overview
6:26
Functions: createItemDataString ( ) and updateLastItemAdded ( )
7:07
addItemToDepartment ()
16:03
addItemToDepartment () Overview
16:04
Functions: createDeptDataString ( ) and updateDepartment ( )
17:55
HTTP POST: File Uploads

22m 51s

Intro
0:00
Lesson Overview
0:10
Lesson Overview
0:11
POST Data Encoding
1:13
POST Data Encoding
1:14
When Data is Included in the Body of the HTTP POST Request and is of the Content Type
1:31
When Uploading Files Using HTTP POST
3:17
Uploading Files
6:22
Uploading Files
6:23
If Encoding Type is Not Set to Multipart/Formdata
9:27
$_FILES Superglobal
10:59
$_FILES Superglobal
11:00
Structure of $_FILES
12:15
Structure of $_FILES: Name, Type, tmp_name, Error, and Size
12:16
Coding Example: $_FILES Superglobal
13:34
Moving an Uploaded File
15:39
Introduction to Moving an Uploaded File
15:40
move_uploaded_file ( ): Definition and Example
16:40
Homework Challenge
21:19
Homework Challenge
21:20
Web Application Development

15m 30s

Intro
0:00
Lesson Overview
0:09
Lesson Overview
0:10
Uploading Item Image File
1:22
Uploading Item Image File
1:23
Uploading Item Image File (cont.)
2:43
Altering insertItem ( )
2:44
Helpfer Functions: getFileExtension ( ) and moveUploadedFile ( )
4:30
isValidItem ( )
13:03
Introduction to Object-Oriented Programming

32m 44s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
Object-Oriented Programming
0:56
Introduction to Object-Oriented Programming
0:57
Associative Arrays
5:27
Associative Arrays
5:28
Classes
7:27
Classes Overview
7:28
Defining Classes
8:24
Defining Classes
8:25
Declaring Class Properties
9:25
Coding Example: Classes
10:11
Objects
12:18
Objects Overview
12:19
Classes vs. Objects
12:49
Classes vs. Objects
12:50
Instantiating Classes
14:58
Instantiating Classes
14:59
Coding Example: Instantiate an Item Object
16:30
Object Properties
19:21
Access and Set an Object's Property
19:22
Coding Example: Set & Access the Properties of an Item Object
24:23
Homework Challenge
30:22
Homework Challenge
30:23
Web Application Development

17m 47s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
Version 5.0 Overview
0:50
Version 5.0 Overview and Examples
0:51
Outputting Object Properties
12:38
Outputting Object Properties
12:39
Array Object Properties
14:18
Access and Set Array Value
14:19
Object Methods

39m 57s

Intro
0:00
Lesson Overview
0:12
Lesson Overview
0:13
Object Methods
0:52
Definition of Object Methods
0:53
Calling Object Methods
3:25
Calling Object Methods
3:26
Coding Example: Simple Object Methods
4:44
Object Methods and Return Values
7:02
$this Variable
10:06
$this Variable: Definition and Example
10:07
$this Variable (cont.)
15:51
$this Variable (cont.)
15:52
Getters & Setters
21:21
Getters & Setters Methods
21:22
Object Methods In Strings
25:46
Object Methods In Strings
25:47
Coding Example: Outputting Method Return Values in Strings
27:41
Using $this to Call Other Methods
28:49
Using $this to Call Other Methods
28:50
Homework Challenge
34:18
Homework Challenge: 1-3
34:19
Homework Challenge (cont.)
36:20
Homework Challenge: 4-6
36:21
Homework Challenge (cont.)
37:52
Homework Challenge: 7-10
37:53
Web Application Development

17m 30s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
Version 6.0 Overview
0:40
Version 6.0 Changes & Examples
0:41
Item Methods
0:53
Item Class Definition: getImageFilename()
0:54
Coding Example: getImageFilename()
1:58
Department Methods
7:33
addItem(), removeItem(), and isItemInDept() Method
7:34
addItemtToDepartment() & buildDeptObject() Functions
11:46
A Default Value Needed to Be Set for $items
16:26
Object Constructors

22m 20s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
Object Constructors
0:32
Introduction to Object Constructors
0:33
Coding Example: Object Constructors
1:43
Defining Constructors
3:26
Defining Constructors
3:27
Coding Example: Constructors with No Arguments
4:24
Constructor Arguments
8:09
Constructor Arguments
8:10
Coding Example: Constructor Arguments
9:49
Important Notes
16:13
Important Notes
16:14
Homework Challenge
17:35
Homework Challenge: 1 - 4
17:36
Homework Challenge (cont.)
19:13
Homework Challenge: 5 - 9
19:14
Homework Challenge (cont.)
21:40
Homework Challenge: 10 and 11
21:41
Web Application Development

16m 19s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
Version 7.0 Overview
0:39
Version 7.0 Overview
0:40
Item Constructor
2:19
Item Constructor
2:20
Department Constructor
7:47
Department Constructor
7:48
Customer Constructor
12:23
Customer Constructor
12:24
More Magic Methods

53m 37s

Intro
0:00
Lesson Overview
0:13
Lesson Overview
0:14
Magic Methods
1:12
Magic Methods
1:13
Destructors
2:45
Destructors Overview
2:46
Coding Example: Calling Destructors
4:30
Coding Example: Object Destructor
9:19
_to String ()
16:12
_to String () Overview
16:13
Coding Example: _to String () Magic Method
18:10
Access Modifiers
21:23
Introduction to Access Modifiers
21:24
Access Modifiers: Public
21:39
Access Modifiers: Private
22:18
Access Modifiers: Protected
22:41
Object Properties and Methods
23:06
Coding Example: Public Access Modifiers
26:48
Coding Example: Private Access Modifiers
28:30
_get()
31:37
_get() Overview
31:38
Coding Example: _get () Magic Method
33:30
_set ()
36:23
_set () & the Magic Method
36:24
Using Getters & Setters
44:37
Coding Example: Using Getters & Setters
44:38
Homework Challenge
50:33
Homework Challenge: 1 - 6
50:34
Homework Challenge (cont.)
51:41
Homework Challenge: 7 - 12
51:42
Web Application Development

31m 12s

Intro
0:00
Version 8.0 Review
0:12
Version 8.0 Review
0:13
private Object Properties
1:15
private Object Properties
1:16
Coding Example
2:54
_toString() Methods
6:51
_toString() Methods
6:52
Coding Example
8:09
DataFile Class
13:27
DataFile Class & I/O Operations
13:28
Using DataFile Class: Instantiate a DataFile, DataFile open () Method, and DataFile close () Method
18:09
Homework Challenge
29:35
Homework Challenge
29:36
Classes vs. Objects

37m 49s

Intro
0:00
Lesson Overview
0:09
Lesson Overview
0:10
Class vs. Object Review
0:58
Class vs. Object Review
0:59
Static Properties
2:42
Static Properties
2:43
Scope Resolution Operator (::)
5:26
Scope Resolution Operator (::) & Static Property
5:27
Coding Example: Accessing a Static Property Using the Scope Resolution Operator
7:57
Coding Example: Accessing a Static Property in a Class Definition
10:33
Coding Example: Using a Static Property as an Instance Counter
14:18
Static Methods
18:51
Static Methods Overview
18:52
Coding Example: Static Methods
21:39
Classes vs. Objects
26:28
Classes vs. Objects: Diagrams
26:29
Class Constants
30:24
Class Constants Definition
30:25
Coding Example: Using Class Constants
31:55
Homework Challenge
34:01
Homework Challenge: 1 - 5
34:02
Homework Challenge (cont.)
35:25
Homework Challenge: 6 - 10
35:26
Web Application Development

21m 7s

Intro
0:00
Version 9.0 Overview
0:12
Version 9.0 Changes & Examples
0:13
Output Class
1:08
Output Class & Static Methods
1:09
outputHtmlSelector ( ) Method
2:43
outputItemSelector ( ) Method
4:53
outputDeptSelector ( ) Method
6:42
buildObject() Methods
11:54
buildObject() Methods & Examples
11:55
Exceptions

22m 43s

Intro
0:00
Lesson Overview
0:12
Lesson Overview
0:13
try Blocks
0:44
try Blocks Definition
0:45
catch Blocks
2:03
catch Blocks: Definition and Syntax
2:04
Coding Example: try/catch Blocks
3:48
When an Exception Object is Caught & Error Handling
5:59
Exception Class
7:02
Exception Class
7:03
Coding Example: Using try/catch to Catch an Exception Thrown from a Method
8:04
Re-Throwing Exceptions
16:39
Re-Throwing Exceptions
16:40
Coding Example: Re-throwing an Exception
17:21
Homework Challenge
20:40
Homework Challenge: 1 - 5
20:41
Homework Challenge (cont.)
22:17
Homework Challenge: 6
22:18
Web Application Development

22m

Intro
0:00
Version 10.0 Overview
0:11
Updating addItem.php, addItemToDept.php, and error.php
0:12
Updating DataFile Class: open ( ) Method & try/catch blocks
7:45
Version 10.1 Overview
13:37
Version 10.1 Changes & Examples
13:38
Updating DataFile Class: close ( ) Method & logWarning ( )
20:17
Cookies

39m 47s

Intro
0:00
Lesson Overview
0:09
Lesson Overview
0:10
What is a Cookie?
1:15
Definition of Cookie
1:16
HTTP - A Stateless Protocol
2:17
HTTP - A Stateless Protocol
2:18
Purpose of Cookies
4:10
Set - Cookie Header
6:21
Introduction to Set - Cookie Header
6:22
Coding Example: Set - Cookie Header
7:38
Cookie Header
9:45
Introduction to Cookie Header
9:46
Example: Cookie Header
10:27
setcookie()
12:33
Introduction to setcookie()
12:34
Example: Using setcookie
13:54
Cookies Attributes
15:48
Cookies Attributes Overview
15:49
Common Cookies Attributes: Domain
16:24
Common Cookies Attributes: Path
17:04
Common Cookies Attributes: Expires
19:34
Coding Example: Setting Cookie Attributes
20:58
$_COOKIE Superglobal
27:03
$_COOKIE Superglobal
27:04
Coding Example: Accessing Cookies from PHP Using $_COOKIE
29:45
Security Implications
34:44
Security Implications
34:45
Homework Challenge
36:10
Homework Challenge: 1 - 4
36:11
Homework Challenge (cont.)
37:47
Homework Challenge: 5 - 7
37:48
Web Application Development

39m 11s

Intro
0:00
Lesson Overview
0:17
Lesson Overview
0:18
instanceof Operator
1:34
instanceof Operator
1:35
Objects with Object Properties
2:53
Objects with Object Properties
2:54
Version 11.0 Overview
6:41
Version 11.0 Changes: Cart and CartItem Classes
6:42
Version 11.0 Coding Example
10:40
Version 11.1 Overview
31:03
Version 11.1 Changes & Examples
31:04
Introduction to Sessions

46m 8s

Intro
0:00
Lesson Overview
0:08
Lesson Overview
0:09
What is a Session?
0:53
What is a Session?
0:54
Client-Side Sessions
3:51
Client-Side Sessions
3:52
Server-Side Sessions
5:04
Server-Side Sessions
5:05
Session IDs
6:26
Session IDs
6:27
The SID is Used by the Server to:
7:08
A Client Passes an SID to the Server with Each HTTP Request Via:
8:15
Sessions in PHP
12:19
Sessions in PHP
12:20
session_start()
14:40
session_start() Overview
14:41
Coding Example: Using session_start () to Continue a Session
18:03
$_SESSION Superglobal
22:06
$_SESSION Superglobal Overview
22:07
Coding Example: Setting a Session Variable via $_SESSION
25:22
Accessing Session Data
28:08
Accessing Session Data
28:09
Deleting Session Data
31:43
Deleting Session Data
31:44
Coding Example: Deleting Session Data
32:16
Configuring PHP Sessions
36:14
session.cookie_lifetime, session.cookie_domain, and session.cookie_path
36:15
Coding Example: Configuring PHP Sessions
37:28
Configuring PHP Sessions (cont.)
40:56
session.use_cookies, session.use_trans_sid, and session.use_only_cookies
40:57
Coding Example: Configuring PHP Sessions
42:25
Homework Challenge
42:55
Homework Challenge: 1 - 5
42:56
Homework Challenge (cont.)
44:10
Homework Challenge: 6 - 10
44:11
Homework Challenge (cont.)
45:27
Homework Challenge: 11 - 13
45:28
Web Application Development

11m

Intro
0:00
Version 12.0 Overview
0:12
Version 12.0 Changes Part I: Updating 'viewCart.php' & 'checkout.php'
0:13
Version 12.0 Changes Part II
5:03
Destroying Sessions

29m 59s

Intro
0:00
Lesson Overview
0:12
Lesson Overview
0:13
Destroying Sessions
1:02
Destroying Sessions
1:03
session_destroy()
2:10
session_destroy() Overview
2:11
Coding Example: Setting a Session Variable and Destroying a Session
3:18
Deleting Session Cookies
8:38
Deleting Session Cookies
8:39
Coding example: Deleting Session Cookies
9:17
Review of Steps
21:07
Review of Steps
21:08
Garbage Collection
21:50
Garbage Collection Overview
21:51
Coding Example: Garbage Collection
24:30
Homework Challenge
26:28
Homework Challenge: 1 - 4
26:29
Homework Challenge (cont.)
28:16
Homework Challenge: 5 - 9
28:17
Web Application Development

19m 14s

Intro
0:00
Lesson Overview
0:13
Lesson Overview
0:14
_autoload()
0:46
Introduction to _autoload ()
0:47
Version 13.0 Overview
4:06
_autoload () and SessionManager Class
4:07
Updating 'viewCart.php' & 'checkout.php'
11:16
Introduction to Databases

21m 24s

Intro
0:00
Lesson Overview
0:16
Lesson Overview
0:17
Flat Files
1:09
Flat Files: Definition and Example
1:10
Problems Associated with Using Flat Files as a Database
2:15
Relational Databases
3:29
Relational Databases
3:30
Relational Database Management System (RDBMS)
3:50
Tables
7:43
Tables
7:44
Columns
9:24
Columns
9:25
What is SQL?
10:45
Introduction to Structured Query Language
10:46
Standard Data Types of SQL
12:23
Primary Keys
13:19
Primary Keys
13:20
Primary Key Examples
16:36
Primary Key Examples
16:37
Introduction to MySQL

28m 11s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
What is MySQL?
1:33
MySQL
1:34
MySQL Monitor
5:16
MySQL Monitor Overview
5:17
XAMPP & MySQL
5:58
In the MySQL Command: hostname, username and -p
7:05
Connecting to a MySQl Server
9:52
Connecting to a MySQl Server
9:53
Using MySQl Monitor
13:48
Using MySQl Monitor
13:49
GRANT Command
15:10
GRANT SQL Command
15:11
Privileges & Objects
18:18
Username, Hostname, and Password
19:37
Specifying Objects
20:05
Creating a PHP User Account
21:41
Creating a PHP User Account Overview
21:42
Meaning of all & *.*
23:35
Example: Creating a PHP User Account
23:48
Required Homework
26:27
Required Homework: 1 - 5
26:28
Required Homework (cont.)
27:28
Required Homework: 6
27:29
Creating Databases & Tables

23m 1s

Intro
0:00
Lesson Overview
0:08
Lesson Overview
0:09
Creating a Database
1:40
Introduction to Creating a Database
1:41
Example: Creating a Database
3:33
CREATE TABLE Command
6:43
CREATE TABLE Command
6:44
Data Types
7:39
Numeric Data Types: INT, INT UNSIGNED, and DECIMAL
7:40
String Data Types: CHAR (M), VARCHAR (M), and TEXT
9:23
Colum Attributes
11:00
PRIMARY KEY Attribute
11:01
AUTO INCREMENT Attribute
11:35
Items Table
13:07
Items Table
13:08
Useful Commands
17:04
SHOW TABLES Command & DESCRIBE Utility Statement
17:05
Example: Creating an Items Table
17:58
Required Homework
20:51
Required Homework: 1 - 6
20:52
Required Homework (cont.)
21:55
Required Homework: 7 - 9
21:56
SQL Command: INSERT

27m 11s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
INSERT Command
1:20
SQL INSERT Command
1:21
Specifying Values
3:16
Columns with Numeric Data Types
3:17
Columns with String Data Types
3:34
Columns with AUTO INCREMENT
4:07
Inserting Items
5:21
Inserting Items
5:22
Example: Inserting Items
7:03
SQL Text Files
14:04
SQL Monitor Client
14:05
MySQL Monitor & the < Operator
15:15
Example
17:35
Required Homework
22:32
Required Homework: 1 - 6
22:33
Required Homework (cont.)
24:19
Required Homework: 7 - 10
24:20
SQL Command: SELECT

24m 57s

Intro
0:00
Lesson Overview
0:10
Lesson Overview
0:11
SELECT Command
0:42
SELECT Command: Definition and Syntax
0:43
Results of a SELECT Query
1:53
To Specify the Retrieval of All Columns from a Table
3:06
Example: SELECT Command
4:18
WHERE Clause
7:11
WHERE Clause
7:12
A SELECT Query with WHERE Clause has the Following Syntax
8:10
A Where Condition can Contain both Logical and Comparison Operators
9:44
Literal Values
13:24
Literal Values
13:25
Example: Literal Values
14:18
ORDER BY Clause
15:31
ORDER BY Clause & SELECT Query
15:32
Ascending and Descending Order
17:30
An ORDER BY Clause can Specify Multiple Columns to Order the Rows by
18:01
Example: SELECT Query with WHERE and ORDER BY Clause
20:32
Homework Challenge
21:59
Homework Challenge
22:00
Homework Challenge (cont.)
23:54
Homework Challenge
23:55
Using PHP from MySQL

32m 43s

Intro
0:00
Lesson Overview
0:10
Lesson Overview
0:11
PHP/MySQL Architecture
0:56
PHP/MySQL Architecture
0:57
MySQLi Extension
3:05
MySQLi Extension
3:06
Steps to Using MySQL from PHP
5:53
Four Steps to Using MySQL from PHP
5:54
Step # 3
7:18
Connecting to a Database
8:12
To Connect to a MySQL Database
8:13
To Test for Connection Errors
10:20
Running an SQL Statement
11:54
Running an SQL Statement
11:55
Example
13:30
Processing the Results
15:58
For non-SELECT Queries
15:59
MySQLi Object Property: affected_rows
16:19
For INSERT Statements on Tables with an AUTO_INCREMENT Column
18:07
Closing the Connection
19:45
Closing the Connection
19:46
Coding Example
21:24
Coding Example: Using MySQL from PHP
21:25
Homework Challenge
29:00
Homework Challenge: 1 - 4
29:01
Homework Challenge (cont.)
31:10
Homework Challenge: 5 - 9
31:11
Web Application Development

30m 30s

Intro
0:00
Lesson Overview
0:14
Lesson Overview
0:15
sprintf()
1:28
sprintf() Overview
1:29
Example
1:56
INSERT Statements with sprintf()
5:15
INSERT Statements with sprintf()
5:16
Version 14.0 Overview
10:00
Version 14.0 Changes & Examples Part 1
10:01
Version 14.0 Changes & Examples Part 2
21:58
SELECT QUERIES from PHP

24m 22s

Intro
0:00
Lesson Overview
0:14
Lesson Overview
0:15
SELECT Queries
1:21
SELECT Queries
1:22
MySQLi_Result Class
3:17
MySQLi_Result Class: num_rows
3:18
MySQLi_Result Class: fetch_assoc ( ) and fetch_object ( )
3:59
fetch_assoc()
5:17
fetch_assoc() Overview
5:18
Coding Example: Using fetch_assoc()
9:00
stdClass Objects
12:46
stdClass Objects
12:47
fetch_object()
14:19
fetch_object() Overview
14:20
Coding Example: Using fetch_object()
16:45
Freeing Result Set Memory
18:42
Freeing Result Set Memory
18:43
Coding Example: Using free ( )
20:01
Homework Challenge
22:07
Homework Challenge: 1 - 5
22:08
Web Application Development

17m 6s

Intro
0:00
Version 15.0 Overview
0:13
Version 15.0 Changes & Examples Part 1
0:14
Version 15.0 Changes & Examples Part 2
8:43
Linking Tables

24m 32s

Intro
0:00
Lesson Overview
0:16
Lesson Overview
0:17
A Departments Table
1:08
Departments Table
1:09
How Could We Model This in a Table: Option 1
1:26
How Could We Model This in a Table: Option 2
3:12
Database Normalization
4:37
Database Normalization
4:38
Foreign Keys
8:47
Foreign Keys
8:48
Linking Table
11:26
Linking Table
11:27
Multiple Column Primary Keys
15:30
Multiple Column Primary Keys
15:31
Example
18:51
Required Homework
22:34
Required Homework: 1 - 3
22:35
Required Homework (cont.)
24:10
Required Homework: 4
24:11
Web Application Development

24m

Intro
0:00
Version 16.0 Overview
0:11
Version 16.0 Changes
0:12
Version 16.0 Coding Examples
4:12
Version 16.0 (cont.)
18:30
Version 16.0 Changes & Examples Part 2
18:31
SQL Command: DELETE

10m 33s

Intro
0:00
Lesson Overview
0:12
Lesson Overview
0:13
DELETE Statement
0:30
DELETE Statement & Its WHERE Clause
0:31
Delete All Rows From a Table
2:57
Using DELETE from PHP
4:04
Using DELETE from PHP Overview
4:05
Coding Example: Using DELETE from PHP
6:37
Homework Challenge
8:53
Homework Challenge: 1 - 4
8:54
Web Application Development

16m 2s

Intro
0:00
Version 17.0 Overview
0:11
Version 17.0 Changes
0:12
Version 17.0 Coding Example
2:51
Transactions
12:50
Database Transaction
12:51
Steps in Using Transactions
14:00
SQL Command: UPDATE

32m 14s

Intro
0:00
Lesson Overview
0:10
Lesson Overview
0:11
UPDATE Statement
0:54
UPDATE Statement & Its WHERE Clause
0:55
Example: UPDATE Statement
3:32
Using UPDATE from PHP
5:21
Using UPDATE from PHP Overview
5:22
Coding Example: Using UPDATE from PHP
6:53
htmlspecialchars()
9:04
htmlspecialchars()
9:05
Encoding Special Characters
9:23
Coding Example: htmlspecialchars()
13:41
addslashes()
20:40
addslashes()
20:41
Coding Example: addslashes()
22:52
Homework Challenge
27:55
Homework Challenge: 1 - 2
27:56
Homework Challenge (cont.)
30:14
Homework Challenge: 3 - 5
30:15
Homework Challenge (cont.)
30:41
Homework Challenge: 6 - 9
30:42
Web Application Development

12m 33s

Intro
0:00
Version 18.0 Overview
0:12
Version 18.0 Changes
0:13
Version 18.0 Coding Example
1:24
SQL: Joins

42m 16s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
DATETIME Data Type
1:52
DATETIME Data Type
1:53
Modeling Orders
5:12
Modeling Orders
5:13
Customers Table
10:46
Customers Table
10:47
Example
16:18
Example: Order Table in MySQL
16:19
Joins
22:26
Joins Overview
22:27
Inner Join
23:09
Example: Joins
24:11
Join Conditions
28:14
Join Conditions
28:15
Example
28:32
Join Queries
30:00
Example: Join Conditions in MySQL
30:36
Implicit Joins
34:42
Implicit Joins
34:43
Example: Implicit Joins
35:57
Aliases
37:28
Introduction to Aliases
37:29
Example: Aliases
38:55
Required Homework
40:32
Problem 1
40:33
Problem 2
41:01
Problem 3
41:17
Web Application Development

29m 34s

Intro
0:00
Lesson Overview
0:12
Lesson Overview
0:13
Inserting Orders
0:44
Inserting Orders
0:45
Version 19.0 Overview
3:45
Version 19.0 Changes & Example Part 1
3:46
Version 19.0 Changes & Example Part 2
13:18
Version 19.1 Overview
21:10
Version 19.1 Changes
21:11
Version 19.1 Coding Example
22:18
User Authentication

26m 13s

Intro
0:00
Lesson Overview
0:10
Lesson Overview
0:11
User Authentication
1:31
User Authentication
1:32
Authentication with Sessions
2:34
Authentication with Sessions
2:35
Four Steps in Authentication via Sessions
2:50
Using Sessions to Restrict Access
3:58
Using Sessions to Restrict Access
3:59
Coding Example: Restricted Access Area
4:47
Authentication Methods
5:54
Authentication Methods Overview
5:55
Coding Example: Authentication Methods
7:31
Logging Out
9:57
Logging Out
9:58
Coding Example: Log Out
10:47
Users Table
13:50
Users Table
13:51
Example: Creating a Users Table
15:08
Password Hashing
17:30
Password Hashing
17:31
PHP and MySQL Built-in Hash Functions: sha1 ( ) and md5 ( )
18:43
Coding Example: Password Hashing
19:27
Required Homework
24:41
Required Homework: 1 - 4
24:42
Web Application Development

14m 36s

Intro
0:00
Version 20.0 Overview
0:13
Version 20.0 Changes & Examples Part 1
0:14
Version 20.0 Changes & Examples Part 2
5:05
Version 20.0 Changes & Examples Part 3
7:29
Version 20.0 (cont.)
8:31
Version 20.0 Changes & Examples Part 4
8:32
Loading...
This is a quick preview of the lesson. For full access, please Log In or Sign up.
For more information, please see full course syllabus of Advanced PHP
  • Discussion

  • Study Guides

  • Download Lecture Slides

  • Table of Contents

  • Transcription

  • Related Services

Lecture Comments (1)

0 answers

Post by petar vukasinovic on November 9, 2012

Hi Matthew When i try to press enter on password it says:
access denied for user 'root'@'localhost' using password 0.
Can you please help me.

Introduction to MySQL

  • MySQL is an open-source RDBMS commonly used with PHP applications that operates using a client-server model.
  • The MySQL RDBMS itself acts as a server to which MySQL ‘clients’ connect in order to issue commands on the database.
  • A MySQL server can contain multiple databases, each of which can contain multiple tables.
  • MySQL has a user privilege system to control access to the server.
  • When a MySQL server is first installed it contains a root user account that allows you to initially login to the server.
  • MySQL Monitor is a MySQL client program that provides a command-line interface for interacting with a MySQL server.
  • The MySQL Monitor client program can be invoked using the command (with hostname &username replaced with appropriate values):
    mysql –h hostname –u username -p
  • Commands entered using MySQL Monitor must be terminated with a semicolon.
  • exit can be typed to end the MySQL Monitor program.
  • The GRANT SQL command is used to create database users & grant them privileges. It has the format:
    GRANT privileges
    ON objects
    TO ‘username’@’hostname
    IDENTIFIED BY ‘password
  • In a GRANT command values must be provided for:
    • privileges - the type of privileges to grant to the user
    • objects - the database objects on which to grant the privileges
    • username - the username for the account being created
    • hostname - the host(s) from which the user is allowed to connect
    • password - the password for the account being created
  • Database objects are specified in the format databaseName.tableName, and the wilcard character, *, can be used for either the database name or the table name.
  • Additional Resources:

Introduction to MySQL

Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.

  • Intro 0:00
  • Lesson Overview 0:11
    • Lesson Overview
  • What is MySQL? 1:33
    • MySQL
  • MySQL Monitor 5:16
    • MySQL Monitor Overview
    • XAMPP & MySQL
    • In the MySQL Command: hostname, username and -p
  • Connecting to a MySQl Server 9:52
    • Connecting to a MySQl Server
  • Using MySQl Monitor 13:48
    • Using MySQl Monitor
  • GRANT Command 15:10
    • GRANT SQL Command
    • Privileges & Objects
    • Username, Hostname, and Password
    • Specifying Objects
  • Creating a PHP User Account 21:41
    • Creating a PHP User Account Overview
    • Meaning of all & *.*
    • Example: Creating a PHP User Account
  • Required Homework 26:27
    • Required Homework: 1 - 5
  • Required Homework (cont.) 27:28
    • Required Homework: 6

Transcription: Introduction to MySQL

Hello again, and welcome back to Educator.com's Advanced PHP with MySQL course.0000

In today's lesson, we are going to be continuing our discussion of databases by getting to learn more about the details of the MySQL database system.0005

Specifically, we are going to be talking about what MySQL is; it is a relational database management system.0013

We are going to talk about some of the properties and features of MySQL.0019

We are going to talk about a program that comes with a MySQL distribution called the MySQL Monitor,0023

which is a way of connecting to a MySQL database and issuing SQL commands on it.0028

We are going to go over the steps that it takes to connect to a MySQL server.0034

And then, we are going to show how to be able to do that, using this MySQL Monitor program we are talking about.0039

And then, we are going to learn about the GRANT command, which is a way to create users on a MySQL server.0045

And users are a means of the database restricting access to particular parts of the database.0051

We are going to learn about how to create users using the GRANT command.0057

And then, we are going to walk through the setup of a user account for our PHP scripts,0061

so that our PHP scripts will be able to access our store database.0066

And then, we are going to go over a required homework, and it is a little bit different from your usual homework.0070

It is going to be a required homework, because the steps that you will be going through--you will need to go through these steps0075

in order to set up your MySQL database, so that when we continue web application development,0082

you will be able to connect to a database that is properly set up.0089

What is MySQL? Well, it is an open-source relational database management system.0095

At the back end, it is a relational database, and what it does is (because it is a relational database management system):0102

it provides some features and an interface on top of the database in order to properly use it.0108

It is commonly used with PHP applications; that is probably one of the reasons why you are taking this course:0116

PHP and MySQL are used together very often.0122

One of the things about MySQL is that, like most relational database management systems, in operates using a client-server model.0125

The database runs as a server, and then you have clients that connect to that server and then issue commands.0134

And what MySQL does is contains multiple databases; a MySQL installation can contain multiple databases,0143

each of which can contain multiple tables; and we learned about tables in our last lesson.0155

That is the way to store data in a relational database.0160

A MySQL server can have multiple databases; for example, you might have a couple of different web projects,0165

and you might create a different database (which is just a logical structure for a bunch of tables)0169

which might contain multiple tables; so you can have multiple databases with multiple tables,0174

each related to different projects, and each of the tables containing different information.0179

One thing you will notice is that I have been referring to it, in a way, as a MySQL server.0186

Because it runs in this client-server model, you will typically hear the terms MySQL database and MySQL server used interchangeably.0191

And that is what we are going to be using in this course, also.0199

Sometimes I will refer to it as the server, sometimes as the database.0202

But essentially, when I say that, I am just referring to the MySQL relational database management system as a whole.0205

So, when you are connecting to a MySQL database, you are connecting to this database management system0212

that runs as a server, that gives you access to the relational database.0217

One of the features that MySQL provides is a user privilege system, which controls access to that MySQL server.0222

It allows you to set up permissions for different user accounts to restrict access to certain databases and to certain tables.0229

For example, you could set it up so that a particular user can only access one particular database.0237

That is something that might be common on a web hosting.0243

If you have hosted on a web host before, you might only have access to a specific database.0247

So, they might tell you that, when you connect to a MySQL server (which we are going to learn more about in this lesson),0252

you have to use a particular database set up for your account.0258

And it is a way to restrict access to the database, and then also to different operations on the database.0261

For example, you might create a user account that can only run searches, or queries, on the database--0267

whereas another user account might be able to add information to the database.0273

When MySQL is first installed (as is the case in the XAMPP installation), it contains a root user account.0280

And it contains that account with no password initially.0287

And what that allows you to do is to initially log in to the server, and then create additional user accounts.0290

And then, what you do is build up the security of the system from there.0296

What we are going to be doing is logging in as the root user in order to create our PHP user account,0300

which is an account that we are going to give privileges to,0307

so that we can use that account to access our MySQL database from our PHP scripts.0310

As mentioned, MySQL runs in a client-server model, and the database itself acts as the server.0318

And what you do is connect to it using clients.0324

A PHP script, for example, would fall under the category of a client.0327

It is something that can connect to the database and run queries on it, which is the ultimate goal of this course:0330

we are going to be learning how to use a PHP script as a client to connect and run queries on the database.0335

Well, there is also a program included with the MySQL installation by default, called the MySQL Monitor.0342

And it is just a command-line program that allows you to connect to a running MySQL server, and then issue SQL commands on it.0349

In XAMPP, the MySQL program is called mysql.exe, and it is located in the bin subdirectory of the mysql directory of the xampp root directory.0360

For example, if we were to go to our xampp directory (which for this course, we have set up in our Windows User directory),0374

and we go to xampp, and the mysql directory, and then the bin directory, you can see a bunch of different files,0383

a lot of which are executables, and you can see the mysql.exe program.0390

What that is: that is that client (and we are going to be learning how to use that) that allows to connect to a MySQL database.0395

The way you use the MySQL Monitor program is by issuing a command that looks like this.0404

You specify MySQL, which is the name of the program, mysql.exe (you don't have to include the .exe, however).0410

And then, it has a couple of parameters, or options, that you can pass to it0416

that describe how you should connect to the particular database.0422

In that command that we just saw, there were a couple of command options.0428

The first one is specified by -h, followed by hostname in single quotes.0432

What that does is specifies the hostname, or it can be an IP address, of the MySQL server that you are trying to connect to.0438

The MySQL server is running on a computer somewhere.0446

For example, if you host your website at a web host, it might be running on a server somewhere on the network of your web host.0450

In our particular example with XAMPP, we are going to be running the server on our localhost, so we will be running on the same machine.0458

So, when we try to connect to MySQL, we are going to be specifying hostname as localhost.0464

And again, it is a hostname that represents a particular computer that contains the MySQL server that you are trying to connect to.0472

The -u command option was followed up by the username, or the user account that you want to connect to.0485

So, when you issue that command, you replace that with the username of a valid user account that has been set up on that MySQL server.0493

One of the things--for example, when you get set up with a web host, if you are using a shared hosting plan,0502

they might tell you the hostname of the MySQL server (maybe it's mysql1.hostexample.com--maybe that is the hostname of the server).0507

And you would specify that with -h.0526

And they might tell you that your username to connect to (they have set you up a user account) maybe is your account number.0527

Maybe it's 78967; and what -u does is: that is a command option that allows you to specify what user you want to connect to the server as.0533

Host specifies which server you want to connect to, and then -p is an option that tells the program that,0547

when you try to connect to the server, you want it to request a password from you.0554

After you specify the -p option and you run the command, it is going to ask you to enter your password,0558

which you can do, and it will be masked, like the password forms on web pages,0563

so that anybody looking over your shoulder can't see the characters that you are typing.0570

One thing to note is: if you leave out the -h option when you run this command, by default it uses the value localhost.0574

Because we are going to be running this on our local machine from a Windows command prompt, we will be able to leave out that -h option.0583

How do we go ahead and connect to a MySQL server with XAMPP, using this MySQL Monitor?0595

Well, the first thing that we do is (actually, I'll stop it, because it has been running) open up the XAMPP control panel.0600

And underneath the section for starting and running Apache, there is one for MySQL.0607

And you can go ahead and click the Start button, and what that does is gets that MySQL server up and running on your local computer.0614

And then, what we do is: because it is a command-line program, we are going to be using the Windows command prompt,0624

which some of you may or may not have experience using.0630

We are just going to use some basic command-line commands to be able to use our MySQL program.0633

Most of the commands that we are going to be learning are commands you issue once in the program.0643

You open a Windows Command Prompt, and for those of you that don't know how to do that,0649

on Windows 7, when you click on the Start menu, you can go and type in the search box0653

(and I am doing this off to the side; you won't be able to see it) cmd.exe.0658

And what is going to happen is: Windows will show you the cmd.exe program that you can select and start.0670

And when you click on it, it is going to open up a window like this that shows a command prompt.0679

It shows you the current directory that you are in.0683

Well, in order to be able to run the MySQL Monitor program, we have to switch to the directory that that program is in,0686

so that when we run this MySQL command here, the command prompt knows where to find that program at.0693

The first thing we do is change the directory to this bin directory of the mysql directory of our XAMPP installation.0701

And we change that directory; and the way you do that is using a command called CD, which stands for Change Directory.0708

And we are going to use an absolute path, so in our Windows Command Prompt, you type CD, and then a space,0713

and then the name of the directory that we are trying to switch to.0720

And in Windows, remember that directories are separated by back slashes.0724

In our case, we go to our user directory, which is in Users/(your username) in Windows 7.0729

We are going to go to the xampp installation folder, the mysql folder, and the bin folder of that.0738

And that is going to give us access to this MySQL program.0746

And now, what we want to do is connect to the server, using this root account that we said is set up by default.0748

And as mentioned, the root user does not initially have a password, so when we are prompted for a password,0754

by issuing this command here, we just hit Enter.0759

And what it is going to do is start the program.0762

So, we can type mysql, which is a command to run the program, and then we pass it some command-line parameters.0764

We are going to go ahead here (even though we mentioned we don't need to) and specify that we want to connect0771

to the MySQL server running on the hostname specified by localhost, which is the local computer.0776

We are going to specify the username, using the -u command.0782

So, we are saying -u, and then space, and then the username we want to connect as.0786

We want to connect as root, and then we want it to prompt us for a password, so we can authenticate ourselves.0789

So, we enter -p, and when we hit Enter, it is going to prompt us to enter a password.0795

Because root doesn't have a password, we can simply hit Enter as a blank password.0801

It is going to connect, and now we are connected to the MySQL Monitor.0804

And what you can see is that it outputs a little information.0808

It says, "Welcome to MySQL Monitor," talks about the version of the MySQL server you are connected to...0811

And then, down here, it has the MySQL Command Prompt, and it is kind of like its own command prompt that allows you to run the SQL commands.0818

As far as using this MySQL Monitor, when you are at the MySQL Command Prompt0831

(which is the word mysql followed by a greater than sign), you can enter in different commands.0836

You can enter in different SQL commands.0841

One thing to note is: like statements in PHP, you must terminate your statements with a semicolon.0843

One other thing that you can do is have commands that span multiple lines.0851

One of the things that we will see is that, as we start learning more about databases,0854

we are going to see that we are going to be entering commands that are quite long.0859

So, it is often helpful to space them on different lines to make them easier to read.0861

The way you can do that is to simply hit Enter.0865

For example, if I wanted to type a fake command on multiple lines, I just hit Enter.0867

And what you can see is that it adds a little dash, greater than sign.0874

And that is a signal to you, the user, that it is still expecting you to enter some more of the command.0879

So, I might type 'rest of command,' and then to execute the command, you finish it with a semicolon and simply hit Enter.0885

Now, when I do this, we are going to get an error, because it is not a valid command.0892

But that is how you run a command, and how you have it span multiple lines.0895

And then, when you are done using the MySQL Monitor, you just type exit, and that is going to exit you out of the program.0900

And it brings you back to the command prompt.0906

As mentioned, there is a privilege system that is built into MySQL that allows you to restrict access to parts of the database.0911

And there is a GRANT SQL command that is used to grant privileges to users.0918

And it can be used to create a database user, as well as grant them privileges.0925

And the command has the format that follows this format here.0929

It has a couple of keywords, GRANT, and TO, and IDENTIFIED, and BY.0937

And those are parts of the command that you have to specify.0942

Typically, in SQL, oftentimes you will see, in an SQL command, that any special keywords are required by a command0947

(for example, GRANT) are specified in all capital letters; though it is not necessary to do that, that is often the convention.0956

With this GRANT command, we have a couple pieces of information we need to provide.0964

We need to provide the types of privileges we want to grant.0968

And we specify (we are going to learn more about these in a second) what we want to grant these privileges on.0973

For example, we might say we want to allow this user that we are creating to have only query or select privileges on table Users,0979

which means they can only run select queries (which we are going to learn more about) on a particular table called Users.0989

We are saying, "Grant privileges on these particular database objects."0995

And here is where we specify our user: we are saying, "Create a user account with the username username" (enclosed in single quotes).0999

And that is where you would substitute what username you want to create.1008

And then, you say @, and then a hostname provided in single quotes.1012

And what that does is says that that is the hostname that that user is allowed to connect from.1016

So, for example, one of the things that we are going to be doing is creating a PHP user account.1021

I'm not sure why that is not erasing.1032

And the way that we specify that would be like this.1038

And what that is saying is, "Create an account" on the server that we are connected to, that you are issuing these commands to,1045

"called PHP user," and that PHP user is going to be able to connect to this server only from the localhost computer.1051

You could specify something else, like maybe a specific IP address that says1059

that the PHP user can only connect to this server from a computer with IP address 192.68.1.2, for example.1071

We are going to be specifying localhost, because all of our scripts are going to be running on the same machine as our MySQL server.1079

And then, after you specify the username and the host that that user can connect from,1084

you can specified the IDENTIFIED BY keywords, and then include the password1088

that you want that user to log in with, within quotation marks.1093

The underlined values that are in this command here are values that you must provide to the command, and refer to some different things.1099

The privileges are the type of privileges that you want to grant to the user.1109

It might be...for example, we might grant all privileges, which gives them access to do everything they want to in the database.1114

It might be that they can just view contents of the database; they can just insert contents in the database.1120

The privilege system is an advanced topic, and it is sort of beyond the scope of what we are going to get into in this course.1127

But you can definitely look at the MySQL documentation, if you are curious about that,1133

and find out more information about the different types of privileges that you can grant.1136

The objects parameter of this SQL command specifies the database objects on which you can grant particular privileges.1141

And we will see on the next slide that you can...let's say we were going to use GRANT all1152

(and all is a word that you can use, that says, "Give all privileges to this particular user.").1158

You might grant all privileges on all of the tables in a particular database.1165

Or you might give all privileges to the user for all tables and all databases.1169

The other parts of the GRANT command that were underlined are username1179

(which is the username we want to create for the account that you are creating);1184

hostname specifies the host from which the user is allowed to connect (so it is the host they have to connect from;1189

it might be a particular IP address; it might be a hostname);1197

and then, password is just the password that you want to create for the account.1200

Now, the objects, as mentioned, specifies database objects that privileges are going to work on.1206

So, if we say GRANT all (which means grant all privileges) ON, and then the form that this objects parameter takes is shown here...1211

Basically, you provide a database name, followed by a period, followed by a table name.1227

And so, what that allows you to do is: if you specify a particular database, you can say, for example...1233

maybe we have a database called PHP, and we have a table in it called Users; this is saying,1240

"Grant all privileges on the Users table in the PHP database," and down here we would create the rest of the command:1246

TO so-and-so user, with a password.1254

Now, what you can do is use wildcard characters.1257

Instead of having PHP.Users here, we could say PHP.* (in this case, if * is to the right of the period, it means all tables).1259

So in this case, we are saying, "Grant all privileges to this user on all tables in the PHP database."1269

And it can work the other way, as well; you can do *.*, which says, "Grant all privileges to" whatever user you select "on all tables in all databases."1276

And so, that is the format that it uses: it has the database name and a period,1292

followed by the database table, or wildcard characters, if you want to specify those.1296

Now, what we are going to do is walk through running a GRANT command that is going to create a PHP user account1303

that we could use to connect to MySQL from our PHP scripts.1309

We are going to be creating a username called phpuser that is going to be able to connect to the MySQL server from the localhost.1314

And the reason it is from the localhost is because our script, our web server, is running on the same server as our MySQL server-1321

at least, in this XAMPP distribution that we are using.1328

We are going to be issuing this command here, and we are saying, "Grant all privileges."1332

And 'all' gives you full permission to do whatever you want in the database.1339

That is not necessarily a secure way of doing things: you want to be as restrictive as possible.1344

But for educational purposes, we are going to grant all privileges.1351

So, that is going to allow us to experiment with different SQL commands.1355

But that is definitely not something you would want to do in a production environment.1357

And so, we are going to grant all privileges to our PHP user that is going to connect from the localhost.1362

And we are going to give them all privileges on all databases and all tables in all the databases.1369

Again, that is something you probably wouldn't want to do--to give access to a user to all databases.1375

For example, you might just want to give them access to all the tables in the PHP database.1380

So, this is, again, just for educational purposes that we are going to grant all privileges on all tables,1386

so that we can experiment and learn about SQL.1391

And then, we are going to specify that it is going to be identified by (it is going to have the password) xxx,1395

which--you can put in whatever password that you want there.1400

So, we are going to have you, as part of the homework, run this command on your home computer.1404

And you go ahead and create this phpuser account, and then specify whatever password you would like to have for the phpuser.1409

Again, all is going to grant all privileges to the user, and then *.* is going to specify that it grants privileges on all tables in all the databases.1417

If we go back to our command prompt (and we logged out of the MySQL Monitor program), and we are going to log back in,1429

this time I am not going to specify the -h localhost parameter, because as mentioned, by default it will default to that.1437

I'm just going to type -u and specify that we want to connect to the root user, and we want to be prompted for a password.1445

Just hit Enter when it asks for a password, because again, we don't have a password for the root account currently.1453

And then, what we are going to do is run this GRANT command.1459

We are going to run GRANT; we are going to type GRANT all, so grant all privileges.1461

And I'm going to do it over several lines; as mentioned, just by hitting Enter, it allows you to continue a command on a separate line.1466

We are saying, "Grant all privileges on all tables on all databases to the user we are creating (phpuser)."1473

And we are saying that that phpuser will be connecting from the localhost.1483

And then, we are going to say it is going to be identified by (let's spell it right)...in this case, I am just going to pick the password Educator.1489

And then, finish the command with a semicolon.1500

What we are saying is, "Grant all privileges on all tables in all databases to a new user called phpuser1503

that will be connecting from the localhost that will be identified by (that will have the password) Educator."1510

And so, when we hit Enter, it is going to give you a result that says "query OK," which means that the query went through--1515

or it has called the query, that the command went through, and that it ran OK.1521

And so now, what I want to do is exit out of the MySQL Monitor program1525

and then just verify that the account works by trying to log back in as this new user.1530

What we are going to do is specify MySQL; this time, I'll specify the host name, because we did create it, so we are connecting from the localhost.1535

Well, this localhost here actually refers to the MySQL server, so you can just ignore that.1548

And then, we are going to specify that we are going to connect as phpuser, which is the name of the new user account we created.1554

We are going to say -p, which says we want to be prompted by a password.1560

We hit Enter; now, we are going to be prompted by a password, and we have a password, which in this case was Educator.1566

So, when I type that, now we are logged into the MySQL server, as before.1571

And we are logged in as phpuser, which has all privileges on all tables in all databases.1575

And so, now we know that that account is set up and worked; and that is what we are going to be using from our PHP script.1581

The required homework for this is to go through and set up what we just did,1590

which is to create that phpuser account, because for the demo web store application that we are creating,1595

in order to be able to run future versions of that, you are going to have to have the database set up.1602

And so, we are going to have you set it up by issuing this GRANT command.1606

The steps, again, are just: start the MySQL database from the XAMPP control panel;1610

you open a Windows Command Prompt, and you switch to the MySQL bin directory, using the CD command, using an absolute path.1616

You go ahead and connect to the MySQL database, using the MySQL Monitor program as the root user.1626

And then, just issue a GRANT command that is going to create this phpuser account1632

that can connect from the localhost, has a password that you choose, and should have all privileges on all tables in all databases.1635

Then, type exit to quit the MySQL Monitor.1645

And then, verify that you have successfully created the account.1650

1) You should see a 'query OK' symbol, assuming the syntax and the command was written in correctly.1652

And it may give you an error, for example, if you leave out a single quote, or there is an error anywhere in your syntax.1658

And it will let you know; so if you get query OK, that lets you know the query went through all right.1663

And then, just to double-check to make sure that everything worked, log out and then log back in1668

as this new phpuser that you created, using the password that you created.1674

And if all goes well, you will be presented with a MySQL prompt that will allow you to begin issuing commands to the database.1679

That ends today's lesson; thank you for watching Educator.com--I look forward to seeing you next time.1687

Educator®

Please sign in for full access to this lesson.

Sign-InORCreate Account

Enter your Sign-on user name and password.

Forgot password?

Start Learning Now

Our free lessons will get you started (Adobe Flash® required).
Get immediate access to our entire library.

Sign up for Educator.com

Membership Overview

  • Unlimited access to our entire library of courses.
  • Search and jump to exactly what you want to learn.
  • *Ask questions and get answers from the community and our teachers!
  • Practice questions with step-by-step solutions.
  • Download lesson files for programming and software training practice.
  • Track your course viewing progress.
  • Download lecture slides for taking notes.