下载php工具
[root@VM-4-15-centos ~]# docker pull php
论坛镜像[root@VM-4-15-centos ~]# docker pull tencentci/discuz
[root@VM-4-15-centos ~]# docker run -P -d tencentci/discuz
cb2f93feeca00ea9a43faa354c3037ff9f0cc711c997b122828b1d53100f9ad2
[root@VM-4-15-centos ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
cb2f93feeca0 tencentci/discuz "docker-php-entrypoi…" 4 seconds ago Up 4 seconds 0.0.0.0:49154->80/tcp, :::49154->80/tcp, 0.0.0.0:49153->443/tcp, :::49153->443/tcp reverent_greider
be262c17e58c hello-world "/hello" 9 hours ago Exited (0) 9 hours ago flamboyant_wozniak
[root@VM-4-15-centos ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
cb2f93feeca0 tencentci/discuz "docker-php-entrypoi…" 7 minutes ago Up 7 minutes 0.0.0.0:49154->80/tcp, :::49154->80/tcp, 0.0.0.0:49153->443/tcp, :::49153->443/tcp reverent_greider
[root@VM-4-15-centos ~]# docker top reverent_greider
UID PID PPID C STIME TTY TIME CMD
root 17479 17458 0 19:23 ? 00:00:00 apache2 -DFOREGROUND
33 17514 17479 0 19:23 ? 00:00:00 apache2 -DFOREGROUND
33 17515 17479 0 19:23 ? 00:00:00 apache2 -DFOREGROUND
33 17516 17479 0 19:23 ? 00:00:00 apache2 -DFOREGROUND
33 17517 17479 0 19:23 ? 00:00:00 apache2 -DFOREGROUND
33 17518 17479 0 19:23 ? 00:00:00 apache2 -DFOREGROUND
33 17895 17479 0 19:25 ? 00:00:00 apache2 -DFOREGROUND
33 17896 17479 0 19:25 ? 00:00:00 apache2 -DFOREGROUND
33 17897 17479 0 19:25 ? 00:00:00 apache2 -DFOREGROUND
[root@VM-4-15-centos ~]# yum install mariadb-server -y
启动
[root@VM-4-15-centos ~]# systemctl start mariadb
查看
[root@VM-4-15-centos ~]# ss -lntup |grep 3306
tcp LISTEN 0 50 *:3306 *:* users:(("mysqld"查看
[root@VM-4-15-centos ~]# ps -ef | grep mysql
mysql 20550 1 0 19:43 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
mysql 20720 20550 0 19:43 ? 00:00:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysqlmysql.sock
root 20921 1752 0 19:44 pts/0 00:00:00 grep --color=auto mysql
[root@VM-4-15-centos ~]# mysql_secure_installation
[root@VM-4-15-centos ~]# mysql -uroot -p
输入密码
Enter password:登陆成功
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.68-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database luntan;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> show databases ;
+--------------------+
| Database |
+--------------------+
| information_schema |
| luntan |
| mysql |
| performance_schema |
+--------------------+
4 rows in set (0.00 sec)
MariaDB [luntan]> use luntan;
Database changed
查看
[root@VM-4-15-centos ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
cb2f93feeca0 tencentci/discuz "docker-php-entrypoi…" 36 minutes ago Up 36 minutes 0.0.0.0:49154->80/tcp, :::49154->80/tcp, 0.0.0.0:49153->443/tcp, :::49153->443/tcp reverent_greider
be262c17e58c hello-world "/hello" 9 hours ago Exited (0) 9 hours ago flamboyant_wozniak
[root@VM-4-15-centos ~]# docker exec reverent_greider hostname -I
172.17.0.2
[root@VM-4-15
MariaDB [(none)]> use mysql;
MariaDB [mysql]> grant all on *.* to root@'149.234.46.166' identified by 'mysql';
Query OK, 0 rows affected (0.00 sec)
先使用mysql表
MariaDB [(none)]> use mysql;
MariaDB [mysql]> select user,host,password from user;
+--------+--------------+-------------------------------------------+
| user | host | password |
+--------+--------------+-------------------------------------------+
| root | localhost | *EAAEE581B71C9D3CE27EB4977696364216699B74 |
| root | 127.0.0.1 | *EAAEE581B71C9D3CE27EB4977696364216699B74 |
| root | ::1 | *EAAEE581B71C9D3CE27EB4977696364216699B74 |
| root | 149.234.46.166 | *E74858DB86EBA20BC33D0AECAE8A8108C56B17FA |
| root@% | % | *E74858DB86EBA20BC33D0AECAE8A8108C56B17FA |
+--------+--------------+-------------------------------------------+
MariaDB [mysql]> update user set user="root" where host='%';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0再次查看
MariaDB [mysql]> select user,host,password from user;
+--------+--------------+-------------------------------------------+
| user | host | password |
+--------+--------------+-------------------------------------------+
| root | localhost | *EAAEE581B71C9D3CE27EB4977696364216699B74 |
| root | 127.0.0.1 | *EAAEE581B71C9D3CE27EB4977696364216699B74 |
| root | ::1 | *EAAEE581B71C9D3CE27EB4977696364216699B74 |
| root | 149.234.46.166 | *E74858DB86EBA20BC33D0AECAE8A8108C56B17FA |
+--------+--------------+-------------------------------------------+
[root@VM-4-15-centos ~]# mysql -uroot -p123456 -h 149.234.46.166
MariaDB [(none)]> flush privileges;