WordPress + Nginx + MySQL: Problem beim Starten und Ausführen von WordPress (Fehler: Datenbankverbindung kann nicht hergestellt werden)

WordPress + Nginx + MySQL: Problem beim Starten und Ausführen von WordPress (Fehler: Datenbankverbindung kann nicht hergestellt werden)

Ich habe eine Django-App mit Nginx und Gunicorn bereitgestellt und gestern versucht, mein Setup so zu ändern, dass eine WordPress-Seite als Zielseite enthalten ist.

Ich habe dieses Tutorial für die Grundinstallationen befolgthttps://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-lemp-on-ubuntu-18-04 und ich kann die WordPress-Seite nicht anzeigen, da ein wiederkehrender Datenbankverbindungsfehler auftritt. Ich habe seitdem im Internet gesucht und muss nun zugeben, dass ich Hilfe brauche. Ich kann nicht herausfinden, was los ist.

hier ist mein etc/nginx/sites-available/conf:

server {
    server_name  example.com www.example.com;
    root /var/www/html;
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/myexample.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/myexample.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


 index index.php index.html index.htm index.nginx-debian.html;

location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt { log_not_found off; access_log off; allow all; }
    location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
        expires max;
        log_not_found off;
    }


location / {
        #try_files $uri $uri/ =404;
        try_files $uri $uri/ /index.php$is_args$args;
    }
location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/run/php/php7.2-fpm.sock;

}

und hier ist meine WordPress-Konfigurationsdatei in /var/www/html/wp-config.php

define('WP_HOME','https://www.myexample.com');
define('WP_SITEURL','https://www.myexample.com');

define( 'DB_NAME', 'db1' );

/** MySQL database username */
define( 'DB_USER', 'myuser' );

/** MySQL database password */
define( 'DB_PASSWORD', 'mypassword' );

/** MySQL hostname */
define( 'DB_HOST', 'db1.cve345mgm.eu-west-3.rds.amazonaws.com' );

/** Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );

/** The Database Collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );

define('AUTH_KEY',         'authkeypassword');
define('SECURE_AUTH_KEY',  'secureauthkeypassword');
define('LOGGED_IN_KEY',    'loggedinkeypassword');
define('NONCE_KEY',        'noncekeypassword');
define('AUTH_SALT',        'authsaltpass');
define('SECURE_AUTH_SALT', 'securauthsaltpass');
define('LOGGED_IN_SALT',   'loggedinsaltpass');
define('NONCE_SALT',       'Mnocnesaltpass');




define('FS_METHOD','direct');
define( 'WP_DEBUG', false );

/* That's all, stop editing! Happy publishing. */

/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
        define( 'ABSPATH', __DIR__ . '/' );
}

/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';

define('WP_ALLOW_REPAIR', true);

Ich kann bestätigen, dass die Passwörter in dieser Datei mit denen identisch sind, die ich in MySQL eingerichtet habe.

Wenn ich versuche, mit dem folgenden Befehl eine Verbindung zu MySQL herzustellen:

mysql -u myser -h db1.cve345mgm.eu-west-3.rds.amazonaws.com -p 

Ich erhalte die folgende Fehlermeldung:

ERROR 2003 (HY000): Can't connect to MySQL server on 'db1.cve345mgm.eu-west-3.rds.amazonaws.com' (110).

Ich habe jedoch die Hostverbindung mit nmap überprüft und sie funktioniert:

All 1000 scanned ports on db1.cve345mgm.eu-west-3.rds.amazonaws.com (xxx.xx.xxx) are filtered

Nmap done: 1 IP address (1 host up) scanned in 82.14 seconds

Zusätzlich ist hier die Ausgabe für mysql-log:

2020-08-31T23:21:58.350728Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentat$
2020-08-31T23:21:58.352669Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.31-0ubuntu0.18.04.1) starting as process 26674 ...
2020-08-31T23:21:58.357638Z 0 [Warning] One can only use the --user switch if running as root

2020-08-31T23:21:58.360084Z 0 [Note] InnoDB: PUNCH HOLE support available
2020-08-31T23:21:58.360107Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-08-31T23:21:58.360112Z 0 [Note] InnoDB: Uses event mutexes
2020-08-31T23:21:58.360116Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2020-08-31T23:21:58.360121Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-08-31T23:21:58.360125Z 0 [Note] InnoDB: Using Linux native AIO
2020-08-31T23:21:58.360371Z 0 [Note] InnoDB: Number of pools: 1
2020-08-31T23:21:58.360478Z 0 [Note] InnoDB: Using CPU crc32 instructions
2020-08-31T23:21:58.365097Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2020-08-31T23:21:58.374004Z 0 [Note] InnoDB: Completed initialization of buffer pool
2020-08-31T23:21:58.376393Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2020-08-31T23:21:58.388238Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2020-08-31T23:21:58.397442Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2020-08-31T23:21:58.397496Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2020-08-31T23:21:58.433771Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2020-08-31T23:21:58.434521Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2020-08-31T23:21:58.434533Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2020-08-31T23:21:58.434820Z 0 [Note] InnoDB: Waiting for purge to start
2020-08-31T23:21:58.485059Z 0 [Note] InnoDB: 5.7.31 started; log sequence number 2750396
2020-08-31T23:21:58.485458Z 0 [Note] Plugin 'FEDERATED' is disabled.
2020-08-31T23:21:58.491549Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2020-08-31T23:21:58.492694Z 0 [Note] InnoDB: Buffer pool(s) load completed at 200831 23:21:58
2020-08-31T23:21:58.493566Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2020-08-31T23:21:58.493576Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
2020-08-31T23:21:58.494126Z 0 [Warning] CA certificate ca.pem is self signed.
2020-08-31T23:21:58.494160Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2020-08-31T23:21:58.494227Z 0 [Note] Server hostname (bind-address): 'db1.cve345mgm.eu-west-3.rds.amazonaws.com'; port: 3306
2020-08-31T23:21:58.497633Z 0 [Note]   - 'db1.cve345mgm.eu-west-3.rds.amazonaws.com' resolves to 'xxx.xx.xx.x';
2020-08-31T23:21:58.499484Z 0 [Note] Server socket created on IP: 'xxx.xx.xx.x'.
2020-08-31T23:21:58.499502Z 0 [ERROR] Can't start server: Bind on TCP/IP port: Cannot assign requested address
2020-08-31T23:21:58.499507Z 0 [ERROR] Do you already have another mysqld server running on port: 3306 ?
2020-08-31T23:21:58.499540Z 0 [ERROR] Aborting

und nginx-log:

2020/08/31 19:33:45 [alert] 25670#25670: *62 open socket #15 left in connection 4
2020/08/31 19:33:45 [alert] 25670#25670: *61 open socket #14 left in connection 5
2020/08/31 19:33:45 [alert] 25670#25670: *63 open socket #16 left in connection 6
2020/08/31 19:33:45 [alert] 25670#25670: *59 open socket #3 left in connection 7
2020/08/31 19:33:45 [alert] 25670#25670: *60 open socket #13 left in connection 8
2020/08/31 19:33:45 [alert] 25670#25670: *64 open socket #17 left in connection 9
2020/08/31 19:33:45 [alert] 25670#25670: aborting

und wenn ich es versuche, sudo service mysql restart erhalte ich die folgende Fehlermeldung:

● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2020-08-31 22:13:50 UTC; 12s ago
  Process: 27253 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid (code=exited, status=0/SUCCESS)
  Process: 28990 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)
 Main PID: 27255 (code=exited, status=0/SUCCESS)

Aug 31 22:13:49 ip systemd[1]: mysql.service: Control process exited, code=exited status=1
Aug 31 22:13:49 ip systemd[1]: mysql.service: Failed with result 'exit-code'.
Aug 31 22:13:49 ip systemd[1]: Failed to start MySQL Community Server.
Aug 31 22:13:50 ip systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Aug 31 22:13:50 ip systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Aug 31 22:13:50 ip systemd[1]: Stopped MySQL Community Server.
Aug 31 22:13:50 ip systemd[1]: mysql.service: Start request repeated too quickly.
Aug 31 22:13:50 ip systemd[1]: mysql.service: Failed with result 'exit-code'.
Aug 31 22:13:50 ip systemd[1]: Failed to start MySQL Community Server.

UPDATE: Bei genauerem Hinsehen der Zeile:

Process: 27253 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid (code=exited, status=0/SUCCESS)

Mir ist aufgefallen, dass ich kein mysqld-Verzeichnis habe. ~/var/run/Könnte das das Problem sein? Ich habe festgestellt, dass ich ein mysqlVerzeichnis habe var/lib/, aber keine Berechtigung dafür habe cd. Das alles scheint so bizarr!

Ich habe das Gefühl, ich habe alles versucht, was ich finden konnte, und nichts scheint zu funktionieren. Ich hoffe, dass jemand sieht, wo ich einen Fehler mache. Danke

verwandte Informationen