树莓派 -- mysql 安装

树莓派 -- mysql 安装


enter description here

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


前序

mysql 在树莓派 raspberry pi 上的安装和在 Linux 上的差很少,由于网上的教程只是记述了一部分且遇到了状况,就整理下来mysql


安装

  • 由于不知道忽然执行了什么操做,而后系统执行什么命令都要权限了,都要加上 sudo 才能执行,这个看我的状况吧
  • 更新软件库
sudo apt-get update
  • 安装 mysql
sudo apt-get install mysql-server

接下来就是安装过程了,原本觉得中间会提示输入密码,结果一口气就安装完了,想到该怎么登录啊linux

  • 以空密码登录
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 的用法,因此也不担忧了,不过,这个应该是看我的状况的sql

  • 修改密码
# 数据库中使用
# 链接数据库
use mysql;
 # 修改密码为123456,本身定
UPDATE user SET password=PASSWORD('123456') WHERE user='root';
 # 刷新
flush privileges;
 # 退出
exit;
  • 操做数据库服务
sudo /etc/init.d/mysql status/start/stop/restart

总结

安装以后须要修改密码,否则密码为空shell

相关文章
相关标签/搜索