docker离线安装mysql 如何用docker部署一个mysql
如何用docker部署一个mysql
1 docker pull mysql
2 docker run -v /data/var/mysql/:/var/lib/mysql -e YSQL_ROOT_PASSWORD=kS4pJUIb mysql
3 docker stop [CONTAINER ID]
4 docker run -it -v /data/var/mysql/:/var/lib/mysql mysql /bin/bash
5 mysqld_safe&
6 grant all privileges on *.* to wuxiao@% identified by password
7 docker cp [CONTAINER ID]:/etc/mysql/my.cnf /data/local/my.cnf
8 docker stop [CONTAINER ID]
9 docker run -d -p 3306:3306 -v /data/var/mysql/:/var/lib/mysql -v /data/local/my.cnf:/etc/mysql/my.cnf mysql
10 add [CMD] to /etc/rc.local
11 OK!
在docker怎么起mysql
进入Linux后,使用Docker命令下载MySQL,命令如:
docker pull mysql:5.运行该命令后,则会显示以下日志:
5.7: Pulling from mysql
4c8cbfd2973e: Pull complete
60c52dbe9d91: Pull complete
c2b0136be90f: Pull complete
273cd71eacf0: Pull complete
543ff72402d8: Pull complete
f928e22e58b0: Pull complete
2d1023ecaed4: Pull complete
059dbbef4dd8: Pull complete
ac0ee0367a32: Pull complete
a9057a689e83: Pull complete
5191ddfc3b01: Pull complete
6e2ce31eb835: Pull complete
099dc92e9b15: Pull complete
7b4030a6b20b: Pull complete
fdb9c2185fc2: Already exists
mysql:5.7: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.
Digest: sha256:d00f3f3cd30d0e8ad9bdf8ba61729ee1a4b6fe84a0fbb95f07dc2668a4cb5d0 Status: Downloaded newer image for mysql:5.下载需要一段时间,下载完毕后,启动Docker容器。
如何安装安装mysql-devel包
安装linux一些必须的包:
yum install gcc gcc-c gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* libevent
安装mysql,mysql安装包需要自己下载,安装目录 /usr/local/web/
sudo mkdir -p /usr/local/web/
sudo tar xzvf mysql-5.1.39.tar.gz
cd mysql-5.1.3 ./configure --prefix=/usr/local/web/mysql.5.1.39 --enable-thread-safe-client --enable-assembler --with-big-tables --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=complex
make
make install
创建mysql用户组等信息
sudo groupadd mysql
sudo useradd -g mysql -s /sbin/nologin mysql
sudo ./scripts/mysql_install_db --user=mysql --datadir=/usr/local/web/mysql.5.1.39/var
sudo chown -R root /usr/local/web/mysql.5.1.3 sudo chown -R mysql:mysql /usr/local/web/mysql.5.1.39/var
管理MYSQL
#启动mysql:
sudo /usr/local/web/mysql.5.1.39/share/mysql/mysql.server start
#重启mysql
sudo /usr/local/web/mysql.5.1.39/share/mysql/mysql.server restart
#停止mysql
sudo /usr/local/web/mysql.5.1.39/share/mysql/mysql.server stop
linux