Re: Ubuntu MySQL install with Virtualmin - password problems with 16.04.4 server

From: Thomas 'PointedEars' Lahn <PointedEars_at_web.de>
Date: Tue, 03 Apr 2018 05:32:03 +0200
Message-ID: <2351213.7s5MMGUR32_at_PointedEars.de>


J.O. Aho wrote:

> On 03/29/18 20:09, Abandoned Trolley wrote:
>> I am able to get in to mysql by simply using "mysql --user=root" as
>> superuser on the machine console - so there is not problem getting
>> access to the database.
> 
> As you see he connects to the database without password.

That is merely *your* *assumption*. In fact, the OP is sufficiently vague as to what they have done and what the current status of the MySQL and Virtualmin configuration is. Not even a console transcript has been posted. So all we can do here is *guessing* based on *incomplete* information.

In any case, I have _not_ denied the possibility that you mention. I have only said, and showed, that it does _not_ work *for me* on a GNU+Linux system with a *default* MySQL configuration. That puts into doubt Axel Schwenke’s assertion that it would work *by default* in MySQL (due to auth_socket plugin being enabled by default).

So much for reading properly.

>> | I don't understand how it is that I can assign a root password as part
>> | of the Virtualmin install, which Virtualmin then uses to administer
>> | the database - but I cannot use that same password to log in, even at
>> | the console.
> 
> He is wondering why he did provide a password during Virtualmin
> installation for the database user root.

That much appears to be *obvious* (also from the documentation): Virtualmin has to CREATE its DATABASE first. Usually only the MySQL “root” user can do that, so it is *normal* for MySQL/MariaDB-based Web applications to ask for that password. (Again, you appear to be lacking a minimum clue.)

The possibility *remains* that something went wrong in the Virtualmin installation. From the installation script (which I have downloaded and looked into), it is clear that Virtualmin attempts to install MySQL (actually, the entire LAMP or LEMP stack) from distribution packages, but, like a properly developed Web application would, as the documentation indicates, it would not use the MySQL “root” user for everyday database operations – only to *create* the database. (So the OP’s argument is not conclusive.)

It is possible that the MySQL “root” user password is stored in the Virtualmin configuration without having been set accordingly in the MySQL “user” database. This would be a bug in the Virtualmin installation script as it should do just that, and indicate an error if for some reason it is not possible.

But if it is in fact possible to log into MySQL without password (on that system) using

  mysql --user=root

as system user “root”, as Axel Schwenke asserted, then the only interpretation of the OP’s statements that makes sense is that this works, but

  mysql --user=root --password

or

  mysql --user=root --password=$PASSWORD

for some reason does not (unfortunately, for the reason mentioned above, I cannot test this here).

Then the only possibilities that I can think of are that either they have typed the wrong password on the console, or they have typed the same password as in the Virtualmin setup, but it has not been set accordingly in the MySQL user database in the first place.

One possibility is that the MySQL “root” user password has been set, but for a *different host*:

| # mysql -u root -p mysql <<<'SELECT `user`, `host` FROM `user` WHERE
| `user` = "root";'
| Enter password:
| user host
| root 127.0.0.1
| root ::1
| root localhost
| […]

My experiments show that if you use “mysql -u root -p”, the password for 'root'_at_'localhost' is expected (additionally selecting the “password” column in the above query will show whether the “root” passwords for different hosts differ, and which have not been set).

And, in fact, it does not follow that a Virtualmin-installed MySQL server must also be accessible from the console. The most inexpensive of Web hostings do not even provide console access. That is, the admin of the Web hoster would install Virtualmin (in the virtual host paid by the customer), but the customer would only have, and need, access to the database via the Web, if at all.

For the case that logging into MySQL with “mysql -u root -p” is the problem (because “-u root” alone appears not to be here; see above/below), I have referred to the “Troubleshooting” section of the Virtualmin documentation (that the OP should have read in the first place) which explains how to properly set the password of the MySQL “root” user. Regardless what was the initial reason for it, this should make the OP’s problem disappear.

[Quoted] However, I find it equally likely that we are all just feeding a troll. Consider the (non-)"name" of the OP, and then:

,-<news:p9ic69$4e3$1_at_dont-email.me>
|
| I am using the latest Virtualmin install script, and a fresh clean
| install of the latest 16.04.4 server distro but I still keep getting
| locked out.

,-<news:p9ja58$dqm$1_at_dont-email.me>
|
| I am able to get in to mysql by simply using "mysql --user=root" as
| superuser on the machine console - so there is not problem getting

                           ^^^^^^^

| access to the database.
|
| I don't understand how it is that I can assign a root password as part
| of the Virtualmin install, which Virtualmin then uses to administer the
| database - but I cannot use that same password to log in, even at the
| console.
  ^^^^^^^

On their face, those statements are *mutually* *contradictory*. Either it is possible to log in into MySQL on the console, or it is not. /Tertium non datur./
-- 
PointedEars
Zend Certified PHP Engineer <http://www.zend.com/en/yellow-pages/ZEND024953>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn>
Twitter: _at_PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.
Received on Tue Apr 03 2018 - 05:32:03 CEST

Original text of this message