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?

Related Articles