phpMyAdmin causing failed connections - php

I am running phpMyAdmin on an amazon EC2 ubuntu lamp stack, configured to use a remote RDS server.
I have run the sudo dpkg-reconfigure phpmyadmin configuration script, accessed RDS using the master username and master password (not rdsadmin but that set on initialisation), and can log into the phpMyAdmin console.
However, every refresh of the phpMyAdmin interface creates a new failed connection. In the logs I see:
2014-01-14 23:42:20 12879 [Warning] Access denied for user
'phpmyadmin'#'[IP address]' (using password: YES)
What is the best way to try and debug this?
SOLVED
For reference, when using EC2 with RDS and the phpmyadmin installation wizard above, the control user is set to use an unresolvable host, such as ip-[EC2 IP ADDRESS].eu-west-1.compute.internal. Simply changing the host to your actual EC2 IP address allows the connection to become valid and failed connections no longer occur.

This may be because you've configured a controluser in your config.inc.php file (naming the controluser 'phpmyadmin'), but that isn't actually a valid user on the server. If that's the case, you could resolve it by either removing that line from the configuration or creating the user using the script provided (normally in the "examples" folder, but who knows where it is in the Ubuntu file system).
Try grep phpmyadmin config.inc.php on the configuration file and see if anything interesting is found.
Though, come to think of it, normally Ubuntu handles that sort of thing for you, so it's possible you've got a larger misconfiguration going on here. I'd also try reconfiguring it (dpkg-reconfigure --plow phpmyadmin) and see if you can get any further.
Are there any error or warning messages displayed within phpMyAdmin?

Did you add the EC2 ip address to the RDS security group ?
Check this a similar link Using PHPMyAdmin to administer Amazon RDS
Thanks

Related

Permission denied while trying to access localhost

In PHP 7.2 on a Centos 7 machine, I'm trying to access an Apache Jena Fuseki 3.6 SPARQL endpoint.
Fuseki runs on port 3030, the name of the dataset is ds and I can successfully run curl http://localhost:3030/ds - while being logged in on that system even with a user without any rights.
Everything seems fine so far.
However, when I try in a PHP script to do fopen("http://127.0.0.1:3030/ds","r"); or fopen("http://localhost:3030/ds","r"); I always end up with PHP Warning: fopen(http://localhost:3030/ds): failed to open stream: Permission denied.
Fetching a file from the WWW or even from the very same Apache server like fopen("http://localhost/mytest.html","r"); works though.
Are there any special permissions necessary for accessing a different localhost port? firewalld is deactivated, btw.
It turned out that SELinux is the cause of the problem, preventing Apache from doing outbound connections on other ports.
See here: http://sysadminsjourney.com/content/2010/02/01/apache-modproxy-error-13permission-denied-error-rhel/

phpMyAdmin: Cannot log into the MySQL server no error code

I recently copied my mysql db into a new data directory and changed a few settings.
I also accidentally deleted my user directory /home/user and had all the fun of the fair recreating that.
I can now connect to mysql on the command line but cannot connect via phpMyAdmin.
I get the message:
Cannot log in to the MySQL server
I have seen this before, but not without the error code #1045 or #2002 prepended.
Would there be any logs or documentation anywhere about this message without an error code?
UPDATE
phpMyAdmin is installed on the same server and prompts the web user for a username/password in the browser login page, on submit with the correct details it returns to this login page with the error message displayed.
I have tried changing the /etc/phpMyAdmin/config.inc.php line to:
$cfg['Servers'][$i]['host'] = '127.0.0.1'; // previously 'localhost'
I have also tried FLUSH PRIVILEGE to no avail.
According to me the following can be the issue and the ways to resolve it
Causes:
--> path to save php_session is not set or is uncorrectly set:
--> Either php do not have sufficient rights to write to session directory or the directory does not exists.
Solution:
To define the php_session directory add the below line to php.ini file:
session.save_path="/tmp/php_session/"
And give the write rights to the http server.
Mostly, the http server run as user daemon in group daemon. For this case, the following commands will do the work for you :
chown -R :daemon /tmp/php_session
chmod -R g+wr /tmp/php_session
restart http server.
Try it out and let me know
UPDATE
I have found this:-
In some rare cases, if your MySQL process has existed for a long time without any updates to your password, it may be storing your password in a format phpMyAdmin can't authenticate against. This will cause you to be unable to log in via phpMyAdmin, even with the correct username and password. In these cases, it is usually sufficient to change your MySQL password by another means (e.g. the command line), even if you "change" the password to the same thing.
so try just resetting your password through command line as
SET PASSWORD FOR 'root'#'localhost' = PASSWORD('MyNewPass');
Finally fixed it, after much confusion.
Turns out, my my.cnf file was binding the address to our server's internal network IP.
bind-address = 192.168.etc
Previously, before moving the database (and socket location), it was also connecting with 'localhost' correctly (which uses the socket) and allowing login from phpMyAdmin.
After moving the db, the socket connection didn't work, and changing the config.inc.php line to 127.0.0.1 from localhost causes mysql to connect with TCP instead of the socket. This now caused conflict with the bind-address:
$cfg['Servers'][$i]['host'] = '127.0.0.1'; // previously 'localhost'
Removing the bind-address restriction allowed me to login.
A better solution however, was of course to fix the socket connection.
After fussing over permissions for a while, and asking around, someone help me find a setting in mysqli.ini (the extension phpMyAdmin uses to connect to the db):
mysqli.default_socket = /new/location
This fixed the localhost socket connection and I could reinstate my my.cnf bind-address and revert config.inc.php to use 'localhost' again.
in my situation, I just switch the php version from:5.6.16 to 7.0
and then it got login to nothing.
just switch it back, maybe reboot server it will support work in PHP 7.0

#1130 - Host 'localhost' is not allowed to connect to this MySQL server

When I try to access the PhpMyAdmin page, I had the error in the title above.
I tried all procedures found in the internet but unfortunately I didn't found the resolution.
Below the error that I have :
phpMyAdmin tried to connect to the MySQL server, and the server
rejected the connection. You should check the host, username and
password in your configuration and make sure that they correspond to
the information given by the administrator of the MySQL server.
Edit:
Ichecked the Mysql service and I found that is not running, I try to start it but it won't.
I restart the machine and the things return to normal !! but when I edit the My.ini file in order to clean all added entries and restarted Mysql I had the same error and when I added skip-grant-tables option under [mysqld] in My.ini file I had once again access to Mysql !!!
I guess there is an issue in users or privileges !?

Can't access to amazon ec2 instance

I can't access to amazon ec2 instance using ssh terminal:
ssh -i new.pem ubuntu#<public-ip>
It says connection closed by <public ip>
and FileZilla stopped working and I am getting this error:
Error: Server unexpectedly closed network connection
Error: Could not connect to server
This all happened after I changed the server's /etc folder's permissions to 775 to update the php.ini file.
What happened?
Sounds like your instance may be hosed following the permission changes.
Take a look at this question: https://serverfault.com/questions/364677/why-is-chmod-r-777-destructive which describes a similar situation.
And a look at this potential resolution: https://serverfault.com/questions/234061/re-gaining-root-access-to-an-ec2-ebs-boot-image
Never had this happen to me so not personally used the recovery technique.
Good luck!

Wordpress installation - php and mysql are not talking to each other to access database?

I'm trying to get a wordpress local install working on my Mac.
I've recently set up a database, username and password using the MySQL client as per the instructions in the wordpress codex. That part is ok.
When I go to the local site on my computer I'm prompted by wordpress to set up the wp-config.php file. Putting in the same details that definitely work with the MySQL client returns an error.
Manually updating these details in the 'wp-config-sample.php' file and renaming it as 'wp-config.php' also doesn't work - I'm now greeted with a big bold message: "Error establishing a database connection".
From what I can gather, php and mysql are not communicating with each other properly.
I've changed the apache 2 configuration file found in 'etc/apache2/httpd.conf' and uncommented the line which loads the php5 module: LoadModule php5_module libexec/apache2/libphp5.so
and restarted the apache server. This has still not fixed my problem. I'm stuck on what to do next... help appreciated please!
It's been fixed now.
php was looking in the wrong place for the mysql.sock file, and couldn't communicate with the mysql database, meaning wordpress couldn't be set up.
On the command line I typed
ps aux | grep mysql
to bring up as much info about mysql that I could. From this I saw that the mysql socket on my computer is being used at /tmp/mysql.sock
Meanwhile, in the "wp-config.php" file, I changed the line define('WP_DEBUG', false); to define('WP_DEBUG', true); and refreshed my web browser that was showing my localhost setup. This now said a lot more info than "Error establishing a database connection" - infact I could see that the mysql.sock was not configured correctly at all.
Creating a 'phpinfo.php' file with just the single line of code <?php phpinfo(); ?> was the pivotal turning point for me.
Putting that 'phpinfo.php' file in my localhost directory and then viewing it from my web browser not only definitely confirmed that the mysql.sock file was not configured properly, but it also showed where the configurations were being loaded from on my machine: '/private/etc/php.ini'
The next thing I did was open up the 'php.ini' file in a text editor and doing a quick find and replace to update the correct location of mysql.sock.
Finally, a restart of the local apache server needed to be done to fully update all the new settings that I'd been fiddling about with.
sudo apachectl restart
Now everything works fine!
The Error-Message "Error establishing a database connection" indicates clearly, that the php-script can not establish the connection. This can have one of the following reasons:
Your host in the wp-config.php is not correct.
The mysql-server does not listen on that host
The user you set up in the mysql has no privileges to connect the way you are trying
The firewall blocks the access of the php-script to your mysql-host
Try to connect the database with the same settings of your wordpress using Sequel Pro (or any other GUI to connect a mysql database). If the connection works, the problem 2. and 3. isn't your problem.
Look in your firewall-log to make sure 4. is also not your problem.
If all problems are excluded (even 1. after a final check), try to run something like phpMyAdmin to connect your database, to make sure your php-installation has the needed drivers.

Categories