1.关闭防火漆
systemctl stop firewalld.service#关闭防火墙 systemctl disable firewalld.service#禁止防火墙开机启动
2.安装apache
yum install httpd -y systemctl start httpd.service
3.安装php
更新软件仓库
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
安装PHP及插件
yum install -y php56w php56w-opcache php56w-xml php56w-mcrypt php56w-gd php56w-devel php56w-mysql php56w-intl php56w-mbstring
4.安装mysql
提前安装net-tools工具,下载地址ftp://mirror.switch.ch/pool/4/mirror/centos/7.3.1611/os/x86_64/Packages/net-tools-2.0-0.17.20131004git.el7.x86_64.rpm
下载mysql完整压缩包,下载地址
http://cdn.mysql.com//Downloads/MySQL-5.6/MySQL-5.6.35-1.el6.x86_64.rpm-bundle.tar
将这两个文件放到/usr/local/src文件夹下
cd /usr/local/src rpm -ivh net-tools-2.0-0.17.20131004git.el7.x86_64.rpm#根据具体版本确定 tar xvf MySQL-5.6.35-1.el6.x86_64.rpm-bundle.tar#解压缩mysql的rpm组合包
安装MySQL-client-5.6.35-1.el6.x86_64.rpm
rpm -ivh MySQL-client-5.6.35-1.el6.x86_64.rpm
安装MySQL-devel-5.6.35-1.el6.x86_64.rpm
rpm -ivh MySQL-devel-5.6.35-1.el6.x86_64.rpm
卸载当前系统的mariadb
rpm -qa | grep mariadb rpm -e --nodeps `rpm -qa | grep mariadb`
安装MySQL-server-5.6.35-1.el6.x86_64.rpm
rpm -ivh MySQL-server-5.6.35-1.el6.x86_64.rpm systemctl start mysql.service
此时mysql安装完成,但由于不知道密码无法进入
5.重置mysql密码
关闭mysql服务
systemctl stop mysql.service
绕过密码验证
mysqld_safe --user=mysql --skip-grant-tables--skip-networking #提示一下内容后 161212 15:10:30 mysqld_safe Logging to ‘/var/lib/mysql/localhost.localdomain.err‘. 161212 15:10:30 mysqld_safe A mysqld process already exists 按Ctrl+c终止
输入用户登录命令
mysql -u root mysql UPDATE user SET Password=PASSWORD(‘your_password‘) where USER=‘root‘; #将your_password改为自己的密码 FLUSH PRIVILEGES;#更新 quit#退出mysql systemctl start mysql.service#启动mysql
这是数据库依旧不能使用,登录会提示
You must SET PASSWORD before executing this statement
解决办法
mysql -u root -p your_password SET PASSWORD = PASSWORD(‘your_new_password‘);
至此,mysql安装成功.
本文出自 “keefe” 博客,请务必保留此出处http://keefe.blog.51cto.com/9548710/1882315
Centos7下通过yum搭建apache+php+mysql服务器
原文地址:http://keefe.blog.51cto.com/9548710/1882315