方案
- 安装httpd、mysql、php-mysql及相关包
- 启动httpd服务程序
- 解压phpMyAdmin包,部署到网站目录
- 配置config.inc.php,指定MySQL主机地址
- 创建授权用户
- 浏览器访问、登录使用
步骤
步骤一:准备软件的运行环境 lamp
[root@zhangyx ~]# rpm -q httpd php php-mysql //检测是否安装软件包package httpd is not installed //未安装软件包 httpdpackage php is not installed //未安装软件包 phppackage php-mysql is not installed //未安装软件包 php-mysql[root@zhangyx ~]# yum -y install httpd php php-mysql //装包[root@zhangyx ~]# systemctl start httpd //启动服务[root@zhangyx ~]# systemctl enable httpd //设置开机自启Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
步骤二:测试运行环境
[root@zhangyx ~]# vim /var/www/html/test.php //编辑页面测试文件[root@zhangyx ~]# cat /var/www/html/test.php //查看页面测试文件#!/bin/bash<?php$x=mysql_connect(\"localhost\",\"root\",\"123456\");if($x){echo \"ok\";}else{echo \"no\";};?>[root@zhangyx ~]# yum -y install elinks //安装测试网页工具[root@zhangyx ~]# elinks --dump http://localhost/test.php#!/bin/bash ok //验证测试页面成功
步骤三:安装软件包
1)物理机传输解压包给虚拟机124.70.165.39
[root@zhangyx ~]# scp phpMyAdmin-2.11.11-all-languages.tar.gz 124.70.165.39:/root/ //这里为自己的虚拟机The authenticity of host \'124.70.165.39 (124.70.165.39)\' can\'t be established.ECDSA key fingerprint is SHA256:Pj2l+x1ofPFO0ohGhnir/ELDtPlkiwadccDAizTSO00.ECDSA key fingerprint is MD5:6b:36:66:24:95:5b:72:99:db:0b:00:ae:d5:9b:4a:63.Are you sure you want to continue connecting (yes/no)? yes //确认Warning: Permanently added \'124.70.165.39\' (ECDSA) to the list of known [email protected]\'s password: //此处输入虚拟机密码,为root登录密码phpMyAdmin-2.11.11-all-languages.tar.gz 100% 4218KB 281.2KB/s 00:15
2)虚拟机124.70.165.39解压phpMyAdmin-2.11.11-all-languages.tar.gz压缩包
[root@zhangyx ~]# tar -zxf phpMyAdmin-2.11.11-all-languages.tar.gz -C /var/www/html/ //-C 表示改变至目录[root@zhangyx ~]# cd /var/www/html/[root@zhangyx ~]# mv phpMyAdmin-2.11.11-all-languages phpmyadmin //改变目录名[root@zhangyx ~]# chown -R apache:apache phpmyadmin/ //改变phpmyadmin目录权限
步骤四:修改软件的配置文件定义管理的数据库服务器
切换到部署后的phpmyadmin程序目录,拷贝配置文件,并修改配置以正确指定MySQL服务器的地址
[root@zhangyx ~]# cd phpmyadmin[root@zhangyx phpmyadmin~]#cp config.sample.inc.php config.inc.php //备份主配置文件[root@zhangyx phpmyadmin~]#vim config.inc.php //编辑主配置文件17 $cfg[\'blowfish_secret\'] = \'zyx123\'; //第17行给cookie做认证的值,可以随便填写31 $cfg[\'Servers\'][$i][\'host\'] = \'localhost\'; //第31行指定主机名,定义连接哪台服务器:wq
步骤五:在客户端访问软件 管理数据库服务器
1)在客户端访问软件,打开浏览器输入http://124.70.165.39/phpmyadmin(数据库服务器地址) 访问软件,如图所示,用户名是root,密码是123456
2)登入成功后,如图所示,即可在授权范围内对MySQL数据库进行管理。