Skip to main content
The SQL tab is where you’d run any query that isn’t a one-row edit. It accepts any valid MySQL statement, runs it against the active database, and shows the result below.

Open the SQL tab

1

Pick the scope

Click a database in the left tree to run queries against the whole database. Click into a specific table to scope queries to that table.
2

Click the SQL tab at the top

A multi-line text area opens with a basic syntax-highlighted editor.
phpMyAdmin SQL tab with the query editor
3

Type or paste your query

Multiple statements separated by semicolons all run in sequence. The result panel shows them stacked.
4

Click Go

The results appear under the editor. Above the results, phpMyAdmin echoes the SQL it ran. Useful for spot-checking before you re-run.

Useful keyboard shortcuts

KeysAction
Ctrl+EnterRun the query (same as clicking Go)
Ctrl+SpaceAuto-complete table or column names
TabIndent (handy when nesting queries)

Bookmarks

If a query is one you’ll run repeatedly, save it as a bookmark.
1

Type the query

Same as a normal run.
2

Tick 'Bookmark this SQL query'

Below the editor, just above Go.
3

Name and save

Give the bookmark a name. Click Go.
4

Run it later

On any future visit to the SQL tab, scroll down to Bookmarked SQL query and pick it from the dropdown. Click Submit to run it again.
Bookmarks are per database. Useful patterns:
  • A long JOIN you tweak when debugging
  • A DELETE FROM sessions WHERE last_seen < NOW() - INTERVAL 30 DAY you run before exports
  • An ad-hoc analytics query for the marketing team

Query history

The SQL tab keeps a running list of queries you’ve executed in the current session. Open the Query history dropdown above the editor to revisit them. Sessions reset when you close the browser tab, so save anything important as a bookmark.

Safety tips for production data

An UPDATE or DELETE without a WHERE clause hits every row. There’s no undo button.
A few habits that have saved me:
  1. Run as SELECT first. Run SELECT * FROM users WHERE last_login < '2024-01-01' before turning it into DELETE FROM users WHERE last_login < '2024-01-01'. Confirm the row count matches what you expected.
  2. Wrap in a transaction for InnoDB tables. START TRANSACTION; before the UPDATE/DELETE, then SELECT COUNT(*) to verify, then COMMIT; (or ROLLBACK; if it’s wrong). Doesn’t work on MyISAM.
  3. LIMIT your destructive queries. DELETE FROM logs WHERE created_at < '2024-01-01' LIMIT 1000, run it a few times. Easier to spot a wrong condition before you’ve nuked half the table.
  4. Take an export first. Five minutes of “I’ll just dump it before I touch it” can save hours of restore work later.

Common issues

A typo, an unclosed quote, or a backtick around something that doesn’t need one. Look at the position pointed at in the error message. phpMyAdmin highlights the offending character.If the query was pasted from somewhere else, check for smart-quote characters that look like ' but aren’t.
The user you’re running phpMyAdmin as doesn’t have read access to that table. cPanel logs you in as the cPanel account user, which has access to your databases. But if you’ve revoked privileges through Manage My Databases, this is the message you’ll see.
A JOIN on un-indexed columns, or a LIKE '%...' against a big text column. Either kill the query (close the browser tab and the connection drops within a minute) or add an index first via Table Operations.Repeated long-running queries from the same account can trigger our automatic resource limits. See common issues on Manage My Databases.

Need a hand?