码迷,mamicode.com
首页 > 数据库 > 详细

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

时间:2019-01-09 15:04:37      阅读:841      评论:0      收藏:0      [点我收藏+]

标签:raspberry   quit   mysql密码   ber   info   data   clear   成功   comm   

树莓派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以上的版本。

 

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

标签:raspberry   quit   mysql密码   ber   info   data   clear   成功   comm   

原文地址:https://www.cnblogs.com/yay1688/p/10244100.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!