Laravel database connection times out but can connect via mysql command - php

I'm facing a very weird issue here and have spent a lot of time trying to debug.
My app resides in AWS environment. My staging environment is just an EC2 (CentOS 7) hosting Laravel and database is hosted in RDS. Staging environment is working perfectly fine.
I then cloned the EC2 and RDS for production and for unknown reason my Laravel keeps complaining that connection to database times out. Things I've tried:
Since I can run mysql -u<username> -p<password> and connect successfully then it means that Security Group and database permission are fine.
I also ensured that the .env file contains the correct connection info.
Laravel is also able to list out the correct environment variables.
Lastly, I scanned through the code to ensure that there's no database connection hardcoded.
I don't know what else I missed out.

The solution was very simple. It was very silly of me to miss out a backend instance. Once that was sorted out, the error disappeared.

Related

Database is disappearing from phpmyadmin

We've build an application using wampserver, PHP and MySQL. We are working offline in the meantime for funds reasons and can't upload it online with a dedicated IP address. Each few days, we receive a PHP error on the LOGIN page saying that there isn't a database named X.
We went to the phpmyadmin and the shock was that the database isn't there.
We tried to see if it is hidden in the config file of PHPmyadmin, but it isn't.
Then, we deleted ib_logfile0 and ib_logfile1 from the mysql data bin directory, and after restarting the computer, the database appeared again normally.
After few days, the same thing happens. We deleted the both files but this time the database didn't appeared in wamp. We glad that we backuped the data last time, but there is a full week data that may be lost now.
What is the problem ? Is it a computer virus or wampserver needs to be installed again ?
Error:
#2002 - No connection could be made because the target machine actively refused it. — The server is not responding (or the local
server's socket is not correctly configured).

Accidentally uninstalled mysql on AWS EC2 with wordpress multisite. Need a little guidance

I have a wordpress multisite installation running on an AWS EC2 (t2.medium).
After messing around trying to get phpmyadmin installed on the server I accidentally deleted httpd,mysql-server etc. It broke everything.
Thankfully, I used a plugin called Snapshot from wpmu-dev and had everything backed up but now I'm running into some trouble and not entirely sure how to do this.
Current situation:
1. Created an instance snapshot through my aws dashboard.
2. Backed up everything from /var/www/html/ to my local drive.
3. Reinstalled mysql and httpd, started it, went through the steps provided here - https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/hosting-wordpress.html - however, when setting up the database it states that wordpress-db and the user are already there and my old password still works yet wordpress isn't working?
So I'm not sure where to go from here, shall I just delete my instance and start again from scratch? Loading what I need back into the /var/www/html folder? Or is there a way that I can completely delete my database and then rebuild the tables with the snapshot and get back to where I started?
Thanks in advance for your help folks, really stuck here, have a website that's down!
If you are not sure what happened I would recommend you start from scratch.
Launch an EC2 instance and follow the steps on the guide you provided:
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/hosting-wordpress.html
Download MySQL workbench and connect to the database (remember
modifying the security permissions temporarily
to be able to connect to the database from your computer) (https://dev.mysql.com/downloads/workbench/)
Restore the sql backup (if you have one, or create one if you don't) to restore the database to your new ec2 instance MySQL. You can do this following the Data import section: https://dev.mysql.com/doc/workbench/en/wb-admin-export-import-management.html
Make sure the configuration file is correct (url, database path, name, etc) (https://codex.wordpress.org/Editing_wp-config.php)
I would recommend to point your domain to your new ec2 instance only after it has been properly configured and tested.

No connection to Oracle DB after Linux upgrade and OCI8-Installation

OpenSuse Leap 42.1 (latest upgrade)
Apache2, PHP 5.5 installed
OCI8 installed
ORACLE 11g
Last week, I got some update issues with KDE and did an upgrade of OpenSuse Leap 42.1. I then went over the whole procedure of installing oci8 (as described in http://php.net/manual/en/oci8.installation.php and making sure to use the correct PECL) and everything worked fine.
But when I restarted my system a few hours later, I was't able to connect via hhtp to any vhost due to failed connection to the database.
I get no error logs anywhere, just a white 404 page or the message "Error: Could not connect to database. Aborting." (depending on which page I'm calling). Pages with no connection to the database work perfect!
SQLDeveloper connects without any proble, using the same parameters as in the config-files for the vhosts.
Anyone any idea?
Generally when you get a
ORA-12514
it means that the listenr you are connecting to knows not the servicename/SID you're attempting to connect to. If you get that error it should indicate that the client got some sort of response from the listener which should exclude all sorts of network issues.
This is very much similar to ORA-12514 TNS:listener does not currently know of service requested in connect descriptor
only that the issue sprouted up after an update.
I would first look in the client side tnsnames.ora and the server side listener.ora to check that everything is ok. Also check that the database is registered on the listener. Possibly also check that the db is remotely reachable from a known good client to exclude any issues on the listener configuration.
problem(s) solved!
as there were two different of them provoking a problem salad.
first, the update somehow managed to change some parameters in my config files, first of all the database name.
then, apache update from 2.2 to 2.4 DID change some things in the vhosts config files and therefore the errors were never logged in the former x_error.log and the 404 message was shown.
thx a lot for your response, louigi600!

Apache, PHP, MySQL, PDO, Permission denied , laravel

I'm working on a fun little PHP web application (a manager for my repeating, daily tasks), mostly for the exercise. The 'production' server is a bit limiting, and I cannot view httpd's (Apache's) error logs there, so I've set up my own local httpd as a development server (just good sense). However, my web app makes use of a MySQL database. I will create a local one eventually, but I thought, to make things easier to start, I would just use the remote one.
SQLSTATE[HY000] [2002] Permission denied.
This is what came back each time I tried running the web application from my local httpd. I'm using PHP's PDO database interface, and its mysql driver, and it works when deployed on the remote server. I made sure that my remote server had permissions for my local user. I tested connecting from my local machine from the mysql client, and it worked. I tested the PHP connection statement from the command-line and ... it worked. It is only causing a problem when running within the web application.
Please tell me how to solve this issue. This is the site on which i am getting error pickprogress.com
Some various server provider gives us their database server name. And instead of writing localhost or 127.0.0.1 we have to write their given server name.
I was trying to solve this problem since last 8 hours but didn't found single solution but anyhow I have now solved it.

MySQL, PHP, Login Info correct yet "Unable to connect to the database" error

Alright -
So this is a wee bit frustrating. I have my local Development Server and my remote Test Server. They are using identical code deployed from GitHub, including (temporarily) identical login credentials. Both Apache Servers use local MySQL Servers (for now). I have verified on both MySQL servers that the relevant user has identical permissions & passwords to a certain database.
In other words, everything is theoretically the same. EXCEPT my dev server is Windows (running XAMPP) and my Test server is Linux (running LAMP).
I am using a CodeIgniter Framework. So the problem is, my Test code runs fine on my Test box, but when I try to run it on local Dev I get the error "Unable to connect to the database". I am thinking that there must be a configuration issue between PHP & MySQL on my Dev server since I've pretty much eliminated MySQL credentials as being a possibility.
Any ideas? Much appreciated... Debbie
multiple environments with codeigniter
https://www.codeigniter.com/user_guide/general/environments.html

Categories