Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Docker install mysql5.7

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report