【筆記一】:樹莓派安裝mysql

目錄

1,配置國內源。

2,同步源

3,安裝mysql

4,測試安裝成功

5,設置密碼


 

1,配置國內源。

如果之前已經配置過可忽略此步驟。編輯 raspi.list

vi /etc/apt/sources.list.d/raspi.list

內容替換如下: 

deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main contrib non-free rpi
deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main contrib non-free rpi

2,同步源

apt-get update
apt-get upgrade

3,安裝mysql

apt-get install mysql-server

[root@raspberrypi /]$ apt-get install mysql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package mysql-server is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  mariadb-server-10.0

E: Package 'mysql-server' has no installation candidate

有如上提示,意思是可以安裝mariadb-server-10.0,我要安裝mysql但是卻提示安裝mariadb-server這是什麼鬼。

以下引用一段網友的話:

MariaDB是MySQL源代碼的一個分支,隨着Oracle買下Sun,MySQL也落入了關係型數據庫王者之手。在意識到Oracle會對MySQL許可做什麼後便分離了出來(MySQL先後被Sun、Oracle收購),MySQL之父的Michael以他女兒Maria的名字開始了MySQL的另外一個衍生版本:MariaDB。這兩個數據庫究竟有什麼本質的區別沒有?

區別一:

MariaDB不僅僅是Mysql的一個替代品,MariaDB包括的一些新特性使它優於MySQL。

區別二:

MariaDB跟MySQL在絕大多數方面是兼容的,對於開發者來說,幾乎感覺不到任何不同。目前MariaDB是發展最快的MySQL分支版本,新版本發佈速度已經超過了Oracle官方的MySQL版本。

MariaDB 是一個採用Aria存儲引擎的MySQL分支版本, 這個項目的更多的代碼都改編於 MySQL 6.0

區別三:

通過全面測試發現,MariaDB的查詢效率提升了3%-15%,平均提升了8%,而且沒有任何異常發生;以qp爲單位,吞吐量提升了2%-10%。由於缺少數據支持,現在還不能得出任何結論,但單從測試結果看來還是非常積極的。join中索引的使用以及查詢優化,特別是子查詢方面,MariaDB都有不少提升。此外,MariaDB對MySQL導入導出有良好支持。

 ------ 更多詳細內容參考 《解析Mariadb與MySQL的區別

 

根據提示安裝即可。 apt-get install mariadb-server-10.0 

[root@raspberrypi ~]$ apt-get install mariadb-server-10.0
Reading package lists... Done
Building dependency tree       
Reading state information... Done

4,測試安裝成功

[root@raspberrypi ~]$ mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 50
Server version: 10.3.22-MariaDB-0+deb10u1 Raspbian 10

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

5,設置密碼

Mysql安裝成功後,默認的root用戶密碼爲空,你可以使用以下命令來創建root用戶的密碼:

[root@host]# mysqladmin -u root password "new_password";

現在你可以通過以下命令來連接到Mysql服務器,並使用flush privileges;來是密碼立即生效。

[root@raspberrypi ~]$ mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 63
Server version: 10.3.22-MariaDB-0+deb10u1 Raspbian 10

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)]> flush privileges;
Query OK, 0 rows affected (0.001 sec)

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章