欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

docker mysql数据库

程序员文章站 2024-01-08 17:59:58
...

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;

 

相关标签: mysql

上一篇:

下一篇: