【笔记一】:树莓派安装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)

 

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