Error establishing a database connection Amazon EC2 - after moving my wordpress blog

后端 未结 13 1953
無奈伤痛
無奈伤痛 2021-02-01 09:03

I am getting the error: \"error establishing a database connection\" after moving my wordpress blog to Amazon EC2. I\'ve checked the wp-config.php file and settings are ok (loca

相关标签:
13条回答
  • 2021-02-01 09:40

    The below fixed it for me:

    amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2 &&
    service httpd restart
    
    0 讨论(0)
  • 2021-02-01 09:41

    If the server keep crashing after restart maybe you should increase your memory, upgraded the server from t2.micro to t2.medium do the trick for me.

    0 讨论(0)
  • 2021-02-01 09:42

    I had same error. Every time my EC2 server rebooted due to lack of memory. Mysql did not restart causing my websites to crash by showing "Error establishing a database connection" At first, I restart my server from WHM, that fixed the error immediately. The error return next time the server rebooted again. I also tried to ssh auto restart mysql database on boot commands, but that was not problem. All though my security group was setup to accept all traffic, I had to change my security group to include mysql, and reboot my instances to fix the error. I not sure if this will work for everyone with EC2. That worked for me

    0 讨论(0)
  • 2021-02-01 09:43

    I'm not sure which distribution your using so here's how I generally solve these types of issues.
    1. install a program called nmap (it scans ports) 2. run 'nmap localhost' (replace localhost with whichever server is running your database if its not local) 3. check to see if your database(mysql) is running

    If not, then do something to the effect of 'services mysqld restart' (this will restart the mysql daemon). If this fixes it, then look into have that service autostart. If you get an error with that command than you may not have mysql installed.

    0 讨论(0)
  • 2021-02-01 09:46

    You did not indicate whether you are moving your blog from myolddomain.com to mynewdomain.com, and whether you are using normal WordPress or multi-site WordPress. But here are some tips that might help:

    • First, you need to make sure your wp-config.php is configured correctly (database server, username, password...)

    • Secondly, WordPress uses database to store some information about the current host, look at tables wp_site, wp_options,wp_sitemeta and replace all rows containing myolddomain.com by mynewdomain.com.

    • Make sure your EC2 security group is configured correctly.

    This article might help, too.

    0 讨论(0)
  • 2021-02-01 09:48

    Increase ur swap memory in ec2 that solves the problem. http://digitizor.com/2011/02/06/create-swap-file-ubuntu-linux/

    0 讨论(0)
提交回复
热议问题