ubuntu 20.04 盒子NAS系统安装mysql数据库和phpmyadmin工具

Posted by cmbjx on June 5, 2024

今天分享给大家这个教程,教大家如何在盒子里安装mysql数据库,这对很多博客或者网站主来说,非常有价值。

首先,安装mysql:

1
2
sudo apt-get update
sudo apt install mysql-server

安装完毕增加root用户和权限: 先找到默认的debian用户:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
sudo cat /etc/mysql/debian.cnf

ubuntu@hi3798mv100:~$ sudo cat /etc/mysql/debian.cnf

[client]
host = localhost
user = debian-sys-maint
password = XGIsmI4ihbiqf7Wi
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = XGIsmI4ihbiqf7Wi
socket = /var/run/mysqld/mysqld.sock

此时已默认debian账号先行进入mysql后台, 进行添加root用户的操作

1
sudo mysql -u debian-sys-maint -p

输入上面查看到的password的密码进去,

1
2
3
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的强密码';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;
quit

检查是否成功开启root用户

1
2
sudo mysql -u root -p
quit退出

其次安装phpmyadmin管理工具

1
sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl

安装完后,为了在浏览器直接打开,我们要把工具软链接放在网站目录下:

1
sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin

然后你打开网站http://192.168.1.10/phpmyadmin 就可以登录管理里了。**