docker mysql数据库
install mysql image:
docker pull mysql
manipulate mysql instance:
docker run --rm -itd --name mysql-wcao12 -p 3306:3306 -e MYSQL_ROOT_PASSWORD=wcao12 mysql
docker exec -it mysql-wcao12 bash
mysql -hlocalhost -uroot -pwcao12
new user:
create user 'test'@'localhost' identified by 'wcao12'; (local)
create user 'wcao12'@'localhost' identified by 'wcao12'; (local)
create user 'wcao12'@'%' identified by 'wcao12'; (remote)
flush authentication:
flush privileges;
create database:
create database test DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
show databases;
grant privileges:
GRANT SELECT ON *.* TO `wcao12`@`%`;
GRANT SELECT ON *.* TO `wcao12`@`%`;
grant select, update, delete on *.* to 'wcao12'@'%';
show grants for 'wcao12'@'%';
show grants for wcao12;
revoke delete on *.* from wcao12;
flush privileges: flush privileges;
show users:
select host,user from mysql.user;
delete user:
drop user 'test'@'localhost';
rename user:
rename user 'test'@'localhost' to 'test1'@'localhost';
2.change schema:
use mysql;