0x001 安装和启动mysql
其实已经换成mariadb了;
- 搜索:
yum list|grep mariadb
- 安装:yum install mariadb mariadb-server`
- 启动:
service mariadb start
- 开机自动启动:
systemctl enable mariadb
0x002 初始化密码mysql
- 切换数据库:
use mysql
- 设置新密码:
update user set password =PASSWORD('rooter') where user ='root';
flush privileges
0x003 开启远程连接mysql
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'rooter' WITH GRANT OPTION;
flush privileges
0x004 开启ssh
--
- 查看是否安装ssh:
rpm -qa | grep ssh
- 未安装:
yum install openssh-server
- 启动:
service sshd start
- 开机启动:
chkonfig sshd on
(off 是关闭)
0x005 开启apahce
- 查看是否安装ssh:
rpm -qa | grep httpd
- 未安装:
yum install httpd
- 启动:
service httpd start
sudo usr/sbin/apachectl -k start
- 开机启动:
chkonfig httpd on
(off 是关闭) - 默认项目目录:
/var/www/html
0x006 开启php
1.安装php:yum install php php-mysql
2.重启apache:service httdp restart
-
测试数据库链接:
<?php
$servername = "localhost";
$username = "username";
$password = "password";// 创建连接 $conn = new mysqli($servername, $username, $password); // 检测连接 if ($conn->connect_error) { die("连接失败: " . $conn->connect_error); } echo "连接成功"; ?>