Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll

- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
Building a php-driven page is just the first step in mastering PHP. The true power of PHP shines when you connect it to a data source like an API or a Database. In this course, we’ll refactor an application to use a database to store the information. This will make our application easier and faster to scale. It will also make it easier and faster to add functionality like the search and pagination we’ll also be adding in this project.
Learn More About Relational Databases
https://teamtreehouse.com/library/database-foundations
https://teamtreehouse.com/library/sql-basics
Database Diagram
Using the Database Locally
Included in the download is a .sql file for importing the data into another database such as MySQL. Once you have this file, you can choose one of the following options for loading the database into your local dev environment
CAREFUL: These steps will replace all tables in any existing database named "database"!
1. Import Database into MySQL using phpMyAdmin
If you are using MAMP, you can find phpMyAdmin by starting your servers and going to http://localhost/phpMyAdmin or http://localhost:8888/phpMyAdmin
Then choose the import tab and select the downloaded database.sql file.
2. Importing Database into MySQL using Command Line
Step One:
Open a new terminal (Mac) or command line (Windows) window
Step Two:
[PATH_TO_MYSQL] -u [USERNAME] -p < [PATH_TO_SQL_FILE] Hit the Enter Key
Example Mac with MAMP: /applications/MAMP/library/bin/mysql -u root -p < /Downloads/database.sql
Example Windows with MAMP: c:/MAMP/bin/mysql/bin/mysql -u root -p < c:/Downloads/database.sql
Quick Tip: Don’t forget that you can simply drag the file into the terminal window and it will enter the location of the file for you.
Step Three:
You should be prompted with the following line:
Enter password:
Type your password, keep in mind that the letters will not appear, but they are there Hit the enter key.
Quick Tip: By default, the MySQL password for MAMP is "root".
Step Four:
Check if you database was successfully imported Navigate to phpMyAdmin in a browser
http://localhost/phpMyAdmin OR http://localhost:8888/phpMyAdmin
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up-
Matt Nickolls
9,895 Points0 Answers
-
Rafail Mavrogordatos
5,324 Points1 Answer
-
Sean Flanagan
33,236 Points3 Answers
-
Gremyko Coleman
9,756 Points2 Answers
-
Viki Shah
611 PointsPlease explain the code which is in the workspace of the link https://teamtreehouse.com/library/integrating-php-with-dat
Posted by Viki ShahViki Shah
611 Points0 Answers
-
Thomas Beaudry
29,084 Points0 Answers
-
Vatsal Shah
91 PointsPlease explain the code of the workspace - https://teamtreehouse.com/library/integrating-php-with-databases/databases-an
Posted by Vatsal ShahVatsal Shah
91 Points0 Answers
-
John Gu
6,891 Points1 Answer
-
Asad Kashmiry
219 Points1 Answer
-
Andrew Dovganyuk
10,633 Points0 Answers
-
Hector F.
27,464 Points1 Answer
-
Carlos Enrique Castañeda Gutiérrez
13,886 Points1 Answer
-
Daniel Schroeder
13,859 Points0 Answers
-
Murray Dare
11,035 PointsI'm getting a 'not authorised' message when I try to open the workspace?
Posted by Murray DareMurray Dare
11,035 Points1 Answer
-
Robert Beviss-Challinor
952 Points0 Answers
-
Megan Weber
31,305 Points1 Answer
View all discussions for this video
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up