List of MySQL Commands - MySQL Cheat Sheet

Because the bookmark for the page that had all the MySQL Commands I needed to create and manage new databases succumbed to link rot I’m hosting my own page of common and general MySQL commands. It’s focused mostly on getting new databases up and running, and managing users but I’ll add more as I need it. This you can bookmark this page for future reference because I’m never – really, never – going to take down this page and this site will be up for as long as I’m alive (another 40 years at least).

Commands

Start a new session

mysql -u <user> -p starts a new session under the user you selected and will ask for your password.

Create a database

create database <database_name>; creates a new database.

Create a new user and give them permission to use a database

1
2
CREATE USER '<username>@localhost' IDENTIFIED BY '<PASSWORD>';
GRANT ALL ON <database_name>.* to '<username>@localhost';

After user creation and permission grants, be sure to flush privileges for them to take effect.

FLUSH PRIVILEGES;

Exit MySQL

You can press Control + D or type exit;

More to come

I’ll update this list as I come across commands I need to look up and keep it as a reference for as long as I’m employed. So… about another 35 years or so at least. It’s safe to bookmark this page.

Databases, Web development

« How much should a developer make? Taking Startup Advice »

Comments