树莓派raspberry Pi 3B+系统中安装mysql过程中不提示输入密码,安装完后如何设置密码...

树莓派raspberry Pi 3B+安装mysql未提示输入密码,安装后修改mysql密码默认密码

使用mysql -uroot -p 命令连接mysql时,报错

pi@raspberrypi:/ $ mysql -uroot -p 
Enter password: 
ERROR 1698 (28000): Access denied for user 'root'@'localhost'

按照网上的说法,

1.进入到etc/mysql 目录下,查看debian.cnf文件,使用默认的用户名和密码登录

pi@raspberrypi:/etc/mysql $ sudo cat debian.cnf
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host     = localhost
user     = root
password = 
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host     = localhost
user     = root
password = 
socket   = /var/run/mysqld/mysqld.sock
basedir  = /usr

结果是默认密码是空,多次尝试不成功,依然报错。

 最后输入:sudo mysql -uroot(使用root身份免密码登录,一定要sudo,不要输入-p    否则进不去,我就是尝试多次,不成功)

终于进入系统

pi@raspberrypi:/ $ sudo mysql -uroot 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 10.1.37-MariaDB-0+deb9u1 Raspbian 9.0

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)]>

原来系统用的mysql的版本是MariaDB,是mysql的一个主要分支,但是它全面兼容mysql。

后续的操作按照网上介绍的内容继续操作:

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.01 sec)

  然后使用use mysql; 命令打开数据库。

MariaDB [(none)]> use mysql;
MariaDB [mysql]> update user set authentication_string=("你要设置的密码") where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

MariaDB [mysql]> update user set plugin="mysql_native_password";
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]> quit;
Bye

重启树莓派正常登录

此方法也使用与Ubuntu16以上的版本。

 

转载于:https://www.cnblogs.com/yay1688/p/10244100.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值