This course will be retired on June 1, 2025.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
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 upRelated 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