樹莓派 2安裝MySQL

2022-09-01 19:21:09 字數 2318 閱讀 8076

上一節我主要記錄了樹莓派的啟動使用,這一節主要記錄下在樹莓派上面安裝mysql,因為我要在上面執行nlifebill所以我就先安裝mysql。

首先我想啟用root使用者,所以我先啟用root使用者:

sudo passwd root

這裡會提示輸入兩次密碼,然後:

sudo passwd --unlock root

這樣就可以啟動root登入,如果想立馬使用root,可以:

su root

這樣就可以直接切換到root使用者不過會提示輸入密碼,如果下次用root登入的話就會在登入的時候顯示設定畫面,如果你只是玩玩就可以不用管這個。

接下來要安裝mysql,安裝之前可以先更新下本機軟體:

sudo apt-get update

然後就是等待了。等待完之後要準備安裝mysql了,命令直接安裝:

sudo apt-get install mysql-server

然後就是等待,在安裝的過程中會提示你讓你輸入mysql的root密碼,會提示兩次。輸入完成之後就會安裝成功了。

然後輸入如下命令進入mysql:

mysql -u root -p

然後會提示輸入密碼,輸入密碼就可以進入mysql:

1 root@raspberrypi:/home/pi# mysql -u root -p

2enter password:

3welcome to the mysql monitor. commands end with ; or \g.

4 your mysql connection id is 43

5 server version: 5.5.35-0+wheezy1 (debian)68

9 oracle is a registered trademark of oracle corporation and/or its

10affiliates. other names may be trademarks of their respective

11owners.

1213 type '

help;

' or '\h'

for help. type '

\c' to clear

the current input statement.

1415 mysql>

然後建立我要使用的資料庫lifebill:

1 mysql>create database lifebill

2 ->;

3 query ok, 1 row affected (0.01 sec)

資料庫建立好之後要新建個使用者:

1 mysql> create user dn9x identified by "

123"

;2 query ok, 0 rows affected (0.00 sec)

新使用者建立完成之後要授權給他,這裡我只是授權了只能本機登入:

mysql> grant insert, delete, update, select on lifebill.* to dn9x@localhost identified by "123";

query ok, 0 rows affected (0.00 sec)

授權完成之後用新使用者登入下看看資料庫:

1 mysql>show databases;

2 +--------------------+

3 | database |

4 +--------------------+

5 | information_schema |

6 | lifebill |

7 +--------------------+

82 rows in set (0.00 sec)

顯示lifebill已經在此使用者下了,接下來就是要匯入基本資料了,這裡我的資料和專案都放在github上面,所以先把專案down下來,而raspbian有安裝好的git,這樣就好辦多了。

因為我的sql檔案也在專案裡面,專案也是要用的,所以就直接down下整個專案。然後匯入sql資料:

1 mysql -u root -p -d lifebill到此資料就匯入成功了!查詢下表和資料都沒有問題,接下來就是nodejs方面的問題了!

樹莓派 無法安裝mysql 樹莓派安裝mysql

前置,更新系統 sudo apt get update sudo apt get upgrade 安裝與配置mysql 因為系統版本不同所以我們要根據自己的系統版本來換相應的源 更換源時,必須先將原來的源複製乙份 cp etc apt sources.list cp etc apt sources....

樹莓派安裝Mysql

安裝mysql,安裝過程中會要求輸入2次密碼 sudo apt get install mysql server 啟動mysql,預設是自動啟動 sudo service mysql start 關閉mysql sudo service mysql stop 重啟mysql sudo service...

樹莓派 mysql 安裝

linux mysql yesterday is a history,tomorrow is a mystery,but today is a gift.mysql 在樹莓派 raspberry pi 上的安裝和在 linux 上的差不多,因為網上的教程只是記述了一部分且遇到了情況,就整理下來 su...