樹莓派安裝mysql

步驟

安裝 mysql server

$ sudo apt-get update
$ sudo apt-get install mysql-server

安裝完畢以后,root密碼默認(rèn)為空。即任意密碼都可以登錄。

$ sudo mysql -u root
$ 回車登錄數(shù)據(jù)庫
# 出現(xiàn)下面提示,表示成功

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 13
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)]> 
# MariaDB是一個完全兼容mysql的數(shù)據(jù)庫,具體可以自行百度。

設(shè)置root密碼

MariaDB [(none)]> use mysql;
MariaDB [mysql]> update user set plugin='mysql_native_password' where user='root';
MariaDB [mysql]> UPDATE user SET password=PASSWORD('root的密碼') WHERE user='root';
MariaDB [mysql]> flush privileges;
MariaDB [mysql]> exit;

操作Mysql

$ sudo /etc/init.d/mysql restart
# mysql的其他操作    status、start、stop、restart

開啟遠(yuǎn)程訪問

  1. 允許遠(yuǎn)程登錄
$ sudo vi /etc/mysql/mariadb.conf.d/50-server.cnf
# 將bind-address這行注釋掉
# 或者將127.0.0.1 這個值改為  0.0.0.0
# 然后重啟
$ sudo /etc/init.d/mysql restart
  1. 設(shè)置賬號權(quán)限
$ mysql -u root -p
$ 輸入密碼
MariaDB [(none)]> use mysql;
MariaDB [mysql]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root的密碼' WITH GRANT OPTION;
MariaDB [mysql]> flush privileges;

然后就可以使用客戶端進(jìn)行連接了!

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容