docker for mysql

#搜索mysql
docker search mysql

#下载mysql
docker pull mysql:5

#运行
docker run --name bd-portal-mysql -v D:\test\mysql-data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -p 3306:3306 -d --network bd-portal-bridge mysql:5

#进入mysql容器
docker exec -it bd-portal-mysql /bin/bash
mysql -uroot -p

 #修改账户密码加密规则并更新用户密码
 ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
 
 #创建用户
 CREATE USER 'bd-portal'@'%' IDENTIFIED BY 'bd-portal';
 GRANT ALL PRIVILEGES ON  godb.* TO 'bd-portal'@'%';
 FLUSH PRIVILEGES;
 
 #创建数据库
 create database `bd-portal` default character set utf8 collate utf8_general_ci;
 
 #授权用户
 grant select,insert,update,delete,create,drop,REFERENCES on `bd-portal`.* to `bd-portal`;
 FLUSH PRIVILEGES;
 
 #删除数据库
 drop database `bd-portal`;
 
 #取消大小写敏感
 #修改:/etc/mysql/mysql.conf.d/mysqld.cnf
 #增加lower_case_table_names=1
 docker cp bd-portal-mysql:/etc/mysql/mysql.conf.d/mysqld.cnf f:\\
 docker cp f:\\mysqld.cnf bd-portal-mysql:/etc/mysql/mysql.conf.d/mysqld.cnf

你可能感兴趣的:(docker)