MySQL根密码不能按预期工作

我在Ubuntu 16.04上运行MariaDB 10.0.24。 我通过xenial repo apt-get install mariadb-server

根密码似乎没有正常工作。 我跑了这些步骤来设置密码: http : //dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html,但我得到以下行为:

当我做sudo mysql或者sudo mysql -u root它会让我进入控制台,而不需要input密码(为什么我可以在没有密码的情况下进入?)

当我做sudo mysql -u root -p ,会询问我input密码,但不pipe我input什么string,都会让我进入mysql控制台。 为什么当给出不正确的密码时让我进入?

当我执行mysql -u root它会要求我input密码,但不会接受我按照链接文章中的说明设置的密码。

有些东西显然是不正确的。 有谁知道为什么它不从根本上要求密码,不接受我的用户的密码?

sudo mysql && sudo mysql -u root这是多余的命令。 不要求密码,因为您有一个名为/root/.my.cnf的文件,其中包含客户端名称和密码

sudo mysql -u root -p请求passowrd因为你把-p放在你的命令中(参见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. 

请阅读密码安全的En-user准则

特别是对于用户的问题

由于Ubuntu 16.04使用Xenial,这在控制某些事物方面有一点奇特,并且使用一个影响我们使用许多系统pipe理员的插件。

mysql>使用mysql; mysql> update user set plugin =''其中User ='root'; mysql>刷新权限;