本文主要和大家分享Centos7安装mysql与php的方法,希望能帮助到大家。

相关mysql视频教程推荐:《mysql教程

官网下载安装mysql-server

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

wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpmrpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install mysql-community-server
登录后复制
登录后复制

安装过程如下图

Centos7安装mysql与php的方法-LMLPHP

Centos7安装mysql与php的方法-LMLPHP

Centos7安装mysql与php的方法-LMLPHP

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

Centos7安装mysql与php的方法-LMLPHP

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

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

如下图 我们把root账号密码设置为了 123456 并登录成功

Centos7安装mysql与php的方法-LMLPHP

Centos7安装mysql与php的方法-LMLPHP

设置mysql远程连接

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

grant all privileges on *.* to root@'%'identified by 'password';
登录后复制
登录后复制

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

create user 'username'@'%' identified by 'password';
登录后复制
登录后复制

刷新权限 flush privileges;

Centos7安装mysql与php的方法-LMLPHP

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


下载php7

  • 安装php7

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpmrpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
登录后复制
登录后复制

Centos7安装mysql与php的方法-LMLPHP

  • 使用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
登录后复制
登录后复制

Centos7安装mysql与php的方法-LMLPHP

  • 安装php-fpm 并启动

yum install php70w-fpm php70w-opcache
登录后复制
登录后复制

Centos7安装mysql与php的方法-LMLPHP

启动php-fpm

systemctl start php-fpm
登录后复制
登录后复制
  • 测试php和php-fpm是否安装成功

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

Centos7安装mysql与php的方法-LMLPHP

Centos7安装mysql与php的方法-LMLPHP

访问你的web服务器 出现下图 即安装成功

Centos7安装mysql与php的方法-LMLPHP

官网下载安装mysql-server

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

wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpmrpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install mysql-community-server
登录后复制
登录后复制

安装过程如下图

Centos7安装mysql与php的方法-LMLPHP

Centos7安装mysql与php的方法-LMLPHP

Centos7安装mysql与php的方法-LMLPHP

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

Centos7安装mysql与php的方法-LMLPHP

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

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

如下图 我们把root账号密码设置为了 123456 并登录成功

Centos7安装mysql与php的方法-LMLPHP

Centos7安装mysql与php的方法-LMLPHP

设置mysql远程连接

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

grant all privileges on *.* to root@'%'identified by 'password';
登录后复制
登录后复制

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

create user 'username'@'%' identified by 'password';
登录后复制
登录后复制

刷新权限 flush privileges;

Centos7安装mysql与php的方法-LMLPHP

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


下载php7

  • 安装php7

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpmrpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
登录后复制
登录后复制

Centos7安装mysql与php的方法-LMLPHP

  • 使用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
登录后复制
登录后复制

Centos7安装mysql与php的方法-LMLPHP

  • 安装php-fpm 并启动

yum install php70w-fpm php70w-opcache
登录后复制
登录后复制

Centos7安装mysql与php的方法-LMLPHP

启动php-fpm

systemctl start php-fpm
登录后复制
登录后复制
  • 测试php和php-fpm是否安装成功

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

Centos7安装mysql与php的方法-LMLPHP

Centos7安装mysql与php的方法-LMLPHP

访问你的web服务器 出现下图 即安装成功

Centos7安装mysql与php的方法-LMLPHP

相关推荐:

Linux学习第三篇之Centos7安装mysql5.7.16数据库的详细介绍

详细介绍CentOS7安装Mysql并设置开机自启动的方法

gcc-centos7安装mysql workbench 依赖检测失败

以上就是Centos7安装mysql与php的方法的详细内容,更多请关注Work网其它相关文章!

09-12 09:14