当前位置:网站首页>Docker dockerfile installation mysql5.7
Docker dockerfile installation mysql5.7
2022-06-13 11:43:00 【Lyndon1107】
mysql install
s
[[email protected] home]# cat dockerfile_mysql
FROM centos:latest
MAINTAINER lyndon1107
# Deploy linux7 Version of mysql 64 position
ADD mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz /usr/local
COPY my.cnf /etc/my.cnf
COPY mysql_config.sh /usr/local/
# ENV MYSQL_ALLOW_EMPTY_PASSWORD yes
VOLUME ["/home/mysql/data"]
RUN sh /usr/local/mysql_config.sh
EXPOSE 3306
ENTRYPOINT /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf
#CMD ["sh", "/usr/local/mysql_config.sh"]
# ---------------------------------------------------------------------------------------------------------------------------
# ---------------------------------------------------------------------------------------------------------------------------
# docker build -f dockerfile_mysql -t lyndon1107/mysql:latest .
# adopt mysql:5.7c Mirror starts with a name of mysql The container of ,root The password for 123456, And persist the data to the host /home/mysql/data Next :
# docker run -d lyndon1107/mysql:latest -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 --name mysql -v /home/mysql/data:/home/mysql/data
# docker run --name mysql -v /home/mysql/data:/home/mysql/data -p3306:3306 -itd lyndon1107/mysql:latest tail -f /dev/null
# initialization mysql
# /usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/home/mysql/data
# function mysql
# docker exec -it e636b1b32926 /usr/local/mysqld --defaults-file=/etc/my.cnf
# download
# wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz
# CentOS Download and unload mariadb
# rpm -qa | grep mariadb && rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
# RUN echo "character-set-server=utf8" >> /usr/local/mysql/mysql.conf.d/mysqld.cnf
# RUN echo "bind-address=0.0.0.0 >> /usr/local/mysql/mysql.conf.d/mysqld.cnf"
# After installation , Modify the current data The directory is owned by mysql user ,data Directory is the default data directory , In the extracted Directory . namely /home/mysql/data
mysql_config.sh
[[email protected] home]# cat mysql_config.sh
#!/bin/bash
# https://zhuanlan.zhihu.com/p/122578441
yum install -y net-tools gcc gcc-c++ ncurses-devel bison perl perl-devel libaio numactl libncurses* lvm2
echo ' establish mysql user '
groupadd mysql && useradd -g mysql -s /sbin/nologin -M mysql
cd /usr/local && mv mysql-* mysql && mkdir -p /home/mysql/data/ && mkdir -p /usr/local/mysql/var
echo ' Authorize file permissions '
cd /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql && chown mysql:mysql /etc/my.cnf && chown -R mysql:mysql /home/mysql/data
chmod -R 777 /tmp && chmod -R 777 /usr/local/mysql/var
# The old version Define the primary and database installation directories to which the database belongs
# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/home/mysql/data
echo 'start mysql ......'
# initialization mysql
# /usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/home/mysql/data
#/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf
#/usr/local/mysql/bin/mysql -uroot -h 127.0.0.1 -p
# use mysql;
# ALTER user 'root'@'%' identified by '123456'; # Old edition set password for [email protected]'%' = 123456;
#grant all privileges on *.* to [email protected]'%' identified by '123456';
#flush privileges;
echo 'mysql install success, ok!'
my.cnf
[[email protected] /]# vi /etc/my.cnf
[mysqld]
#skip-grant-tables
basedir=/usr/local/mysql
datadir=/home/mysql/data
socket=/usr/local/mysql/var/mysql.sock
user=mysql
log-error=/usr/local/mysql/var/error.log
server-id=2
#symbolic-likes=0
character-set-server=utf8
max_connections=10000
#default-time_zone = '+8:00'
bind-address=0.0.0.0
explicit_defaults_for_timestamp=true
[mysqld_safe]
log-error=/usr/local/mysql/var/mysqld.log
pid-file=/usr/local/mysql/var/mysql.pid
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
Set up a remote connection
First step , modify /etc/mysql/my.conf
find bind-address = 127.0.0.1 This line is changed to bind-address = 0.0.0.0 that will do
The second step , Give permissions to users who need to log in remotely
1、 Create a new user remote connection mysql database
grant all on . to [email protected]’%’ identified by ‘123456’ with grant option;
flush privileges; Allow any ip Address (% It means to allow any ip Address ) For computers admin Account and password (123456) To visit this mysql server. Be careful admin The account does not have to exist .
2、 Support root Users allow remote connections mysql database
grant all privileges on . to ‘root’@’%’ identified by ‘123456’ with grant option;flush privileges;
The third step , View system users
Reference material
centos7 install mysql-5.7.28
https://www.cnblogs.com/qixing/p/12271499.html
DockerFile Local installation MySQL5.7.25
https://blog.csdn.net/haiyangyiba/article/details/88805729
边栏推荐
- 【TcaplusDB知识库】TcaplusDB-tcapulogmgr工具介绍(二)
- fastapi 如何响应文件下载
- 关于 SAP Spartacus CmsService.getComponentData 可能的优化思路
- [tcapulusdb knowledge base] Introduction to new models of tcapulusdb
- Design and implementation of database for banking system
- 【TcaplusDB知识库】Tmonitor单机安装指引介绍(一)
- Show/exec and close/hide of QT form are not executed when calling the close destructor
- ARM64 上的性能怪兽:API 网关 Apache APISIX 在 AWS Graviton3 上的安装和性能测试
- [ROS] moveit rviz seven DOF Manipulator Simulation
- Multiplicative inverse action
猜你喜欢
关于 SAP Spartacus CmsService.getComponentData 可能的优化思路
【TcaplusDB知识库】Tmonitor后台一键安装介绍(二)
[tcapulusdb knowledge base] tcapulusdb doc acceptance - Introduction to creating game area
多系统对接的适配与包装模式应用
socket编程(中)
【TcaplusDB知识库】TcaplusDB-tcapsvrmgr工具介绍(三)
燃油方案和产品业务建模
1051. 高度检查器
State compression DP example (traveling salesman problem and rectangle filling problem)
VSCode 如何将已编辑好的文件中的 tab 键转换成空格键
随机推荐
[tcapulusdb knowledge base] tcapulusdb doc acceptance - create business introduction
UE4, ue5 phantom engine, command console command, parameter set
Text error correction -- crisp model
Tamidog knowledge | a comprehensive analysis of the meaning and role of mergers and acquisitions of state-owned enterprises
Discord机器人开发
【TcaplusDB知识库】Tmonitor系统升级介绍
How fastapi responds to file downloads
MCDF Experiment 2
break algorithm---multi-interface
Notes on the development of raspberry pie (16): Raspberry pie 4b+ install MariaDB database (MySQL open source branch) and test basic operations
ARM64 上的性能怪兽:API 网关 Apache APISIX 在 AWS Graviton3 上的安装和性能测试
(幼升小信息-04)如何用手机WPS在PDF上进行电子签名
[tcapulusdb knowledge base] Introduction to tmonitor background one click installation (II)
2022.2:EyeshotPro EyeshotUltimate EyeshotFem
【TcaplusDB知识库】TcaplusDB新增机型介绍
kubernetes 部署 ActiveMQ
(一)爬取Best Sellers的所有分类信息:爬取流程
Ipdu handling caused by mode change of COM
Apache apisik v2.14.1 exploratory release to expand into more fields
『忘了再学』Shell基础 — 30、sed命令的使用