Navicat破解网址 https://www.jianshu.com/p/5f693b4c9468
docker pull mysql
docker run -d -p 3306:3306 --name mysql01 mysql/mysql-server
docker logs mysql01 查看日志有默认密码
docker exec -it mysql01 bash 进入到容器里面
# mysql -uroot -p 默认是localhost,然后输入密码
use mysql 提示必须要改密码
修改用户密码 alter user 'root'@'localhost' identified by '123456';
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('password123');
select user,host from user //user表显示信息 改信息
mysql> CREATE USER 'Anker'@'localhost' IDENTIFIED BY 'pwd123456';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'Anker'@'localhost' WITH GRANT OPTION;
mysql> CREATE USER 'Anker'@'%' IDENTIFIED BY 'pwd123456';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'Anker'@'%' WITH GRANT OPTION;
后面有字符集问题 没有默认字符集 中文会乱码应改成utf-8
show variables like '%char%'; 查看所有链接字符集
exit 退出mysql 用户,但还在容器里面
cd /etc cat my.cnf yum install vim 安装vi编辑器
修改MYSQL 默认字符集:
添加到my.cnf
[mysqld]
user=mysql
character-set-server=utf8
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
因为没有外部挂在 就报错了
docker run -d -p 3306:3306 -e "MYSQL_USER=Anker" -e "MYSQL_PASSWORD=sa123456" -e "MYSQL_ROOT_PASSWORD=sa123456" -e "MYSQL_RANDOM_ROOT_PASSWORD=true" --name mysql01 mysql/mysql-server --character-set-server=utf8 --collation-server=utf8_general_ci
Native 链接问题 ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456'; //数据库查询user表,发现新版使用的,caching_sha2_password ,可能我自己的navicat版本不支持这种格式的密码
docker 资料卷
docker restart mysql01 重新启动
docker inspect mysql01 配置参数
用外部volume
vi my.cnf 写入 [mysqld] user=mysql
docker run -d -p 3306:3306 --name mysql01 -v=/docker/mysql/config/my.cnf:/etc/my.cnf -v=/docker/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 mysql/mysql-server
docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=123456' -e 'MSSQL_PID=Developer' -p 1433:1433 -v=/E:/docker/mssql:/var/opt/mssql --name sql1 -d microsoft/mssql-server-linux:2017-latest
MySql.Data.EntityFrameworkCore
来源:oschina
链接:https://my.oschina.net/u/4366204/blog/4047163