MySQL fedora 上 mariadb 的默认密码是多少?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20270879/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What's the default password of mariadb on fedora?
提问by Tony
I installed mysql through yum just now and the OS fedora installed mariadb for me. I know mariadb is a new branch of mysql, but I can't understand why it does not ask me for setting the password. I have tried for 123456 and so on, but I failed. My fedora is new, and this is the first time to install mysql/mariadb. What should I do for it?
我刚刚通过yum安装了mysql,操作系统fedora为我安装了mariadb。我知道 mariadb 是 mysql 的一个新分支,但我不明白为什么它不要求我设置密码。我试过 123456 等等,但我失败了。我的fedora是新的,这是第一次安装mysql/mariadb。我该怎么做?
采纳答案by Floris
From https://mariadb.com/kb/en/mysql_secure_installation/:
从https://mariadb.com/kb/en/mysql_secure_installation/:
In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here.
为了登录 MariaDB 以保护它,我们需要 root 用户的当前密码。如果您刚刚安装了 MariaDB,并且尚未设置 root 密码,则密码将为空白,因此您只需在此处按 Enter。
the password will be blank
密码将为空
I think that's your answer.
我想这就是你的答案。
回答by Alex Angelico
I had the same problem. It's true the password is empty, but even so the error message is shown. The solution is just using "sudo" so
我有同样的问题。确实密码为空,但即使如此,也会显示错误消息。解决方案只是使用“sudo”所以
$ sudo mysql
will open the mysql tool
将打开mysql工具
For securing the database, you should use sudo again.
为了保护数据库,您应该再次使用 sudo。
$ sudo mysql_secure_installation
回答by redochka
mariadb uses by defaults UNIX_SOCKET plugin to authenticate user root. https://mariadb.com/kb/en/mariadb/unix_socket-authentication-plugin/
mariadb 默认使用 UNIX_SOCKET 插件来验证用户 root。https://mariadb.com/kb/en/mariadb/unix_socket-authentication-plugin/
"Because he has identified himself to the operating system, he does not need to do it again for the database"
“因为他已经向操作系统表明了自己的身份,所以他不需要为数据库再做一次”
so you need to login as the root user on unix to login as root in mysql/mariadb:
所以你需要在 unix 上以 root 用户身份登录才能在 mysql/mariadb 中以 root 身份登录:
sudo mysql
if you want to login with root from your normal unix user, you can disable the authentication plugin for root.
如果你想用普通的 unix 用户用 root 登录,你可以禁用 root 的身份验证插件。
Beforehand you can set the root password with mysql_secure_installation (default password is blank), then to let every user authenticate as root login with:
事先您可以使用 mysql_secure_installation 设置 root 密码(默认密码为空),然后让每个用户以 root 登录身份进行身份验证:
shell$ sudo mysql -u root
[mysql] use mysql;
[mysql] update user set plugin='' where User='root';
[mysql] flush privileges;
[mysql] \q
回答by Stéphan Champagne
The default password is empty. More accurately, you don't even NEED a password to login as root on the localhost. You just need to BE root. But if you need to set the password the first time (if you allow remote access to root), you need to use:
默认密码为空。更准确地说,您甚至不需要密码就可以在本地主机上以 root 身份登录。你只需要成为 root。但是如果你第一次需要设置密码(如果你允许远程访问root),则需要使用:
sudo mysql_secure_installation
Enter empty password, then follow the instructions.
输入空密码,然后按照说明操作。
The problem you are having is that you need to BE root when you try to login as root from the local machine.
您遇到的问题是,当您尝试从本地机器以 root 身份登录时,您需要成为 root 用户。
On Linux: mariadb will accept a connection as root on the socket (localhost) ONLY IF THE USER ASKING IT IS ROOT. Which means that even if you try
在 Linux 上:mariadb 仅在询问它的用户是 ROOT 时才以 root 身份在套接字 (localhost) 上接受连接。这意味着即使你尝试
mysql -u root -p
And have the correct password you will be refused access. Same goes for
并且拥有正确的密码您将被拒绝访问。同样适用
mysql_secure_installation
Mariadb will always refuse the password because the current user is not root. So you need to call them with sudo (or as the root user on your machine) So locally you just want to use:
Mariadb 将始终拒绝密码,因为当前用户不是 root。所以你需要用 sudo (或作为你机器上的 root 用户)调用它们所以你只想在本地使用:
sudo mysql
and
和
sudo mysql_secure_installation
When moving from mysql to mariadb it took I will for me to figure this out.
当从 mysql 转移到 mariadb 时,我需要弄清楚这一点。
回答by Michael Greisman
Lucups, Floris is right, but you comment that this didn't solve your problem. I ran into the same symptoms, where mysql (mariadb) will not accept the blank password it should accept, and '/var/lib/mysql' does not exist.
Lucups,Floris 是对的,但您评论说这并没有解决您的问题。我遇到了同样的症状,其中 mysql (mariadb) 不会接受它应该接受的空白密码,并且“/var/lib/mysql”不存在。
I found that this Moonpoint.compage was on-point. Perhaps, like me, you tried to start the mysqld service instead of the mariadb service. Try:
我发现这个Moonpoint.com页面是正确的。也许和我一样,您尝试启动 mysqld 服务而不是 mariadb 服务。尝试:
systemctl start mariadb.service
systemctl status mysqld service
Followed by the usual:
其次是通常的:
mysql_secure_installation
回答by Anum Sheraz
Had the same issue after installing mysql mariadb 10.3. The password was not NULL so simply pressing ENTER didn't worked for me. So finally had to change the password. I followed instruction from here. In nutshell; stop the server
安装 mysql mariadb 10.3 后遇到同样的问题。密码不是 NULL,所以简单地按 ENTER 对我不起作用。所以最后只好改密码了。我按照这里的说明进行操作。简而言之;停止服务器
sudo systemctl stop mariadb.service
gain access to the server through a backdoor by starting the database server and skipping networking and permission tables.
通过启动数据库服务器并跳过网络和权限表,通过后门获得对服务器的访问。
sudo mysqld_safe --skip-grant-tables --skip-networking &
login as root
以 root 身份登录
sudo mysql -u root
then change server password
然后更改服务器密码
use mysql;
update user set password=PASSWORD("new_password_here") where User='root';
Note that after MySQL 5.7, the password field in mysql.user table field was removed, now the field name is 'authentication_string'. So use appropriate table name based on mysql version. finally save changes & restart the server
请注意,在 MySQL 5.7 之后,mysql.user 表字段中的密码字段被删除,现在字段名称为“authentication_string”。因此,请根据 mysql 版本使用适当的表名。最后保存更改并重新启动服务器
flush privileges;
sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service
回答by Dhruvan Ganesh
If your DB is installed properly and typed the wrong password, the error thrown will be:
如果您的数据库安装正确并输入了错误的密码,则抛出的错误将是:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
The following error indicates you DB hasn't been started/installed completely. Your command is not able to locate and talk with your DB instance.
以下错误表明您的数据库尚未完全启动/安装。您的命令无法定位您的数据库实例并与之对话。
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")
Good practice would be to change your password after a fresh install
好的做法是在全新安装后更改密码
$ sudo service mysql stop
$ mysqld_safe --skip-grant-tables &
$ sudo service mysql start
$ sudo mysql -u root
MariaDB [(none)]> use mysql;
MariaDB [mysql]> update user set password=PASSWORD("snafu8") where User='root';
MariaDB [mysql]> flush privileges;
MariaDB [mysql]> exit;
$ sudo service mysql restart
OR
或者
mysqladmin -u root password 'enter password here'
回答by Matija
I believe I found the right answers from here.
我相信我从这里找到了正确的答案。
So in general it says this:
所以一般来说它是这样说的:
user:root
password:password
用户:root
密码:密码
That is for version 10.0.15-MariaDB, installed through Wnmpver. 2.1.5.0 on Windows 7 x86
这适用于通过Wnmp版本安装的 10.0.15-MariaDB 版本。Windows 7 x86 上的 2.1.5.0
回答by neildt
By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment.
默认情况下,MariaDB 安装有一个匿名用户,允许任何人登录 MariaDB,而无需为其创建用户帐户。这仅用于测试,并使安装更顺畅。您应该在进入生产环境之前删除它们。
回答by Adeel Ansari
For me, password = admin
, worked. I installed it using pacman
, Arch(Manjaro KDE).
对我来说password = admin
,工作了。我使用pacman
, Arch( Manjaro KDE)安装了它。
NB:MariaDB was already installed, as a dependency of Amarok.
注意:MariaDB 已经安装,作为Amarok的依赖项。