Docker实践:WordPress

在服务器下创建目录

mkdir mysql-data wordpress-html

运行mysql

docker run -itd --name mysql --restart=always -v /root/mysql-data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD="123456" mysql

创建wordpress数据库

mysql> create database worldpress;

修改mysql 身份验证类型

mysql> use mysql;
Database changed

mysql> SELECT Host, User, plugin from user;
 +-----------+------------------+-----------------------+
 | Host      | User             | plugin                |
 +-----------+------------------+-----------------------+
 | %         | root             | caching_sha2_password |
 | localhost | mysql.infoschema | caching_sha2_password |
 | localhost | mysql.session    | caching_sha2_password |
 | localhost | mysql.sys        | caching_sha2_password |
 | localhost | root             | caching_sha2_password |
 +-----------+------------------+-----------------------+

mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
mysql> FLUSH PRIVILEGES; 

运行wordpress容器

docker run -itd --name wordpress --restart=always -p 80:80 --link mysql:mysql -v /root/wordpress-html:/var/www/html wordpress

发表评论

电子邮件地址不会被公开。 必填项已用*标注