Sign inSign up

hotxia/tgc-mysql

By hotxia

Updated almost 7 years ago

云平台MySQL服务(192.168.0.53)

Image
0

157

hotxia/tgc-mysql repository overview

云平台MySQL服务Docker操作:

1.下载Docker镜像

[root@linux-node1 ~]# docker pull hotxia/tgc-mysql
Using default tag: latest
latest: Pulling from hotxia/tgc-mysql
Digest: sha256:ca4318ed9820ebbcdb996149ff58911eaec44103caac638ca39083dbef2a4045
Status: Image is up to date for hotxia/tgc-mysql:latest
docker.io/hotxia/tgc-mysql:latest

2.启动Docker容器

[root@linux-node1 ~]# docker run -itd -p 192.168.56.11:3306:3306 hotxia/tgc-mysql /bin/bash
0fcf4fef2eb75d187ca84d4e003ec76d235c5837148347d3c8f603ef0712f231

3.进入Docker容器查看服务是否运行正常

[root@linux-node1 ~]# docker ps
CONTAINER ID        IMAGE                     COMMAND             CREATED             STATUS              PORTS                          NAMES
0fcf4fef2eb7        hotxia/tgc-mysql          "/bin/bash"         3 seconds ago       Up 2 seconds        192.168.56.11:3306->3306/tcp   silly_khayyam
3e0ca74ee3cf        hotxia/tgc-nginx-images   "/bin/bash"         22 hours ago        Up 22 hours         192.168.56.11:80->80/tcp       condescending_gould
6574c715eb61        196e0ce0c9fb              "/bin/bash"         26 hours ago        Up 26 hours                                        lucid_hellman
[root@linux-node1 ~]# docker exec -it 0fcf4fef2eb7 /bin/bash

4.处理Docker容器中MySQL初始化错误

[root@0fcf4fef2eb7 ~]# rm -rf /usr/local/mysql/data/*
[root@0fcf4fef2eb7 ~]# mysqld --initialize-insecure

5.启动MySQL容器服务

[root@0fcf4fef2eb7 ~]# nohup /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --user=root &
[1] 80

[root@0fcf4fef2eb7 ~]# ss -tnl
State       Recv-Q Send-Q                                         Local Address:Port                                                        Peer Address:Port              
LISTEN      0      80                                                      [::]:3306                                                                [::]:*    

6.修改MySQL容器root用户密码

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql> update user set authentication_string=password('123456789') where  user='root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456789' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

Tag summary

Content type

Image

Digest

Size

2.5 GB

Last updated

almost 7 years ago

docker pull hotxia/tgc-mysql