安装PHP
- 安装更新与PHP证书安装
apt update && apt upgrade
apt install ca-certificates apt-transport-https
wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
echo "deb https://packages.sury.org/php/ buster main" | tee /etc/apt/sources.list.d/php.list
- 安装PHP
apt update
apt install php7.3
apt install php7.3-cli php7.3-common php7.3-curl php7.3-gd php7.3-json php7.3-mbstring php7.3-mysql php7.3-xml
- 配置pdo(去掉注释)
nano /etc/php/7.3/apache2/php.ini
extension=pdo_mysql
安装MariaDB
- 安装MariaDB
apt install mariadb-server -y
- 设置开机启动MariaDB
systemctl enable mariadb.service
systemctl restart mariadb.service
- 设置MariaDB权限与密码等
- 登陆MariaDB:无密码
mysql -uroot
有密码用mysql -uroot -p123456
- 显示数据库
show databases;
- 选择数据库
use mysql;
- 查询用户
SELECT host,user,password from user;
- 设置密码
set password for ‘root‘@‘localhost‘ =password(‘123456‘);
- 远程连接设置
grant all privileges on *.* to [email protected]‘%‘identified by ‘123456‘;
- 如果是不是root则先新建用户
create user ‘用户名‘@‘%‘ ip地址 by ‘密码‘
测试pdo代码(方便不懂的人使用修改,注意127.0.0.1与localhost有可能不一样!请修改mysql密码)
重启apache服务
systemctl restart apache2.service
```
以上完成相关设置
原文地址:https://www.cnblogs.com/praybb/p/12155604.html
时间: 2024-10-28 15:05:03