Need help? Call us on 1300 789 260

MySQL: Basic Command Quick Reference

Difficulty: Intermediate

Prerequisites

  • Access to your Virtual Private Server (VPS) via SSH
  • MySQL installed

MySQL Quick Reference

Here's a few of the basic commands to get you started with MySQL from the Linux shell. This article is intended to be a quick reference "cheat sheet" more than an explanation of each command.

Show all databases

SHOW DATABASES;

Create a database

CREATE DATABASE <DATABASENAME>;

Use a database

USE <DATABASENAME>;

Show all tables

SHOW TABLES;

Show a table structure

EXPLAIN <TABLENAME>;

Create a user

CREATE USER '<USERNAME>'@'localhost' IDENTIFIED BY '<PASSWORD>';

Grant the user permissions

GRANT ALL PRIVILEGES ON <DATABASENAME>.* TO '<USERNAME>'@'localhost';

Show running processes

SHOW PROCESSLIST;

Login as the root user to a Plesk based server

mysql -uadmin -p`cat /etc/psa/.psa.shadow`

 

Was this article helpful? Yes No
👥

Having trouble? We’re here to help!

We’ve built our company with a serious focus on quality service. Feel free to give us a call!

1300 789 260