1

I am running MariaDB 10.0.24 on Ubuntu 16.04. I installed it via the xenial repo apt-get install mariadb-server.

The root password doesn't seem to be working properly. I ran through these steps to set the password: http://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html but I get the following behaviour:

When I do sudo mysql or sudo mysql -u root it gets me into console without asking for password (why can I get in without password?)

When I do sudo mysql -u root -p it asks me for a password but will let me into mysql console regardless of what string I enter. Why does it let me in when giving an incorrect password?

When I do mysql -u root it asks me for password but will not accept the password I set following the instructions in the linked article.

Something is obviously not right. Does anyone know why its not asking for password from root at all and not accepting password from my user?

Guerrilla
  • 243
  • 7
  • 18

1 Answers1

1

sudo mysql && sudo mysql -u root it's redundant command. Not assks for password because you have a file named /root/.my.cnf with with client name and password

sudo mysql -u root -pask for passowrd because you put -p in your coammand (see man mysql)

·   --password[=password], -p[password]

           The password to use when connecting to the server. If you use the short option form (-p), you cannot have a
           space between the option and the password. If you omit the password value following the --password or -p option
           on the command line, mysql prompts for one.

           Specifying a password on the command line should be considered insecure. See Section 6.1.2.1, “End-User
           Guidelines for Password Security”. You can use an option file to avoid giving the password on the command line.

Please read En-user guidelines for Password Security

Especially for the user question

As Ubuntu 16.04 uses Xenial this is a little peculiar in the way they control certain things, and working with a plug that affects as we used many system administrators.

mysql> use mysql; mysql> update user set plugin='' where User='root'; mysql> flush privileges;

abkrim
  • 417
  • 7
  • 18
  • that was psuedo, i just meant that both of those commands give that result. I think you missed my meaning. Usually it expects a correct password but it just accepts any string – Guerrilla May 02 '16 at 05:48
  • I updated the phrasing of my question to hopefully be less ambiguous. – Guerrilla May 02 '16 at 05:50
  • Please.. search and read /root/.my.cnf and /home//.my.cnf If search, read, and read link on reply you will understand what question. Question it's over this file, named .my.cnf – abkrim May 02 '16 at 05:52
  • I don't have any file there. Root directory just contains bash config. – Guerrilla May 02 '16 at 06:09
  • Sure? please put `ls -lisa /home//` It must be replaced by the user executing sudo – abkrim May 02 '16 at 07:00
  • Yes I am positiive. I searched for my.cnf and there is only one file on server `/var/lib/dpkg/alternatives/my.cnf`. This file contains references to /etc/mysql configuration files. – Guerrilla May 02 '16 at 07:41
  • Name of file it's not `my.cnf` it's `.my.cnf` Note dot before my.cnf. and not on other site... i'ts ONLY on user's home or root home – abkrim May 02 '16 at 09:14
  • it does not exist in any of the home directories or anything similarly named – Guerrilla May 02 '16 at 10:31
  • Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/39170/discussion-between-abkrim-and-guerrilla). – abkrim May 02 '16 at 10:40