在树莓派上安装mysql/MariaDB
时间:2022-10-18 23:05 作者:Anglei 分类: 树莓派
前序
mysql 在树莓派 raspberry pi 上的安装和在 Linux 上的差不多,因为网上的教程只是记述了一部分且遇到了情况,就整理下来
安装
因为不知道突然执行了什么操作,然后系统执行什么命令都要权限了,都要加上 sudo 才能执行,这个看个人情况吧
更新软件库
sudo apt-get update
安装 mysql
sudo apt-get install mysql-server
接下来就是安装过程了,本来以为中间会提示输入密码,结果一口气就安装完了,想到该怎么登陆啊
以空密码登陆
sudo mysql -u root
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 10.1.23-MariaDB-9+deb9u1 Raspbian 9.0
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
注:遇到陌生的 MariaDB,百科了发现是 mysql 的一个分支,完全继承 mysql 的用法,所以也不担心了,不过,这个应该是看个人情况的
修改密码
数据库中使用
连接数据库
use mysql;
修改密码为123456,自己定
UPDATE user SET password=PASSWORD('123456') WHERE user='root';
刷新
flush privileges;
退出
exit;
操作数据库服务
sudo /etc/init.d/mysql status/start/stop/restart
总结
安装之后需要修改密码,不然密码为空
ANOTHER==================================
MariaDB是MySQL的一个分支,由开源社区在维护。开发这个分支的原因是:甲骨文公司收购了MySQL后,有将MySQL闭源的潜在风险,因此社区采用分支的方式来避开这个风险。MariaDB的目的是完全兼容MySQL,能轻松成为MySQL的代替品。
在树莓派上安装mysql, 结果默认安装的是maria db(当然, 究竟是mysql还是maria db, 这个树莓派装的系统有关), 树莓派真会拥抱开源啊。 呵呵哒, 来看看安装:
sudo apt-get update #更新软件库
sudo apt-get install mysql-server #安装mysql,期间如果要求输入密码, 那就输入吧.
sudo mysql -u root -p #登录mysql查看是否安装成功
登录后, 是这样的(我发现,空密码也可以登录):
[plain] view plain copy
pi@raspberrypi:~/taoge $ sudo mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 16
Server version: 10.1.23-MariaDB-9+deb9u1 Raspbian 9.0
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
MariaDB [(none)]>
MariaDB [(none)]>
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [mysql]> show tables;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| column_stats |
| columns_priv |
| db |
| event |
| func |
| general_log |
| gtid_slave_pos |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| host |
| index_stats |
| innodb_index_stats |
| innodb_table_stats |
| plugin |
| proc |
| procs_priv |
| proxies_priv |
| roles_mapping |
| servers |
| slow_log |
| table_stats |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+
30 rows in set (0.00 sec)
MariaDB [mysql]>
不多说。
推荐阅读:
![]() 路过(0) |
![]() 雷人(0) |
![]() 握手(0) |
![]() 鲜花(0) |
![]() 鸡蛋(0) |