MySQL Start/Stop:
net start mysql;
net stop mysql;
cd /usr/local/mysql/bin
sudo ./mysqld_safe
./mysqladmin –p –u root shutdown
MySQL User:
Use MYSQL;
Describe USER;
Select host, user, grant_priv from USER;
MySQL INFORMATION_SCHEMA:
Use INFORMATION_SCHEMA;
Describe TABLES;
Select TABLE_NAME, TABLE_SCHEMA from TABLES;
Describe VIEWS;
Select TABLE_NAME, TABLE_SCHEMA from VIEWS;
Describe ROUTINES;
Select SPECIFIC_NAME,ROUTINE_DEFINITION from ROUTINES;
Describe SCHEMA_PRIVILEGES;
Select GRANTEE, TABLE_SCHEMA from SCHEMA_PRIVILEGES;
User Management:
Create User 'name'@'host' [Identified by 'password'];
Drop user 'name'@'host';
Rename user 'name'@'host' To 'new_name'@'host';
Managing Permission & Security:
USE MYSQL;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
Delete From USER where user='';
FLUSH PRIVILEGES;
Grant privileges On target To 'new_name'@'host' [Identifid By 'password'];
Revoke privileges On target From 'new_name'@'host';
ALTER USER 'new_name'@'localhost' IDENTIFIED BY 'password';
Show Grants For 'new_name'@'host';
privileges
Table:
'Select', 'Insert', 'Update', 'Delete', 'Create', 'Drop', 'Grant',
'References', 'Index', 'Alter', 'Create View', 'Show view', 'Trigger'
Column:
'Select', 'Insert', 'Update', 'References'
Process:
'Execute', 'Create Routine', 'Alter Routine', 'Grant'
General:
'All [Privileges]','Super'
target
Global privileges:
ON *.*
Database:
ON db_name.*
Table:
ON db_name.table_name
Column:
GRANT privileges(col_name) [,...] ON db_name.table_name ...
System Variables:
Show variables like 'max%';
Select @@max_allowed_packet;
my.ini: max_allowed_packet=16M (allows larger files to be stored in e.g. longblob)
Documentation
Examples:
Create User 'su'@'localhost' Identified by 'xq81y7z3';
Grant All Privileges On *.* to 'su'@'localhost' With Grant Option;
Create User 'reader'@'localhost' Identified by 'only1234';
Grant Select On SALES.* to 'reader'@'localhost';
Create User 'seeprod'@'localhost' Identified by 'prod1234';
Grant Select On SALES.PRODUCT to 'seeprod'@'localhost';
Create User 'seeprodqoh'@'localhost' Identified by 'onhand1234';
Grant Select (pid, onhand) On SALES.PRODUCT to 'seeprodqoh'@'localhost';
Show Function Status;
Show Procedure Status
Help Show;