Mysql

From roonics
Revision as of 09:02, 25 June 2019 by Jlambert (talk | contribs)
Jump to navigation Jump to search

MySQL

Useful Commands

Connect to database

mysql -u <username> -p

Show process list

mysqladmin -p processlist

or if already connected to MySQL

show processlist;

Create database

CREATE DATABASE <db_name;

Show databases

show databases;

Select database

use <db_name>;

Show tables

show tables;

Show table layout

describe <table_name>;

Create a MySQL user

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

Replace username and password with the username and password required

Grant permissions to a database

GRANT ALL PRIVILEGES ON database.* to username@localhost;

Replace database and username with the database and username required

Once this has been run, run the below command to flush privileges:

FLUSH PRIVILEGES;

Finally this command to verify:

SHOW GRANTS FOR 'username'@'localhost';