Docker+Wordpress station building problem summary record

Wordpress] dashboard - unable to access after setting change and fixed connection (domain name change without filing / Nginx reverse proxy)

Cause of the problem: if the domain name is changed to a domain name (for example, the domain name is not filed) because the domain name cannot be accessed directly, simulate the request process

  • PC browser input IP port:
  • After receiving the request, Wordpress automatically redirects the set domain name. At this time, the domain name is not resolved / filed, resulting in inaccessibility, so the interface displays 404 or other interfaces

Solution

  1. Log in to ECS
  2. Enter MySQL dock
View running docker process
    $ docker ps 
get into docker Mirror inside
    $ docker exec -it fId bash
    If specified when starting mirroring name You can name Mode entry
    $ docker exec -it wp(Name at startup) bash get into docker

fId is the first 12 alphanumeric mixed combination at runtime

When you see the / $representative and the docker in this item, exit exits

3. Log in to MySql, enter the database and execute the update command

  • Sign in
$ mysql -uroot -p 
  • Enter and enter the password (the password is not displayed) the password when starting mysql

If the startup user name is different, mysql -u user name - p

Display MySQL > to enter

  • Enter the database (select the database to operate)
$ show databales;    View all libraries
$ use wordpress;     get into wordpress 

The display of Database changed indicates successful switching

After entering the library (the library to be operated must be switched), execute the command

View all tables  wp_options in
    $ show tables;   
View the current data in the table
    $ select * from wp_option where option_id=1;
If you forget to set something, this view is usually the first one option_value Chinese domain name 
    $ select * from wp_otion where option_value='Domain name set from dashboard/IP';
    $ select * from wp_otion where option_value link '%xx%';   Fuzzy query %It matches everything in front of it
 Update command  UPDATE Table name SET field=value  where Constraints change those
    $ UPDATE wp_options SET option_value = replace( option_value, 'http://Old domain name ',' http: / / new domain name ') WHERE option_name = 'home' OR option_name = 'siteurl';
    $ UPDATE wp_posts SET post_content = replace( post_content, 'http://Old domain name ',' http: / / new domain name ');
    $ UPDATE wp_posts SET guid = replace( guid, 'http://Old domain name ',' http: / / new domain name ');

    $ UPDATE wp_comments SET comment_content = replace(comment_content, 'http://Old domain name ',' http: / / new domain name ');
    $ UPDATE wp_comments SET comment_author_url = replace(comment_author_url, 'http://Old domain name ',' http: / / new domain name ');

wordpress mysql link failed after running

  • Q1 Problem Description:

During startup, the IP uses 127.0.0.1 / localhost / 0.0.0.0 management interface. The access fails during initialization Docker WordPress connection to docker MySQL

  • A1 solution

Create a new docker network, check the docker IP and restart

  1. Add a docker network
$ docker network create docker-mysql-net

2. Check the network IP ifconfig and remember to try to connect using the newly created ip

  • For example: restart wordpress
$ WORDPRESS_DB_HOST=172.18.0.1:3306 -e WORDPRESS_DB_USER=root -e WORDPRESS_DB_PASSWORD=123456-e WORDPRESS_DB_NAME=wordpress-p 8050:80 -d hub.c.163.com/library/wordpress  
Note that other configurations are the same as before, but WORDPRESS_DB_HOST use ifconfig Viewed docker IP start-up

After the above attempts, the problem cannot be solved

Try root connection

mysql -h0.0.0.0 -uroot -p password

root can connect, but the newly created account cannot connect

  • A2 solution Please authorize the user% because the permission is insufficient, please authorize. docker belongs to a separate virtual environment, and the network Ip is not 127.0.0.1 localhost, so you need to authorize%
  1. root connection entry
mysql -h0.0.0.0 -uroot -p password

2. Authorization

grant all privileges on `Database name`.* to 'User name'@'%' ;

Added by amitvedak on Wed, 02 Mar 2022 13:41:49 +0200