- 0. change user in database login allow any host [ '%' ]
- 1. install CoreOS
- 2. install docker-compose
- 3. copy /var/lib/mysql from db old host to CoreOS
- 4. remove ib log file
- 5. create docker-compose.yml
- 6. start with docker-compose up -d
sudo openssl passwd -1 > cloud_config.yml
vi cloud_config.yml
#cloud-config
users:
- name: username
passwd: TEXT IN THIS FILE
groups:
- sudo
- docker
hostname: mysql-newhost
sudo coreos-install -d /dev/sda -C stable -c cloud_config.yml
wget https://raw.githubusercontent.com/coreos/init/master/bin/coreos-install
chomd +x coreos-install
sudo ./coreos-install -d /dev/sda -C stable -c cloud_config.yml
sudo su -
mkdir -p /opt/bin
curl -L https://github.com/docker/compose/releases/download/1.24.1/docker-compose-`uname -s`-`uname -m` > /opt/bin/docker-compose
chmod +x /opt/bin/docker-compose
stop service mysql
service mysql stop
cd to /var/lib/
cd /var/lib/
tar file
tar -zcvf mysql_backup.tar.gz mysql
send file to core os host
scp mysql_backup.tar.gz username@IPNEWHOST:PATH TO SAVEFILE (Ex. /home/username/)
un tar file
tar -zxvf mysql_backup.tar.gz
change name folder
cp -rf mysql mysql_server1
rm mysql_server1/ib_logfile0;
rm mysql_server1/ib_logfile1;
(if root is setting allow any host remove enviroment setting in file docker-compose.yml or comment by # )
mysql_server_01:
image: mysql:5.6
container_name: mysql-server-01
restart: always
environment:
- MYSQL_ROOT_HOST=%
- MYSQL_ROOT_PASSWORD=PASSWORD
ports:
- "3308:3306"
volumes:
- "/home/iserl/mysql_server1:/var/lib/mysql"
docker-compose up -d
Test Connection
mysql -h IPNEWSERVER -P port -u root -pPASSWORD