How to Run SQL Queries in phpMyAdmin
This tutorial demonstrates how to run SQL queries in phpMyAdmin.
SQL queries are commands that you issue to the MySQL server to tell it to perform various functions. Designed for advanced users, this allows you to quickly make changes to your database simply by issuing the appropriate commands.
This tutorial shows you where to execute SQL queries, but not what queries to execute. The exact SQL queries you will execute will depend on what you want to do.
Queries are Context-Sensitive
The SQL tab appears above all pages inside of phpMyAdmin. This tab is context-sensitive, which means that depending on what you're looking at, the target of your SQL queries might be different.
If you are on the home page of phpMyAdmin and do not have any databases selected, if you click on the SQL tab, any queries you run will apply to the overall server (or hosting account if on shared hosting).
If you select a database, any queries run by clicking on the SQL tab will apply to that database.
If you select a table within a database, any queries run by clicking on the SQL tab will apply to that table.
Summary of Steps
Begin by accessing phpMyAdmin via cPanel or Plesk.
- Navigate to the area your SQL query will apply to.
- The phpMyAdmin home page if you want the query to apply to the whole server or hosting account.
- The database you want to run queries against.
- The table you want to run queries against.
For this example, let us use the database example_db1. Click example_db1 from the list of databases on the left-side menu.
- Click on the SQL tab.
- Type in your SQL query. For this example, let us use the query CREATE TABLE to create a new table thisismynewtable.
- Click on Go. Your SQL query will be executed and the actions you requested will be performed.
- The new table, thisismynewtable, is now created under the database example_db1.