树莓派 -- mysql 安装

树莓派 -- mysql 安装


enter description here

Yesterday is a history, tomorrow is a mystery, but today is a gift.


前序

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

总结

安装之后需要修改密码,不然密码为空


posted @ 2017-11-27 23:13  onlypinsily  阅读(5836)  评论(0编辑  收藏  举报