Centos7 安装mysql与php

 Centos7 安装mysql与php  靠谱的安装方法

官网下载安装mysql-server

依次使用下面三个命令安装

wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

rpm -ivh mysql-community-release-el7-5.noarch.rpm

yum install mysql-community-server

安装过程如下图

Centos7 安装mysql与php

Centos7 安装mysql与php

Centos7 安装mysql与php

安装成功后 使用 systemctl start mysql 命令启动mysql

Centos7 安装mysql与php

由上图可以看出,初始安装mysql root账号是没有密码的

下面我们来设置 root 账户密码 使用命令 set password for 'root'@'localhost' =password('password');

如下图 我们把root账号密码设置为了 123456 并登录成功
Centos7 安装mysql与php

设置mysql远程连接

把数据库所以权限都赋予root账号

grant all privileges on *.* to [email protected]'%'identified by 'password';

如果是新用户而不是root 则要先新建用户

create user 'username'@'%' identified by 'password'; 

刷新权限 flush privileges;
Centos7 安装mysql与php

这样我们的mysql 数据库就配置好了 还可以远程连接

下载php7

  • 安装php7

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm 

Centos7 安装mysql与php

使用yum命令安装php7

yum install php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-mysql.x86_64 php70w-pdo.x86_64 

安装php-fpm 并启动

yum install php70w-fpm php70w-opcache

启动php-fpm

systemctl start php-fpm

测试php和php-fpm是否安装成功

在 nginx 根目录 新建index.php 内容如下

Centos7 安装mysql与php

Centos7 安装mysql与php原文地址 https://blog.****.net/qq_36431213/article/details/79576025

感谢上官二狗同学分享