树莓派要mysql的密码_树莓派raspberry Pi 3B+系统中安装mysql过程中不提示输入密码,安装完后如何设置密码...
樹莓派raspberry Pi 3B+安裝mysql未提示輸入密碼,安裝后修改mysql密碼默認密碼
使用mysql -uroot -p 命令連接mysql時,報錯
pi@raspberrypi:/ $ mysql -uroot -p
Enter password:
ERROR1698 (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 idis 5Server version:10.1.37-MariaDB-0+deb9u1 Raspbian 9.0Copyright (c)2000, 2018, Oracle, MariaDB Corporation Ab andothers.
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.00sec)
Rows matched:1 Changed: 1Warnings: 0
MariaDB [mysql]> update user set plugin="mysql_native_password";
Query OK,1 row affected (0.00sec)
Rows matched:1 Changed: 1Warnings: 0
MariaDB [mysql]>flush privileges;
Query OK, 0 rows affected (0.00sec)
MariaDB [mysql]>quit;
Bye
重啟樹莓派正常登錄
此方法也使用與Ubuntu16以上的版本。
總結
以上是生活随笔為你收集整理的树莓派要mysql的密码_树莓派raspberry Pi 3B+系统中安装mysql过程中不提示输入密码,安装完后如何设置密码...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 日本飞机餐推出蟋蟀粉末汉堡:用废弃食品培
- 下一篇: python本地编译器_Python学习