mariadb直接可以mysql登录_解决Mariadb10.1.37不需要密码就可以登录

在Ubuntu下apt装了Mariadb后,改掉root密码后,发现不需要密码就可以进入控制台。

刚开始以为密码修改失败了。后来发现是Mariadb认证插件的原因。

mysql库user表中默认有一条root用户记录,这条记录plugin字段(用户认证)默认值是 unix_socket(在centos7 yum安装的为mariadb-server-5.5.60版本,默认这个字段是空的),如果是这种认证方式,则通过系统凭据认证,就跳过数据库的密码认证了。

所以出现不需要密码就可以登录。

# 改回数据库密码认证

root@simon-PC:/etc/mysql# mysql

Welcome to the MariaDB monitor. Commands end with ; or \g.

Your MariaDB connection id is 5

Server version: 10.1.37-MariaDB-0+deb9u1 Debian 9.6

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> select user,plugin from mysql.user;

+------+-------------+

| user | plugin |

+------+-------------+

| root | unix_socket |

+------+-------------+

1 rows in set (0.00 sec)

MariaDB [(none)]> use mysql;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

MariaDB [mysql]> update user set plugin = 'mysql_native_password' where user = 'root';

Query OK, 1 rows affected (0.00 sec)

Rows matched: 1 Changed: 1 Warnings: 0

MariaDB [mysql]> select user,plugin from mysql.user;

+------+-----------------------+

| user | plugin |

+------+-----------------------+

| root | mysql_native_password |

+------+-----------------------+

1 rows in set (0.00 sec)

MariaDB [mysql]> exit

Bye

# 重启MariaDB数据库

root@simon-PC:/etc/mysql# systemctl restart mysql

root@simon-PC:/etc/mysql# mysql

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

上面提示没有带密码,拒绝登录了。

root@simon-PC:/etc/mysql# mysql -uroot -proot

Welcome to the MariaDB monitor. Commands end with ; or \g.

Your MariaDB connection id is 3

Server version: 10.1.37-MariaDB-0+deb9u1 Debian 9.6

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

完成。

专注于 服务器运维与web架构

E-mail:venus#rootop.org

MariaDB 10.1.48是一个流行的关系型数据库管理系统,适用于Linux操作系统。下面是下载和安装MariaDB 10.1.48的步骤: 1. 打开任意互联网浏览器,进入MariaDB的官方网站。 2. 在官方网站上找到"下载"或"Get MariaDB"选项,并点击。 3. 在下载页面上,选择适用于Linux操作系统的版本。可能有各种不同的发行版、架构和包类型可供选择,根据您的操作系统的需求进行选择。 4. 单击所选版本的下载链接,将MariaDB 10.1.48软件包下载到您的计算机中。 5. 下载完成后,打开Linux终端窗口。 6. 在终端中,使用命令"cd"进入您保存MariaDB 10.1.48软件包的目录。 7. 解压软件包。在终端中运行以下命令:tar -xf mariadb-10.1.48-linux.tar.gz 8. 创建一个新的MariaDB安装目录。在终端中运行以下命令:sudo mkdir /usr/local/mariadb 9. 将解压后的文件复制到新创建的目录中。在终端中运行以下命令:sudo cp -R mariadb-10.1.48-linux/* /usr/local/mariadb/ 10. 运行以下命令来配置MariaDB:sudo /usr/local/mariadb/bin/mysql_install_db --user=mysql 11. 启动MariaDB服务器。在终端中运行以下命令:sudo /usr/local/mariadb/bin/mysqld_safe --user=mysql & 12. 现在,您已成功下载并安装了MariaDB 10.1.48。您可以使用MySQL客户端工具(如MySQL Workbench或phpMyAdmin)连接到MariaDB服务器,并开始使用它。 请注意,以上是基本的下载和安装过程。具体步骤可能因您的Linux发行版或个人设置而有所不同。强烈建议您在开始安装之前查阅适用于您的操作系统的官方文档或用户指南,以获取更详细和准确的说明。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值