PHP & MySQL – The Engine and the Cabinet
To understand how dynamic websites work, think of a busy restaurant:
- MySQL Database = Kitchen/Pantry: Stores all raw ingredients (posts, user data, settings) in organized bins.
- PHP = Chef: Takes an order, grabs the right ingredients from the database, "cooks" them into a webpage, and serves it to the visitor.
1. What is PHP? (The Engine)
PHP is a Server-Side Scripting Language. Code runs on the server before the webpage reaches the browser.
- Dynamic Content: Unlike static sites, PHP can show personalized content (e.g., "Hello, John!" vs. "Hello, Jane!").
- The Brains: Handles logic—checks passwords, processes contact forms, calculates shopping carts.
2. What is MySQL? (The Cabinet)
MySQL is a Relational Database Management System (RDBMS). It stores all the information that makes your website unique in structured tables.
- Every blog post and page you’ve written.
- Every visitor comment.
- Site settings (site title, theme choice).
- User account details (encrypted passwords, emails).
3. How They Work Together (The 4-Step Cycle)
- The Request: Browser requests a page (e.g., yourdomain.com/blog-post-1).
- The Query: PHP asks MySQL: "Give me the text and title for Blog Post #1."
- The Fetch: MySQL retrieves the data and sends it back to PHP.
- The Assembly: PHP wraps the text in your website theme (HTML/CSS) and sends the finished page to the browser.
4. Managing Your Database: phpMyAdmin
You don’t need coding knowledge to manage your database. Most hosting plans, including Jiinubi, include phpMyAdmin, a visual tool to explore your "Cabinet."
Pro-Tip: You can manually reset a WordPress password here if the "lost password" email isn’t working.
5. Performance & Versions
- Use the Latest PHP: Upgrading from PHP 7.4 to PHP 8.x can make your site up to 2x faster and more secure.
- WP-Config File: This file tells PHP which database name and password to use to connect to the MySQL "Cabinet."
⚠️ Caution:
Database backups are essential. Files (images/themes) are on disk, but content lives in the database. Always back up both your files and MySQL database, or you’ll risk losing all your content.
Database backups are essential. Files (images/themes) are on disk, but content lives in the database. Always back up both your files and MySQL database, or you’ll risk losing all your content.