[MDEV-9545] MariaDB-Server 10.0.23-2 no root Password setting during installation (thus no connection possible) Created: 2016-02-10  Updated: 2016-02-15  Resolved: 2016-02-15

Status: Closed
Project: MariaDB Server
Component/s: Platform Debian
Affects Version/s: 10.0.23
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Infi Nity Assignee: Unassigned
Resolution: Not a Bug Votes: 0
Labels: armhf
Environment:

Debian Jessie (ARMBian), armhf (Banana Pi - comparable to Raspberry Pi 2 platform). Installing from "testing" Repository (also unstable repository with same issue)



 Description   

Hello,

there is no root-password prompt during installation of mariadb-server 10.0.23-2 out of unstable and testing repos of debian for arm systems.

Even if I set a password manually with:

mysqladmin -u root password MYPASSWORD

it will still not work.

Also configuring the coresponding *my.cnf* file does not help:

/root/.my.cnf

[client]
user=root
password=MYPASSWORD

chmod 600 /root/.my.cnf

This is reproducable. If I install an older MariaDB-Server (10.0.23-0+deb8u1) it will direclty ask for a new root password during installation process.

The issue affects in my case the installation of a seafile server. This comes during installation of seafile server in combination with mariadb-server:

What is the password of the mysql root user?
[ root password ]

verifying password of user root ...
Failed to connect to mysql server using user "root" and password "***": Access denied for user 'root'@'localhost'



 Comments   
Comment by Elena Stepanova [ 2016-02-11 ]

Infinity85,

What exactly do you mean by "it will still not work" about mysqladmin, and "does not help" about my.cnf? What happens when you do either of that?

Comment by Infi Nity [ 2016-02-11 ]

I mean with that, that the password will still not be set somehow.

1. Problem: During fresh install of MariaDB 10.0.23-2 (clean system without prior MariaDB/MySQL installations) the usually coming blue screen with prompt for setting a root password won't come up. The installation will just finish without any prompt for setting a password.
During Installation of Seafile there comes then this error message:

What is the password of the mysql root user?
[ root password ]
verifying password of user root ...
Failed to connect to mysql server using user "root" and password "***": Access denied for user 'root'@'localhost'

2. Then I tried to set manually a password via "mysqladmin -u root password MYPASSWORD" and I thought it is set, as no error message comes up. But afterwards during install of Seafile the same error message comes again:

What is the password of the mysql root user?
[ root password ]
verifying password of user root ...
Failed to connect to mysql server using user "root" and password "***": Access denied for user 'root'@'localhost'

3. Then I decided to make this configfile containing the root password:

/root/.my.cnf
[client]
user=root
password=MYPASSWORD
chmod 600 /root/.my.cnf

And again I tried to install Seafile, but again I got the very same error message.

4. Then I installed Mariadb-server 10.0.23-0+deb8u1, which prompted directly during installation in a blue screen to set root password and seafile installed flawlessly afterwards. Something is odd with the recent version of MariaDB-Server 10.0.23-2 :/

Comment by Elena Stepanova [ 2016-02-12 ]

Infinity85,

The problem with the dialog screen is to be looked at; but lets figure out the password creation issue.

I don't know how Seafile works and what its requirements are, but a third-party tool is not a good way to check whether the basic password creation works.

First of all, if root password is not set during installation, it should be empty, so it's very much possible to connect – not safe, but definitely possible. You should be able to connect (using mysql client) without the password option at all, or using -p and pressing enter in the prompt. Could you please try? In fact, you did exactly that when you ran your mysqladmin command – you used it without any password and were able to connect.

Secondly, could you please repeat the exercise after you have set the password via mysqladmin? You should not be able to connect without the password option anymore, but your new password should work.

If you are able to connect, after you do so, please run SELECT CURRENT_USER() to make sure you indeed are connected as root@localhost, and not any other root, e.g. root@'127.0.0.1' or root@<domain name>. It is important because when you enter the password via the dialog (a.k.a. "blue screen"), it sets this password for all these roots simultaneously, while mysqladmin only does it for the root you are connected with.

Finally, I doubt that the client section of the config file will work for Seafile (but then again, I'm not sure how it establishes the connection); but it should work for the regular client.

After we make sure that password actually works, we will ask otto about this unstable build and where the screen could have gone --it's not built by MariaDB, so he knows better how it's different from the stable one.

Comment by Otto Kekäläinen [ 2016-02-12 ]

This is not a bug, more of an documentation/support issue.

MariaDB in the official Debian Jessie release is different fromt he MariaDB in the next Debian release (testing/Stretch) despite the upstream number version being the same (10.0.23).

The new version uses passwordless root via unix socket authentication. So you can simply run as root (or sudo) 'mysql -u root' and you will then have the root prompt. From there you can run whatever 'GRANT USER' statements to create a user with whatever name, password and access rights you need. It is not recommended to run Seafile with the MariaDB root user. Instead create a user called 'seafile' that has only the permissions it needs (e.g. access to seafile database and tables).

http://anonscm.debian.org/cgit/pkg-mysql/mariadb-10.0.git/tree/debian/mariadb-server-10.0.README.Debian

Comment by Infi Nity [ 2016-02-12 ]

Tanks for your explanation Otto

But are you aware, that this breaks compatibility with the older versions and is apparently incompatible with the original MariaDB behaviour?

Now I understand the approach of avoiding the root thing, but seafile (or its installer script) for example relies on having a MySQL user prior to seafile Installation. During installation it asks for the MySQL-root-user password and after typing this root password in (which hat to be set during mariadb installation blue screen), seafile-instaler connects to MySQL and gives you the prompt to create the MySQL-seafile-user. So without root-account you can't create the seafile-user for MySQL. Apparently it is actually not supposed to use the root-user as stated by you, but currently it is mandatory to have a set root-password to be able to create a 'seafile'-user with less permissions. By the way... if I play around today evening with your 'mysql -u root' way and then it will hyperthetically work to create the 'seafile'-user... how do I set the given permissions? I don't know anything about it? Usually the 'seafile'-installer-script did create the user (also demanded permissions I guess)... That means that because of the mentioned change in mariadb armhf testing/unstable, that the seafile installer script (and probably many others relying on MySQL) need to be rewritten?

@Elena Stepanova
Sorry Elena, I did not find time yet to try your suggestions :/. I hope I will find time today evening/this weekend to power reconfigure my testing system for playing around with your steps I hope this is okay for you.

With best regards

Comment by Infi Nity [ 2016-02-13 ]

@Elena Stepanova
Well... I have to mention that I am completely lost with MySQL if I try to follow your steps. I have no basic knowledge about MySQL, so I am stuck at the very beginning of your steps. I just stumbled over this problem because of seafile, which does not install because of the change that Otto described.

One thing I have to mention: MariaDB-server installation is done as root, but seafile installation is started as unpriviledged user seafile:
"su - seafile -s /bin/bash"
Then I start the installation Script setup-seafile-mysql.sh which seems to be some kind of wrapper for a setup-seafile-mysql.py

And in this python script this section might be the problem when executing as unpriviledged user and not having a mysql-root-password already set:

class NewDBConfigurator(AbstractDBConfigurator):
'''Handles the case of creating new mysql databases for ccnet/seafile/seahub'''
def _init_(self):
AbstractDBConfigurator._init_(self)

self.root_password = ''
self.root_conn = ''

def ask_questions(self):
self.ask_mysql_host_port()

self.ask_root_password()
self.ask_seafile_mysql_user_password()

self.ask_db_names()

def generate(self):
if not self.mysql_user_exists(self.seafile_mysql_user):
self.create_user()
self.create_databases()

def ask_root_password(self):
def validate(password):
self.root_conn = self.check_mysql_user('root', password)
return password

question = 'What is the password of the mysql root user?'
key = 'root password'
self.root_password = Utils.ask_question(question,
key=key,
validate=validate,
password=True)

def mysql_user_exists(self, user):
cursor = self.root_conn.cursor()

sql = '''SELECT EXISTS(SELECT 1 FROM mysql.user WHERE user = '%s')''' % user

try:
cursor.execute(sql)
return cursor.fetchall()[0][0]
except Exception, e:
if isinstance(e, MySQLdb.OperationalError):
Utils.error('Failed to check mysql user %s: %s' % (user, e.args[1]))
else:
Utils.error('Failed to check mysql user %s: %s' % (user, e))
finally:
cursor.close()

def ask_seafile_mysql_user_password(self):
def validate(user):
if user == 'root':
self.seafile_mysql_password = self.root_password
else:
question = 'Enter the password for mysql user "%s":' % Utils.highlight(user)
key = 'password for %s' % user
password = Utils.ask_question(question, key=key, password=True)

  1. If the user already exists, check the password here
    if self.mysql_user_exists(user):
    self.check_mysql_user(user, password)
    self.seafile_mysql_password = password

return user

question = 'Enter the name for mysql user of seafile. It would be created if not exists.'
key = 'mysql user for seafile'
default = 'root'
self.seafile_mysql_user = Utils.ask_question(question,
key=key,
default=default,
validate=validate)

Coming to your steps:

First of all, if root password is not set during installation, it should be empty, so it's very much possible to connect – not safe, but definitely possible. You should be able to connect (using mysql client) without the password option at all, or using -p and pressing enter in the prompt. Could you please try?

I don't know how to connect, and especially as a "client" and I don't know where to use the argument -p. It's the first time I use MySQL and actually I am not even using it... seafile uses it . For my working system I just use the older MariaDB build, which has the blue root-password prompt. This here is just some kind of bug report, as I noticed that this problem (turned out as feature) went from unstable without any fix to testing repository.

In fact, you did exactly that when you ran your mysqladmin command – you used it without any password and were able to connect.

Sounds plausible, I just copied the commands and saw (without any plan about this) that the seafile installation (started as unpriviledged user) stopped with the initially stated error message of failed connection with root.

Secondly, could you please repeat the exercise after you have set the password via mysqladmin? You should not be able to connect without the password option anymore, but your new password should work.
If you are able to connect, after you do so, please run SELECT CURRENT_USER() to make sure you indeed are connected as root@localhost, and not any other root, e.g. root@'127.0.0.1' or root@<domain name>.

Unfortunately I don't know how to connect and also how to make sure whether I'm connected as root@localhost.

It is important because when you enter the password via the dialog (a.k.a. "blue screen"), it sets this password for all these roots simultaneously, while mysqladmin only does it for the root you are connected with.

This might be the whole problem! Without setting for all roots in combination with later starting the seafile setup as unpriviledged user.

Finally, I doubt that the client section of the config file will work for Seafile (but then again, I'm not sure how it establishes the connection); but it should work for the regular client.

Unfortunately I don't understand the structure of mariadb, so I also don't know what the client section might be and what the "regular client is"

Sorry for not being helpful with this :/ I just wanted to report some Kind of bug, which affects the installation of seafile. Now it turns out that this is a change, which might lead the seafile-developers and many others I guess to change their Installation scripts. In my case I will just use the stable build of mariadb, but I hope that an apt-get update / apt-get upgrade won't brick my server / mysql databases because of this change!

Comment by Elena Stepanova [ 2016-02-15 ]

Infinity85,

Thanks, I've installed and tried 10.0.23-2, and also took a quick look at Seafile installation process, so now I see what's happening.
Indeed, Seafile is not supposed to run with the root user, but that's exactly what setup-seafile-mysql.sh does – it creates a new account which is expected to be used later. To create it, the script naturally needs to connect to the server, and it relies on having a superuser identified by password, which does not exist in a new installation of 10.0.23-2.

As otto explained above, it's the new way Debian chose to deal with local root accounts, it does not depend on us, so I'm closing the issue. If you have objections regarding this decision, you need to go through Debian channels instead.

Meanwhile, to get your Seafile work, you can use one of two ways.

First, instead of using setup-seafile-mysql.sh, you can do configuration manually, as described in the Seafile manual (search for "However, sometimes you have to use the second way"). For that, you need to connect to MariaDB server:

sudo mysql -uroot

run the SQL commands described in the manual, then run quit to exit the MariaDB prompt, and follow further instructions for Seafile installation.

Secondly, you can make MariaDB server behave the usual way. As follows from Otto's comment, it is not recommended and probably isn't tested well enough with debian maintenance scripts, but at the end you are the master of your MariaDB installation. If you want to do so, you need, again, connect to the server

sudo mysql -uroot

then run

update mysql.user set plugin = '' where user='root' and host='localhost';
set password = password('xxxxxxx');
flush privileges;
quit

Then you can run setup-seafile-mysql.sh as usual, with the MariaDB user root and password that you've just set.

Comment by Otto Kekäläinen [ 2016-02-15 ]

Infinity85 I suggest you file a bug on Seafile that they have database username hardcoded in their installation script. You should be able to create a new user and database 'seafile' that Seafile uses instead of simply root. Commands how to create you custom user: https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql

You can run simply 'sudo mysql' to access the console.

Generated at Thu Feb 08 07:35:28 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.