Loading...

Knowledge Base

Run SQL Queries in phpMyAdmin

 

SQL queries are commands that you execute to the MySQL server to tell it to perform various functions. Designed for advanced users, this lets you quickly change your database by issuing the appropriate commands.

This tutorial shows you where to execute SQL queries in your control panel but not what queries to execute. The exact SQL queries you will execute will depend on your intent.

Video Tutorial


Be careful when executing SQL queries because it will do whatever you tell it to do (and not necessarily what you want it to do). Always double-check any destructive commands (such as DROP) to make sure it is acting upon the items you intend it to act upon. If you are making significant changes, it is recommended that you make a backup before you begin.

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, your SQL query target might differ.

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.

How to run SQL Queries 

  1. Log in to your cPanel or Plesk.
  2. Navigate to your control panel and click the phpMyAdmin icon.

    Plesk:
    Plesk phpMyAdmin

    cPanel:
    cPanel phpMyAdmin

  3. On the phpMyAdmin homepage, navigate to the area where you wish to run your SQL query.
    • 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.
  4. For this example, let us use the database example_db1. Click example_db1 from the list of databases on the left-side menu.

    cPanel - phpMyAdmin - Databases

  1.  
  2. Click on the SQL tab.

    SQL tab

  3. Type in your SQL query. For this example, let us use the query CREATE TABLE to create a new table, thisismynewtable.

    Sample Query

  4. Click on Go.

    Your SQL query will be executed, and your requested actions will be performed.

  5. The new table, thisismynewtable, is now created under the database example_db1.

    Sample new database

 

Did you find this article helpful?

 
* Your feedback is too short

Loading...