I have a Wordpress server (php-fpm / nginx), completely fresh. Powered by CentOS. I also have a docker container built from vanilla mysql server image.
MySQL configuration
It works on the port 3306, and all MySQL users are registered in MySQL with a host 172.17.0.1(for example, root@172.17.0.1), which is the gateway IP gateway. A docker container is installed using a downloadable file. All configuration parameters are parameterized, and these parameters are used everywhere, including the WordPress configuration file and environment variables that fill in things like the root password during the installation of the MySQL dock. Here, where I set up the appropriate database:
WordPress configuration:
These are two parts of which I will include the relevant ones. In my obscure play, this code sets up a WordPress user table and (successfully):
- name: Create WordPress database
mysql_db:
name: '{{ wp_db_name }}'
state: present
login_user: root
login_password: '{{ mysql_root_password }}'
login_host: '{{ docker_mysql_ip }}'
- name: Create WordPress database user
mysql_user:
name: '{{ wp_db_user }}'
password: '{{ wp_db_password }}'
priv: '{{ wp_db_name }}.*:ALL'
state: present
login_user: root
host: '{{ docker_gateway_ip }}'
login_password: '{{ mysql_root_password }}'
login_host: '{{ docker_mysql_ip }}'
And the corresponding wp-config.php:
define('DB_NAME', 'wordpress');
define('DB_USER', '{{ wp_db_user }}');
define('DB_PASSWORD', '{{ wp_db_password }}');
define('DB_HOST', '{{ docker_mysql_ip }}');
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
When I go to wp-admin, the specific problem indicated is " Warning: mysql_connect(): Permission denied in /srv/wordpress/wp-includes/wp-db.php on line 1473", entitled "Error connecting to database," status code 500.
The tangled part
When I check the wp-config.php file, the username, password, and database name are exactly the same as they should be. When I copy / paste the host, user and password from wp-config.phpto their respective locations on the command line (for example mysql -u wordpress -p -h 172.17.0.2), I can connect as well as view the Wordpress database.
Summarizing
MySQL , Wordpress . Wordpress PHP, , , , .