docker 安裝mysql mongo
阿新 • • 發佈:2018-12-20
docker pull mysql/mysql-server
docker run -d -p 3306:3306 --name [Name] [ImageName] //示例 docker run -d -p 3306:3306 --name mysql01 mysql/mysql-server
docker exec -it [ContainerName] bash //示例 docker exec -it mysql01 bash
mysql -uroot -p
mysql> CREATE USER 'test'@'localhost' IDENTIFIED BY 'pwd123456'; mysql> GRANT ALL PRIVILEGES ON *.* TO 'test'@'localhost' WITH GRANT OPTION; mysql> CREATE USER 'test'@'%' IDENTIFIED BY 'pwd123456'; mysql> GRANT ALL PRIVILEGES ON *.* TO 'test'@'%' WITH GRAN T OPTION;
[mysqld] character-set-server=utf8 [client] default-character-set=utf8 [mysql] default-character-set=utf8
show variables like '%char%';
docker run -d -p 3306:3306 -e MYSQL_USER="test" -e MYSQL_PASSWORD="password" -e MYSQL_ROOT_PASSWORD="password" --name [Name] [ImageName] --character-set-server=utf8 --collation-server=utf8_general_ci
docker run -d -p 3306:3306 -e MYSQL_USER="test" -e MYSQL_PASSWORD="password" -e MYSQL_ROOT_PASSWORD="password" --name [Name] [ImageName] --character-set-server=utf8 --collation-server=utf8_general_ci
[mysqld] user=mysql character-set-server=utf8 [client] default-character-set=utf8 [mysql] default-character-set=utf8
docker run -d -p 3306:3306 --name mysql01 -v=/docker/mysql/config/my.cnf:/etc/my.cnf -v=/docker/mysql/config/data:/var/lib/mysql mysql/mysql-server
docker run -d -p 27017:27017 --name mongo01 -v /docker/mongo/config:/data/configdb -v /docker/mongo/db:/data/db mongo
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('password');
ALTER user 'root'@'localhost' IDENTIFIED BY 'password'
mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
FLUSH PRIVILEGES;
備註: : When this is true (which is its default state, unless MYSQL_ROOT_PASSWORD is set or MYSQL_ALLOW_EMPTY_PASSWORD is set to true), a random password for the server's root user is generated when the Docker container is started
當這個MYSQL_RANDOM_ROOT_PASSWORD 為true 時 為root使用者設定密碼是沒有作用的還是會生成隨機的密碼,設定為false 或者不加這個環境變數