码迷,mamicode.com
首页 > 数据库 > 详细

k8s记录-docker源码安装mysql5.7.20

时间:2020-05-13 11:41:21      阅读:94      评论:0      收藏:0      [点我收藏+]

标签:改密码   exec   gen   chm   down   rac   black   pass   log   

1.下载mysql源码

wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.20.tar.gz 

2.新建my.cnf文件

[client]                            
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock

[mysql]                           
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock

[mysqld]                          
user = mysql                  
basedir = /usr/local/mysql      
datadir = /usr/local/mysql/data    
port = 3306                    
character_set_server=utf8          
pid-file = /usr/local/mysql/mysqld.pid     
socket = /usr/local/mysql/mysql.sock    
server-id = 1

3.新建dockerfile文件

FROM centos:7
ADD mysql-boost-5.7.20.tar.gz /opt
WORKDIR /opt/mysql-5.7.20/
RUN yum -y update
RUN yum -y install cmake ncurses ncurses-devel bison gcc gcc-c++ make
RUN useradd -s /sbin/nologin mysql
RUN cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DSYSCONFDIR=/etc/ -DSYSTEMD_PID_DIR=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DWITH_BOOST=boost -DWITH_SYSTEMD=1
RUN make && make install
RUN chown -R mysql:mysql /usr/local/mysql/
RUN rm -rf /etc/my.cnf
ADD my.cnf /etc
ENV PATH /usr/local/mysql/bin:/usr/local/mysql/lib:$PATH
WORKDIR /usr/local/mysql
RUN bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data
RUN cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/
EXPOSE 3306
RUN echo -e "#!/bin/sh  \nsystemctl enable mysqld" > /run.sh
RUN chmod 755 /run.sh
RUN sh /run.sh
CMD ["init"]

4.执行

build:docker build -t centos:mysql .
运行:docker run --name=mysql_server -d -P --privileged mysql:centos
进入容器:docker exec -it 容器id /bin/bash
修改密码:
mysql -u root -p
Enter password:                #此处直接回车
grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘abc123‘;
grant all privileges on *.* to ‘root‘@‘localhost‘ identified by ‘abc123‘;
flush privileges
exit

k8s记录-docker源码安装mysql5.7.20

标签:改密码   exec   gen   chm   down   rac   black   pass   log   

原文地址:https://www.cnblogs.com/xinfang520/p/12881270.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!