Run mysql in cmd window:
1) Database startup
net start mysql
2) Database stops
net stop mysql
3) Log in using root account
mysql -uroot -p密码
4) Show all databases
show databases;
5) Use a certain database
use <数据库名>
6) Change password
update mysql.user set authentication_string=PASSWORD('123456') where user='root;
7) Refresh
flush privileges;
8) Create user
CREATE USER '用户名'@'主机' IDENTIFIED BY '密码';
Example:
CREATE USER 'dog'@'localhost' IDENTIFIED BY '123456';
CREATE USER 'pig'@'192.168.1.101_' IDENDIFIED BY '123456';
CREATE USER 'pig'@'%' IDENTIFIED BY '123456';
CREATE USER 'pig'@'%' IDENTIFIED BY '';
CREATE USER 'pig'@'%';
(%: Allow this user to log in from any remote host)
9) Create a database
method one:
create database <数据库名称>;
Method Two:
create database if not exists <数据库名称> default charset <数据库字符集编码>;
10) Delete a database
method one:
drop database <数据库名称>;
Method Two:
drop database if exists <数据库名称>;