Skip to content

Mysql Basics

Create Database;

MySQL
create database dbname;

or

MySQL
create database `dbname` CHARACTER SET utf8 COLLATE utf8_general_ci;

or

MySQL
create schema some_db default character set utf8mb4;

Create User

MySQL
create user 'user'@'%' identified by 'some_pwd';

Grant Privileges to User

MySQL
grant all privileges on dbname.* to 'user'@'%';
flush privileges;

Show Users

MySQL
select user,host from mysql.user;

Show Grants

MySQL
show grants for 'some_user'@'%';

Give Admin Rights

MySQL
GRANT ALL PRIVILEGES ON *.* TO 'some_user'@'%';
MySQL
GRANT ALL PRIVILEGES ON *.* TO 'some_user'@'localhost';

Drop database

MySQL
drop databse some_db;

Show Process list

MySQL
show processlist;

max connections

MySQL
show variables like "max_connections";

Increase max connections:

MySQL
set global max_connections = 200;

max allowed packets

See max allowed packets value:

MySQL
SHOW VARIABLES LIKE 'max_allowed_packet';

Change max allowed packets value:

MySQL
SET GLOBAL max_allowed_packet=16777216;
Back to top