How to Access phpMyAdmin & Manage Databases

phpMyAdmin is a widely-used web-based tool for managing MySQL and MariaDB databases. It provides an intuitive graphical interface to create, modify, and delete databases, tables, and records without requiring command-line expertise. This guide will walk you through how to access phpMyAdmin and perform common database management tasks.


How to Access phpMyAdmin

Accessing phpMyAdmin via cPanel

  1. Log in to your hosting account and go to cPanel.

  2. Scroll down to the Databases section and click on phpMyAdmin.

  3. This will open the phpMyAdmin interface where you can manage your databases.

Accessing phpMyAdmin via Direct URL

If your hosting provider allows direct access, use this URL:

https://yourdomain.com/phpmyadmin

You may be prompted to enter your database username and password, which can be found in your hosting account or wp-config.php file (for WordPress users).

Accessing phpMyAdmin on a Local Server

For local development using tools like XAMPP, MAMP, or WAMP:

  1. Start your Apache and MySQL services.

  2. Open your web browser and go to:

http://localhost/phpmyadmin/

This will give you access to phpMyAdmin on your local machine.


How to Create a New Database

  1. In phpMyAdmin, click on the Databases tab.

  2. Enter a name for your new database in the Create database field.

  3. Select a collation (usually utf8mb4_general_ci for general use).

  4. Click Create.

Your new database will now appear in the list of available databases.


How to Import a Database

If you have an existing database backup, follow these steps to import it:

  1. Select the database where you want to import the data.

  2. Click on the Import tab.

  3. Click Choose File and select your .sql file.

  4. Click Go to start the import process.

  5. You will see a success message once the import is complete.


How to Export a Database

To back up your database:

  1. Select the database you want to export.

  2. Click the Export tab.

  3. Choose the Quick export method and select SQL as the format.

  4. Click Go to download the backup file.

For advanced users, the Custom option allows you to fine-tune export settings.


How to Manage Tables in phpMyAdmin

Creating a New Table

  1. Select the database where you want to create a table.

  2. Click on the Structure tab and scroll down to the Create Table section.

  3. Enter a table name and specify the number of columns.

  4. Define column names, data types, and constraints.

  5. Click Save to create the table.

Editing an Existing Table

  • Click on a table name to view its structure.

  • Select Change next to a column to modify its type, name, or default value.

  • Click Save to apply changes.

Deleting a Table

  1. Navigate to the Structure tab.

  2. Click Drop next to the table you want to delete.

  3. Confirm the deletion.

Warning: Deleting a table permanently removes all its data.


How to Manage Database Users

Creating a New Database User

  1. Click on the User Accounts tab.

  2. Click Add user account.

  3. Enter a username and password.

  4. Under Global Privileges, assign the necessary permissions.

  5. Click Go to create the user.

Assigning User Privileges

  1. Select a database and go to the Privileges tab.

  2. Click Edit privileges next to the user.

  3. Select the privileges needed (e.g., SELECT, INSERT, DELETE, etc.).

  4. Click Go to save the changes.

Deleting a User

  1. Go to the User Accounts tab.

  2. Click Drop next to the user you want to remove.

  3. Confirm deletion.


How to Run SQL Queries in phpMyAdmin

phpMyAdmin allows users to execute SQL commands directly.

  1. Select your database.

  2. Click the SQL tab.

  3. Enter your SQL query, e.g.:

    SELECT * FROM users;
  4. Click Go to execute the query.

  5. Results will be displayed below.


How to Fix Common phpMyAdmin Errors

Error: "Access Denied for User"

  • Ensure that the username and password are correct.

  • If using WordPress, check the wp-config.php file for correct credentials.

  • Reset the database user password in your hosting panel.

Error: "Connection Timed Out"

  • Increase the max_execution_time in the php.ini file.

  • Optimize large queries to improve performance.

Error: "Database Collation Issues"

  • Change collation settings using the following SQL command:

    ALTER DATABASE database_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

Conclusion

phpMyAdmin is a powerful tool for managing MySQL databases without requiring complex command-line operations. By following this guide, you can access phpMyAdmin, create and manage databases, import/export data, assign user privileges, and troubleshoot common issues efficiently. Keeping regular backups and understanding database management best practices will ensure your website or application runs smoothly.

Last updated

Was this helpful?