Get the App
SLTechnology News&Howtos  ›  Servers  › 

Docker install mysql5.7

Shulou Source: shulou.com Published: 2022-06-02 21:50:50 09月22日 Update

1. Pull the image

Docker pull mysql:5.7

two。 View local image

Docker images

3. Create a directory

Mkdir / usr/local/docker/mysql/logs

Mkdir / usr/local/docker/mysql/data

Mkdir / usr/local/docker/mysql/conf

4. Create a my.cnf file with the following contents

[mysql]

# set mysql client default character set

Default-character-set=utf8

Socket=/var/lib/mysql/mysql.sock

[mysqld]

# handling of incompatibility issues after 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

# maximum number of connections allowed

Max_connections=200

# the character set used by the server defaults to the 8-bit encoded latin1 character set

Character-set-server=utf8

# default storage engine to be used when creating new tables

Default-storage-engine=INNODB

Lower_case_table_names=1

Max_allowed_packet=16M

# set time zone

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. Start the container

Docker run-- name mysql5.7-p 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. View container startup status

Docker ps-a

7. Test connection

You can connect through visualization tools.

Tags: Characters character sets containers mirrors maximum content customers clients tools engines files time zones status directories encodings problems visualization processing storage services Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Microsoft NVidia Shulou Technology vpn