在Debian搭建phpMyAdmin phpMyAdmin 是一个以PHP为基础,以Web-Base方式架构在网站主机上的MySQL的数据库管理工具,让管理者可用Web接口管理MySQL数据库。
注释:以下命令全部以root用户执行,另外大家复制代码的时候前面的#不要复制,#代表的是root权限
安装phpMyAdmin需要的php扩展
1 2 3 # apt install php7.3-mysql php7.3-mbstring -y
下载phpMyAdmin源代码
1 2 3 # wget https://files.phpmyadmin.net/phpMyAdmin/4.9.0.1/phpMyAdmin-4.9.0.1-all-languages.zip
安装zip,并解压下载的源代码
1 2 3 # apt install zip unzip -y && unzip phpMyAdmin-4.9.0.1-all-languages.zip
移动phpMyAdmin源代码到网页目录下并把权限设置为nginx
1 2 3 # mv phpMyAdmin-4.9.0.1-all-languages /usr/share/nginx/html/phpMyAdmin && chown -R nginx:nginx /usr/share/nginx/html/phpMyAdmin
配置phpMyAdmin的短语密码
1 2 3 4 5 6 7 # sed -i "108 s/''/'自己随机生成32为密码就行'/g" /usr/share/nginx/html/phpMyAdmin/libraries/config.default.php 示例: # sed -i "108 s/''/'M4HUkD8rwVPo919e36Rp5zItiPqprByh'/g" /usr/share/nginx/html/phpMyAdmin/libraries/config.default.php
打开网页http://IP地址/phpMyAdmin/index.php登录phpMyAdmin,创建phpmyadmin数据库,登录→查找原因→创建
如果遇到root无法登陆,提示#1698 - Access denied for user ‘root‘@’localhost’,如下步骤添加新用户解决
1 2 3 4 #链接数据库 mysql -u root -p
创建一个用来赋予权限的账户(例如 root_sql)
1 2 3 4 5 6 CREATE USER 'root\_sql'@'localhost' IDENTIFIED BY 'yourpasswd'; GRANT ALL PRIVILEGES ON \*.\* TO 'root\_sql'@'localhost' WITH GRANT OPTION; FLUSH PRIVILEGES; exit #退出数据库
重启数据库,新用户应该能登陆了。登录→查找原因→创建
现在LNMP+phpMyAdmin的教程结束了,一个网站的环境算是基本搭建完成了。