Photo by Wesley Tingey / Unsplash

Mysql Basics

Mysql Oct 3, 2021

Lets assume that you already have mysql (server) installed and running.

Create Database

create database some_db;

or with character set

create database `some_db` CHARACTER SET utf8 COLLATE utf8_general_ci;

Create User

create user 'some_user'@'%' identified by 'secret';

Give Privileges to User

grant all privileges on some_db.* to 'some_user'@'%';flush privileges;

Show Users

select user,host from mysql.user;

Show Grants

show grants for 'some_user'@'%';

Give Admin Rights

grant all privileges on *.* TO 'some_user'@'localhost';

or

grant all privileges on *.* TO 'some_user'@'%';

Drop database | Delete

drop databse some_db;

Drop user | Delete

drop user some_db_user;

Show Process list

show processlist;

Tags