您好,登錄后才能下訂單哦!
1.拉取鏡像
docker pull mysql:5.7
2.查看本地鏡像
docker images
3.創建目錄
mkdir /usr/local/docker/mysql/logs
mkdir /usr/local/docker/mysql/data
mkdir /usr/local/docker/mysql/conf
4.創建my.cnf文件,內容如下
[mysql]
#設置mysql客戶端默認字符集
default-character-set=utf8
socket=/var/lib/mysql/mysql.sock
[mysqld]
#mysql5.7以后的不兼容問題處理
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
#允許最大連接數
max_connections=200
#服務端使用的字符集默認為8比特編碼的latin1字符集
character-set-server=utf8
#創建新表時將使用的默認存儲引擎
default-storage-engine=INNODB
lower_case_table_names=1
max_allowed_packet=16M?
#設置時區
default-time_zone='+8:00'
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
#
# include all files from the config directory
#
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
5.啟動容器
docker run --name mysql5.7 -p 3306:3306 --privileged=true --restart=always -d -v /usr/local/docker/mysql/logs:/logs -v /usr/local/docker/mysql/data:/var/lib/mysql -v? /usr/local/docker/mysql/conf/my.cnf:/etc/mysql/mysql.conf.d/mysqld.cnf -e MYSQL_ROOT_PASSWORD=Cc201818 mysql:5.7
6.查看容器啟動狀態
docker ps -a
7.測試連接
通過可視化工具進行連接即可
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。