-
This guide provides step-by-step instructions for creating and managing databases and users, as well as importing and exporting databases, using phpMyAdmin. Follow these steps to set up and maintain your MySQL or MariaDB databases effectively.
Creating a New Database and User
Step 1: Access phpMyAdmin
- Log in to phpMyAdmin via your hosting control panel (e.g., cPanel) or directly at https://yourdomain.com/phpmyadmin.
- Use your MySQL/MariaDB root credentials or an account with administrative privileges.
Step 2: Create a Database
- In phpMyAdmin, click the Databases tab.
- Enter a unique database name (e.g., mydb) in the Create database field.
- Select a collation, such as utf8mb4_unicode_ci, for compatibility with modern applications.
- Click Create. The database will appear in the left sidebar.
Step 3: Create a User
- Click the User accounts tab (or Privileges in older versions).
- Select Add user account.
- Fill in the user details:
- Username: Choose a unique username (e.g., dbuser).
- Host name: Select Local (for localhost) or % (for remote access).
- Password: Set a strong password or use the Generate button.
- Re-type: Confirm the password.
- Under Database for user account, select Grant all privileges on database and choose your database (e.g., mydb).
- Click Go to create the user.
Step 4: Verify Access
- Log out and test the new user’s credentials by logging back into phpMyAdmin.
- Ensure the user can access only the assigned database.
Importing a Database
Step 1: Select the Database
- In phpMyAdmin, select your database (e.g., mydb) from the left sidebar.
- Click the Import tab.
Step 2: Upload the SQL File
- Click Choose File and select your .sql or .sql.gz file.
- Set the Character set to utf8mb4 (or match your database’s collation).
- Click Go to import the file.
Step 3: Verify the Import
- Check the database tables in the left sidebar to confirm the data was imported correctly.
- If errors occur, verify the SQL file’s format or check user privileges.
Note: Large databases may cause timeouts in phpMyAdmin. For files over 50MB, contact your hosting provider or use command-line tools like mysqldump.
Exporting a Database
Step 1: Select the Database
- In phpMyAdmin, select your database (e.g., mydb) from the left sidebar.
- Click the Export tab.
Step 2: Export the Database
- For a simple export:
- Select Quick and choose SQL as the format.
- Click Go to download the .sql file.
- For advanced options:
- Choose Custom to select specific tables or enable options like Add DROP TABLE.
- Select compression (e.g., zipped) for large databases.
- Click Go to download.
Step 3: Save the Backup
- Store the exported .sql file securely for backups or migrations.
- Regularly export your database to prevent data loss.
- 0 gebruikers vonden dit artikel nuttig
