树莓派中安装mysql并配置远程访问
今天折腾了下我刚刚买的树莓派zero,编译安装了php,在安装MySQL时发现标准版的mysql依赖太多,无法直接进行安装,使用网上提供的mysql安装命令发现树莓派并不能进行相关依赖的补充,使用以下方法可以直接进行安装mysql,下面讲树莓派安装mysql遇到的坑
- 安装命令
pi@raspberrypi:~ $ apt-get install default-mysql-server -y
经过漫长的等待,发现安装已经结束,我们也可以进行使用mysql登录,但是突然发现没有密码,因为树莓派安装的mysql属于MariaDB类型,并不能使用mysql忘记密码的操作,使用以下命令实现密码的修改
pi@raspberrypi:~ $ sudo nano /etc/mysql/debian.cnf
将红框位置密码替换为123456
组合键 CTRL+O 回车键 保存 组合键 CTRL+X 退出编辑
pi@raspberrypi:~ $ sudo reboot #重启树莓派让配置生效
pi@raspberrypi:~ $ mysql -uroot -p #登录MYSQL 回车键后输入123456密码
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 15
Server version: 10.3.23-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)]>
MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "新密码";#允许root远程登录并修改登录密码
MariaDB [(none)]> flush privileges;#刷新权限表
安装到这里以为是结束了,没想到一个大坑正在等我,局域网其他主机无法登录此数据库,查找了一圈防火墙问题,发现没有一个是,最后在查找问题中发现了那么一句 ,一个大坑
树莓派上的mariaDB默认只监听本地访问,我们需要把它打开才能从其它计算机上访问数据库
pi@raspberrypi:~ $ sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
![](https://cdn.hlhasd.com/wp-content/uploads/2020/10/QQ截图20201020213138-1024x425.png)
将图像里面画红框的文本前面加#号进行注释,重启后树莓派就可以让其他电脑正常链接到此数据库。
以上为安装mysql数据库的折腾之旅,生命不息,折腾不止!
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/cy.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/hanx.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/huaix.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/tx.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/se.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/wx.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/zk.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/shui.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/kuk.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/lh.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/gz.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/ku.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/kel.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/yiw.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/yun.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/jy.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/dy.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/gg.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/fn.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/fendou.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/shuai.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/kl.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/pj.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/fan.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/lw.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/qiang.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/ruo.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/ws.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/ok.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/gy.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/qt.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/cj.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/aini.gif)
![](https://cdn.hlhasd.com/wp-content/themes/tow/images/smilies/bu.gif)