phpMyAdmin: Cannot log into the MySQL server no error code - php

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

Related

Database connect not successful TYPO3

I am working for the first time on one hosting with TYPO3, and seems that I can't connect to database during initial setup (first install). My username and passwords are correct, and I can access to database using other methods but i simply can't with TYPO3 install tool. I tried with default hosts (e.g. localhost and default 127.0.0.1) and even socket based connection but nothing.
Any help please?
Best regrads
I had a similar problem on my local development machine. The solution for me was to comment out the skip-networking line in the MySQL server configuration file my.cnf
At first localhost or 127.0.0.1 will be successful as long as the mysql server is located on the same server.
Either you can create an special typo user for the server and bind it to an DB or you can use the default root user. Any other user also migth work depending on the configuration. Here you should check the accessrigths for the user u want TYPO to log in as.
For the password section you have to check if the user needs a password. If not just omit it.
Also try to select an empty but existing database
The connection type is not really relevant cause most of the problems are caused by wrong host,user, password, database settings.

#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 !?

Why does MySQL always give error access denied even though user exists?

I'm trying to simply run php artisan migrate --seed on a new Laravel project but everytime I try, I get the error:
SQLSTATE[HY000] [1045] Access denied for user 'appuser'#'localhost' (using password: YES)
I check my database config file and the correct username and password for the database are there.
I check MySQL Workbench, and the correct user is there with all the schema privileges for the same password.
I tried adding the user with privileges under %, localhost and 127.0.0.1 but same access denied error.
I ran a quick check to make sure Laravel was selecting the right environment for the database connection details and it is.
I've created users hundreds of times and never had this problem. This all started after I updated to the latest MySQL Workbench 6.1.7 after the older version stopped working correctly on Windows 8. Sadly, I don't have the option to even go back and test if the old version fixes the problem since it won't work at all.
At this point I can't get any new database users to connect.
The database server is up and running, and every other previously existing user still connects just fine.
Here is the my.ini file.
Any ideas? I'm hoping I'm just tired and missing something obvious here.
by reading the config file.
[client]
password = mysql
port = 3306
socket = "{$path}/mysql/mysql.sock"
i think you need to comment the string with default password. Probaby it affects something.
I have recent MariaDB, and the password string is commented out in every config file example

Bizarre error when trying to connect to database

Over the last day or so I'm not able to connect to a database through PHP. Here's what my code connecting to the database looks like
$con = mysqli_connect("localhost","root","password","database");
And here's the strange error.
PHP Warning: mysqli_connect(): (HY000/1045): Access denied for user 'user'#'localhost' (using password: YES) in - on line 2
I'd usually get that error if the credentials are incorrect, but I used a GUI and tested the connection with the exact credentials, where therefore means that, that is not the issue. I just started randomly getting this error and have restarted my computer, reinstalled MySQL, and reconfigure the server I've also tried 127.0.0.1 instead of localhost I'm on localhost so I have full control on pretty much anything and I didn't mess with anything causing this issue. Any ideas?
For some reason the function is trying to connect using the "user" user instead of "root".
You can debug further by adding the error link:
$con= mysqli_connect("myhost","myuser","mypassw","mybd") or die("Error " . mysqli_error($con));
Maybe the problem is in mysql server configuration.
You can try to change password and after flush privileges.
Than restart mysql!
Hope this helps! Bye.
I had the same problem as the title of this question, so incase anyone else googles upon this question and wants to start MySql in 'skip-grant-tables' mode on Windows, here is what I did.
Stop the MySQL service through Administrator tools, Services.
Modify the my.ini configuration file (assuming default paths)
C:\Program Files\MySQL\MySQL Server 5.5\my.ini
In the SERVER SECTION, under [mysqld], add the following line:
skip-grant-tables
so that you have
# SERVER SECTION
# ----------------------------------------------------------------------
#
#The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this
# file.
#
[mysqld]
skip-grant-tables
Start the service again and you should be able to log into your database without a password.

phpMyAdmin causing failed connections

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

Categories