raspberryPI 树莓派 安装 mysql

Modified on: Sun, 21 Jun 2020 20:34:52 +0800 热度: 2,908 度

1.安装mysql

apt-get install update
apt-get install mysql-server

2.打开mysql 这时直接使用mysql -u root

3.设置mysql的密码

MariaDB [(none)]> use mysql;
MariaDB [mysql]> update user set plugin='mysql_native_password' where user='root';
MariaDB [mysql]> UPDATE user SET password=PASSWORD('root的密码') WHERE user='root';
MariaDB [mysql]> flush privileges;
MariaDB [mysql]> exit;

4.允许远程操作

$ sudo vi /etc/mysql/mariadb.conf.d/50-server.cnf
# 将bind-address这行注释掉
# 或者将127.0.0.1 这个值改为  0.0.0.0
# 然后重启
$ sudo /etc/init.d/mysql restart

5.设置账户权限

$ mysql -u root -p
$ 输入密码
MariaDB [(none)]> use mysql;
MariaDB [mysql]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root的密码' WITH GRANT OPTION;
MariaDB [mysql]> flush privileges;

添加新评论