phpmyadmin: Access denied for user 'root'@'localhost'

New to Debian (Or Linux in general)? Ask your questions here!

phpmyadmin: Access denied for user 'root'@'localhost'

Postby Jarry » 2017-08-19 18:08

I just installed LAMP on debian9, but I can not log in to phpmyadmin with mariadb root/passwd. All I get is:

#1698 - Access denied for user 'root'@'localhost'
mysqli_real_connect(): (HY000/1698): Access denied for user 'root'@'localhost'

But I can log in to mariadb using command-line:
mysql -u root -p
...

So where is the problem? Why I can not login to mariadb over phpmyadmin?
Jarry
 
Posts: 4
Joined: 2017-08-19 17:55

Re: phpmyadmin: Access denied for user 'root'@'localhost'

Postby dasein » 2017-08-19 19:53

Jarry wrote:So where is the problem?

The root problem lies in your failure to do a simple search before posting a forum question:

The verbatim title you chose for your thread returns over 100K answers to the question: https://www.google.com/search?q=phpmyad ... 8&oe=utf-8

And please accompany any claim that you did too search ("for hours" :roll:) with a complete list of the exact things you have already tried and the exact results and verbatim output of each attempt.

If you are unable to do so for some mysterious reason, then go back and retry each and every one of them to produce that list. After all, there's no point in anyone here suggesting something you already tried, right?

(To be clear: "I tried them all and nothing worked" is neither specific nor even remotely believable. You did not try so much as 1% of the 100K available answers.)
User avatar
dasein
 
Posts: 7775
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: phpmyadmin: Access denied for user 'root'@'localhost'

Postby pendrachken » 2017-08-19 23:13

dasein wrote:
Jarry wrote:So where is the problem?

The root problem lies in your failure to do a simple search before posting a forum question:

The verbatim title you chose for your thread returns over 100K answers to the question: https://www.google.com/search?q=phpmyad ... 8&oe=utf-8

And please accompany any claim that you did too search ("for hours" :roll:) with a complete list of the exact things you have already tried and the exact results and verbatim output of each attempt.

If you are unable to do so for some mysterious reason, then go back and retry each and every one of them to produce that list. After all, there's no point in anyone here suggesting something you already tried, right?

(To be clear: "I tried them all and nothing worked" is neither specific nor even remotely believable. You did not try so much as 1% of the 100K available answers.)





Since I am personally sick of hearing this in every thread from you:

You know how you tell Gary to STFU about all the stuff he doesn't understand all the time? Take your own advice and ignore all of these people that you tell to search better. As it is we might as well make an edit to the PHPBB code to just make a post comprised of " you suck at searching, goaway --signed dasein" to be immediately posted at each new thread generation.

That or try posting actual answers, I think I saw one maybe two actual answers in the last year from you. The rest was immediately jumping to conclusions, calling people trolls, and bitching incessantly about how people can't do searches.


TL;DR: Let easy search solvable threads die a natural death, your post count doesn't really matter that much.


EDIT = please feel free to add me to your ever-growing ignore list. Then you can wonder why the forums are so silent when you finally have "*" at the top of your list.
fortune -o
Your love life will be... interesting.
:twisted: How did it know?

The U.S. uses the metric system too, we have tenths, hundredths and thousandths of inches :-P
pendrachken
 
Posts: 1298
Joined: 2007-03-04 21:10
Location: U.S.A. - WI.

Re: phpmyadmin: Access denied for user 'root'@'localhost'

Postby GarryRicketson » 2017-08-20 01:44

It would help to know what version of MySQL, is it MySQL 5.7 ?
So where is the problem?

More then likely it is this:
From :https://askubuntu.com/questions/763336/cannot-enter-phpmyadmin-as-root-mysql-5-7 MySQL 5.7 changed the secure model: now MySQL root login requires a sudo (while the password still can be blank).

I.e., phpMyAdmin will be not able to use root as user.

The simplest (and safest) solution will be create a new user and grant required privileges.


I have had the same problem on various servers, it can be different things. Most recently,but also it was not Debian, after several tries, it occurred to me that maybe phpmyadmin is not really necessary, and I decided to just not use it, it is not necessary, everything works just fine with out it. If you don't believe me see :
http://parrotsandopenbsd.org/myforum/index.php it does work just fine
without phpmyadmin.

To avoid getting search results that are mostly just for ms windows,
It will be better if you add Debian, or specify Linux in your search string, like this:
Code: Select all
phpmyadmin: Access denied for user 'root'@'localhost' on a Debian system

you can copy paste into any search engine.
Also, this yields many results, that should be usefull:
https://www.startpage.com/do/search/?q=Access%20denied%20for%20user%20%27root%27@%27localhost%27%20mysqli_real_connect():%20(HY000/1698)
======================================================
This : https://stackoverflow.com/questions/36864206/sqlstatehy000-1698-access-denied-for-user-rootlocalhost-tried-everythi
Note where it mentions :
bind to all addresses:
The easiest way is to comment out the line in your /etc/mysql/mariadb.conf.d/50-server.cnf or /etc/mysql/mysql.conf.d/mysqld.cnf file, depending on what system you are running:
Code: Select all
bind-address = 127.0.0.1


Why I can not login to mariadb over phpmyadmin?


Since you have not really given much details, it is not possible to give a definite answer,
It may take a few tries before you get the passwords and user names set correctly, it was the same for me, it did not work the first couple of times,...
But in a nut shell, the reason you can not login via phpmyadmin , is something is wrong with how you set the user and password.
This was the reason I had problems recently :

MySQL makes a difference between "localhost" and "127.0.0.1".

It might be possible that 'root'@'localhost' is not allowed because there is an entry in the user table that will only allow root login from 127.0.0.1.

This could also explain why some application on your server can connect to the database and some not because there are different ways of connecting to the database. And you currently do not allow it through "localhost".

My self: Hah, it turned out to be so simple, I was using "localhost" as the "hostname" , then I noticed on the tutorial,

Database host; Enter 127.0.0.1 or ::1. Do not leave it as “localhost” as we want to use the sockets;


When I used 127.0.0.1 it worked fine. [/quote]
So any way, if none of the things in the above links work, and you can give more details ,
show the error messages, etc,... maybe someone can narrow it down to something specific.
User avatar
GarryRicketson
 
Posts: 4588
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: phpmyadmin: Access denied for user 'root'@'localhost'

Postby Jarry » 2017-08-20 05:17

dasein wrote:The root problem lies in your failure to do a simple search before posting a forum question:
The verbatim title you chose for your thread returns over 100K answers to the question: https://www.google.com/search?q=phpmyad ... 8&oe=utf-8

And please accompany any claim that you did too search ("for hours" :roll:) with a complete list of the exact things you have already tried and the exact results and verbatim output of each attempt.

Believe or not, but I did search google (did not take me hours) and got the same list of answers you were so kind to post. If you really want to know what I did, so I tried the first solution and got stuck immediatelly with "Step 3: Open and edit your config.inc.php file located in your local server files".

First, I checked that file /etc/phpmyadmin/config.inc.php and found it does not contain the line with $cfg['Servers'][$i]['password']. Second, that file is "-rw-r--r--"! Call me paranoid, but I find it quite dangerous to put somewhere plain text root password that can be read by everyone (!!!). I could not believe *that* is the right solution, so in that moment I decided to ask here.

I expected to get a few "smart ass" answers like yours and you did not dissapoint me. Yet I sincerely hope you do not represent behaviour of typical debian-comunity user. I really do...
Jarry
 
Posts: 4
Joined: 2017-08-19 17:55

Re: phpmyadmin: Access denied for user 'root'@'localhost'

Postby kedaha » 2017-08-20 06:32

Jarry wrote:[...]Call me paranoid, but I find it quite dangerous to put somewhere plain text root password that can be read by everyone (!!!). I could not believe *that* is the right solution, so in that moment I decided to ask here.

When I login to phpmyadmin—which is not often—the login is root with the mysql password.
No, it's not paranoid to be concerned about security; my advice, now that letsencrypt is available, is to use https.
Mate DE & OSSv4.
LaMp, WordPress; ispmail
Debian Stable

Words, as is well known, are the great foes of reality. Joseph Conrad.
Kedaha's Conjecture
User avatar
kedaha
 
Posts: 2817
Joined: 2008-05-24 12:26

Re: phpmyadmin: Access denied for user 'root'@'localhost'

Postby GarryRicketson » 2017-08-20 09:36

Still not clear, if it is
Post by GarryRicketson » 2017-08-19 19:44
It would help to know what version of MySQL, is it MySQL 5.7 ?

=======================

from: https://askubuntu.com/questions/763336/cannot-enter-phpmyadmin-as-root-mysql-5-7The fix was by reconfiguring phpmyadmin, and by answering some interactive questions.

Code: Select all
sudo dpkg-reconfigure phpmyadmin
<Ok>
Reinstall database for phpmyadmin: <Yes>
Connection method for MySQL database server for phpmyadmin: TCP/IP
Host name of the MySQL database server for phpmyadmin: localhost
Port number for the MySQL service: 3306
MySQL database name for phpmyadmin: phpmyadmin
<Ok>
MySQL username for phpmyadmin: root
MySQL application password for phpmyadmin: pass  # OR ANY PASSWORD YOU WANT
Password confirmation: pass
Name of the database's administrative user: root
Web server to reconfigure automatically: apache2
An error occurred while installing the database: ignore

==========
The above is basically what I had to do, however I am not using 5.7 , it is 5.5,
also, I do not use "sudo", ever,...
I also removed and re-intsalled "phpmyadmin" , to try again... however the
dpkg-reconfigure command, accomplishes the same.
Code: Select all
dpkg-reconfigure phpmyadmin

Hint, After you reconfigure phpmyadmin, it is a good idea to restart Mysql,
I don't see that mentioned in the one tutorial, in others they do .
Another thing , that causes confusion, the browser you use may be keeping
the old password, etc. in a cache, this can result in it not working, even after you
have made some changes and re-configured.
I am not familiar enough with Debian 9 and some of the "new features", but in any event
I had the same troubles even with Debian 6 and 7, ...
Jarry wrote:Call me paranoid, but I find it quite dangerous to put somewhere plain text root password that can be read by everyone (!!!). I could not believe *that* is the right solution, so in that moment I decided to ask here.

I agree, I found it questionable, and that leads to another reason I decided I don't really
need phpmyadmin on my server. (probably should be another topic)
by kedaha »
When I login to phpmyadmin—which is not often—the login is root with the mysql password.
No, it's not paranoid to be concerned about security; my advice, now that letsencrypt is available, is to use https.

Is a good solution as well.
I strongly recommend looking at the information they (phpmydamin) have on their website:
https://docs.phpmyadmin.net/en/latest/security.html
The phpMyAdmin developer team is putting lot of effort to make phpMyAdmin as secure as possible. But still web application like phpMyAdmin can be vulnerable to a number of attacks and new ways to exploit are still being explored.

=====================
https://www.phpmyadmin.net/support/
=============================
All though phpmyadmin is a package availble in Debian repositories, the problems
and security risks associated with it, are not specific to just Debian,..
https://docs.phpmyadmin.net/en/latest/config.html
All configurable data is placed in config.inc.php in phpMyAdmin’s toplevel directory. If this file does not exist, please refer to the Installationsection to create one. This file only needs to contain the parameters you want to change from their corresponding default value in libraries/config.default.php (this file is not intended for changes).


There is no problem asking here, and since you are using Debian 9, ... how ever
you will find more details,and accurate info, on the Myphpadmin website.

==== Off topic a little ========
by Jarry »Believe or not, but I did search google (did not take me hours) and got the same list of answers you were so kind to post.

I believe you, and I spent literally days, going over the lists of answers, some are not very clear, others just don't work, ... after all said and done, it was little bit's and pieces from
various ones , and mostly just the old, "if at first you don't succeed, try,try,and try again",..
================ on security =========
Yes, indeed, they do try to access all of the php files, looking for a way to access:
Here this one was trying to get the "setup.php". Since there is no "phpmyadmin"
on the system, they got a "404", the file does not exist, but any way, this is the kind of thing you need to be able to deal with if you have a production server, there are 100s of
"bad" bots, constantly trying to access...............
Code: Select all
default 104.197.3.228 - - [22/Jul/2017:20:07:54 -0500] "GET /w00tw00t.at.blackhats.romanian.anti-sec:) HTTP/1.1" 404 0
default 104.197.3.228 - - [22/Jul/2017:20:07:55 -0500] "GET /phpmyadmin/scripts/setup.php HTTP/1.1" 404 0
default 104.197.3.228 - - [22/Jul/2017:20:07:55 -0500] "GET /phpMyAdmin/scripts/setup.php HTTP/1.1" 404 0
default 104.197.3.228 - - [22/Jul/2017:20:07:55 -0500] "GET /mysqlmanager/scripts/setup.php HTTP/1.1" 404 0
default 104.197.3.228 - - [22/Jul/2017:20:07:55 -0500] "GET /p/m/a/scripts/setup.php HTTP/1.1" 404 0
default 104.197.3.228 - - [22/Jul/2017:20:07:55 -0500] "GET /phpmanager/scripts/setup.php HTTP/1.1" 404 0
default 104.197.3.228 - - [22/Jul/2017:20:07:55 -0500] "GET /mysql-admin/scripts/setup.php HTTP/1.1" 404 0
default 104.197.3.228 - - [22/Jul/2017:20:07:55 -0500] "GET /mysqladmin/scripts/setup.php HTTP/1.1" 404 0
default 104.197.3.228 - - [22/Jul/2017:20:07:56 -0500] "GET /webdb/scripts/setup.php HTTP/1.1" 404 0
default 104.197.3.228 - - [22/Jul/2017:20:07:56 -0500] "GET /webadmin/scripts/setup.php HTTP/1.1" 404 0
default 104.197.3.228 - - [22/Jul/2017:20:07:56 -0500] "GET /phpmy-admin/scripts/setup.php HTTP/1.1" 404 0
default 104.197.3.228 - - [22/Jul/2017:20:07:56 -0500] "GET /php-myadmin/scripts/setup.php HTTP/1.1" 404 0
default 104.197.3.228 - - [22/Jul/2017:20:07:56 -0500] "GET /my/scripts/setup.php HTTP/1.1" 404 0
default 104.197.3.228 - - [22/Jul/2017:20:07:56 -0500] "GET /MyAdmin/scripts/setup.php HTTP/1.1" 404 0
default 104.197.3.228 - - [22/Jul/2017:20:07:56 -0500] "GET /phpMyAdmin-2.10.0/scripts/setup.php HTTP/1.1" 404 0
default 104.197.3.228 - - [22/Jul/2017:20:07:57 -0500] "GET /myAdmin/scripts/setup.php HTTP/1.1" 404 0
default 104.197.3.228 - - [22/Jul/2017:20:07:57 -0500] "GET /mysql/scripts/setup.php HTTP/1.1" 404 0
default 104.197.3.228 - - [22/Jul/2017:20:07:57 -0500] "GET /dbadmin/scripts/setup.php HTTP/1.1" 404 0
default 104.197.3.228 - - [22/Jul/2017:20:07:57 -0500] "GET /sqladm/scripts/setup.php HTTP/1.1" 404 0
default 104.197.3.228 - - [22/Jul/2017:20:07:57 -0500] "GET /scripts/setup.php HTTP/1.1" 404 0
default 104.197.3.228 - - [22/Jul/2017:20:07:57 -0500] "GET /PMA/scripts/setup.php HTTP/1.1" 404 0
default 104.197.3.228 - - [22/Jul/2017:20:07:57 -0500] "GET /db/scripts/setup.php HTTP/1.1" 404 0
default 104.197.3.228 - - [22/Jul/2017:20:07:58 -0500] "GET /myadmin/scripts/setup.php HTTP/1.1" 404 0
User avatar
GarryRicketson
 
Posts: 4588
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: phpmyadmin: Access denied for user 'root'@'localhost'

Postby GarryRicketson » 2017-08-20 09:49

I think I mentioned this before, but it is another thing that can cause this problem:
https://docs.phpmyadmin.net/en/latest/faq.html?highlight=Access%20denied%20for%20user%20%27root%27%40%27localhost%27
2.6 I get an “Access denied for user: 'root@localhost‘ (Using password: YES)”-error when trying to access a MySQL-Server on a host which is port-forwarded for my localhost.

When you are using a port on your localhost, which you redirect via port-forwarding to another host, MySQL is not resolving the localhost as expected. Erik Wasser explains: The solution is: if your host is “localhost” MySQL (the command line tool mysql as well) always tries to use the socket connection for speeding up things. And that doesn’t work in this configuration with port forwarding. If you enter “127.0.0.1” as hostname, everything is right and MySQL uses the TCP connection.

Do you have "127.0.0.1" as the host name.
Code: Select all
man hosts

Code: Select all
man hostname

SEE ALSO
domainname(1), gethostname(3), myname(5), hostname(7), netstart(8)

User avatar
GarryRicketson
 
Posts: 4588
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: phpmyadmin: Access denied for user 'root'@'localhost'

Postby Thorny » 2017-08-20 12:16

pendrachken wrote:Since I am personally sick of hearing this in every thread from you:

You know how you tell Gary to STFU about all the stuff he doesn't understand all the time? Take your own advice and ignore all of these people that you tell to search better. As it is we might as well make an edit to the PHPBB code to just make a post comprised of " you suck at searching, goaway --signed dasein" to be immediately posted at each new thread generation.

That or try posting actual answers, I think I saw one maybe two actual answers in the last year from you. The rest was immediately jumping to conclusions, calling people trolls, and bitching incessantly about how people can't do searches.

[OT]
Since you say you are sick of "hearing" (SIC) that, the simple solution that occurs to me is to take a bit of your own advice and put dasein on your ignore list. Nobody forces you to read any post.

Personally, I don't like people posting off topic in a help request about a personal issue when the forum has the mechanism for PMs.

I note your post doesn't have doesn't have any "actual answers" to the help request either. I don't find fault with constantly reminding of the expectation that users should search first and/or use Debian documentation as explained by the forum stickies from a forum admin. It seems clear to me that original poster wasn't harmed by dasein's post and has a thick enough skin to survive. I expect that otherwise Moderators would step in. Remember that these forums don't exist only to help the original poster and I hope that lurkers can recognise the goal of at least some of us here, that is is best to learn to help themselves and to detail what they have tried or don't understand so that it is easier to try and help them.
[/OT]

I apologise for adding my off topic post.
Thorny
Thorny
 
Posts: 366
Joined: 2011-02-27 13:40

Re: phpmyadmin: Access denied for user 'root'@'localhost'

Postby n0rthlight » 2017-08-21 16:09

dasein wrote:
Jarry wrote:So where is the problem?

The root problem lies in your failure to do a simple search before posting a forum question:

The verbatim title you chose for your thread returns over 100K answers to the question: https://www.google.com/search?q=phpmyad ... 8&oe=utf-8

And please accompany any claim that you did too search ("for hours" :roll:) with a complete list of the exact things you have already tried and the exact results and verbatim output of each attempt.

If you are unable to do so for some mysterious reason, then go back and retry each and every one of them to produce that list. After all, there's no point in anyone here suggesting something you already tried, right?

(To be clear: "I tried them all and nothing worked" is neither specific nor even remotely believable. You did not try so much as 1% of the 100K available answers.)


I was coming to this post to see if I could help and instead for the first time experience something I have read multiples times about Debian community.

I am a new comer I love Debian and want to learn and help but when I see this type of post from a user with over 7000k post on this forum it made me question my decision. I do understand that seen redundant questions can be irritating but it is no reason.

There is no way this is helping the community at any level, the vibe behind is extremely controlling, negative and territorial and I hope admin of the forum will take notice.
n0rthlight
 
Posts: 11
Joined: 2017-08-21 15:41

Re: phpmyadmin: Access denied for user 'root'@'localhost'

Postby dasein » 2017-08-21 16:16

Ooooo. Chastised by a sock puppet. I'm crushed.

(Do I win a prize if I guess who's behind the sock puppet account? Because I'm pretty sure I can. :mrgreen:)
User avatar
dasein
 
Posts: 7775
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: phpmyadmin: Access denied for user 'root'@'localhost'

Postby n0rthlight » 2017-08-21 16:47

dasein wrote:Ooooo. Chastised by a sock puppet. I'm crushed.

(Do I win a prize if I guess who's behind the sock puppet account? Because I'm pretty sure I can. :mrgreen:)


I will not dive further into this thread, it's already hijacked enough however this is not puppet account. I never posted here since I ask most of my question on the Debian help channel. Like I mentioned your post was the second one I have ever read here and I believe you should reconsider it if it's your desire is to help Debian and the community who support it.

If you still believed this is a puppet account please come and speak with me on the Debian IRC channel. Most regular know me there for my incessant questioning.

Maybe you should take a break from helping on forum? Try IRC for a change? :)
n0rthlight
 
Posts: 11
Joined: 2017-08-21 15:41

Re: phpmyadmin: Access denied for user 'root'@'localhost'

Postby Jarry » 2017-08-21 18:01

GarryRicketson wrote:More then likely it is this:
From :https://askubuntu.com/questions/763336/cannot-enter-phpmyadmin-as-root-mysql-5-7
MySQL 5.7 changed the secure model: now MySQL root login requires a sudo (while the password still can be blank). I.e., phpMyAdmin will be not able to use root as user. The simplest (and safest) solution will be create a new user and grant required privileges.


Yep, that solved the problem! First I checked /etc/dbconfig-common/phpmyadmin.conf, and there was already some user (probably created during installation):
dbc_dbuser='phpmyadmin'
dbc_dbpass='**************'

I do not know what this user is good for (?) so I created another one:

CREATE USER 'adminmyphp'@'localhost' IDENTIFIED BY '**********';
GRANT ALL PRIVILEGES ON *.* TO 'adminmyphp'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;

Now I can log in to phpmyadmin with user "adminmyphp" and password. Thanks!
Jarry
 
Posts: 4
Joined: 2017-08-19 17:55

Re: phpmyadmin: Access denied for user 'root'@'localhost'

Postby dasein » 2017-08-21 18:29

Jarry wrote:
GarryRicketson wrote:More then likely it is this:
From :https://askubuntu.com/questions/763336/cannot-enter-phpmyadmin-as-root-mysql-5-7

Yep, that solved the problem!

"That" = the #5 hit at Google using the exact search that I pointed you to two days ago, but you were too farqing lazy even to click.

So much for "you searched, honest."

Lazy, lyin', Oedipus-wannabe
User avatar
dasein
 
Posts: 7775
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: phpmyadmin: Access denied for user 'root'@'localhost'

Postby kedaha » 2017-08-21 18:55

The times I've found myself unable to connect to web interfaces like phpmyadmin are more than I care to remember. Countless times. I think that the more such issues are documented either on the Debian wiki or here, the better; it's a pity places like askubuntu need to be consulted at all.
Mate DE & OSSv4.
LaMp, WordPress; ispmail
Debian Stable

Words, as is well known, are the great foes of reality. Joseph Conrad.
Kedaha's Conjecture
User avatar
kedaha
 
Posts: 2817
Joined: 2008-05-24 12:26

Next

Return to Beginners Questions

Who is online

Users browsing this forum: No registered users and 5 guests

fashionable