phpMyAdmin 5.2默认用户名密码,其实是你要连接的MySQL数据库的账号、密码。不是用户名root,密码root或空。
phpMyAdmin可以认为只是MySQL的UI界面管理工具,它不存储用户名密码。它把用户名、密码传给MySQL,让MySQL来判断这个账号是否有权限登陆这个数据库。具体可以看”附录2、User management“。
phpMyAdmin上创建的账号,其实只是帮你在对应的MySQL数据库创建账号,其它MySQL数据库要访问,也是需要另外创建账号的。
phpMyAdmin官网下载
具体:
一、下载phpMyAdmin
# cd /data/software
# wget https://files.phpmyadmin.net/phpMyAdmin/5.2.0/phpMyAdmin-5.2.0-all-languages.zip
# unzip phpMyAdmin-5.2.0-all-languages.zip
# mv phpMyAdmin-5.2.0-all-languages /data/www/phpMyAdmin
二、创建运行目录
# mkdir /data/www/phpMyAdmin/tmp
#nginx.nginx为php的运行用户、用户组,可以通过ps aux|grep php查看
# chown nginx.nginx /data/www/phpMyAdmin/tmp
三、修改config.inc.php配置
# cd /data/www/phpMyAdmin
# cp config.sample.inc.php config.inc.php
3.1 修改配置(phpMyAdmin连接单个数据库)
修改blowfish_secret,xxxx修改为自己想要的,这个不是密码,这个是加密密码用的,需要32个字符。phpMyAdmin的账号密码其实是要连接的MySQL数据库的账号、密码
修改First server为实际内容, verbose是指数据库的备注说明,在phpMyAdmin登陆里选择数据库使用 host是数据库的实际地址 port是数据库的端口
# vim config.inc.php
/**
* This is needed for cookie based authentication to encrypt password in
* cookie. Needs to be 32 chars long.
*/
$cfg['blowfish_secret'] = 'xxxx'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
/**
* Servers configuration
*/
$i = 0;
/**
* First server
*/
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['verbose'] = 'db.66office.com';
$cfg['Servers'][$i]['host'] = '172.16.0.3';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = false;
3.2 修改配置(phpMyAdmin连接多个数据库)
如果phpMyAdmin要连接多个数据库,就复制一个First server那段,改成Second server,Third server。里面的verbose、host、port改成第二个MySQL的地址,商品就行了。
/**
* First server
*/
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['verbose'] = 'db.66office.com';
$cfg['Servers'][$i]['host'] = '172.16.0.3';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = false;
/**
* * Second server
* */
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['verbose'] = 'db2.66office.com';
$cfg['Servers'][$i]['host'] = '172.16.0.4';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = false;
四、配置nginx
server_name改成你自己域名或ip,用域名记得要解析。
$ vim /etc/nginx/conf/phpmyadmin_nginx.conf
server
{
listen 80;
server_name phpmyadmin.66office.com;
index index.html index.htm index.php;
root /data/www/phpMyAdmin;
location ~ .*\.(php|php5)?$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
access_log off;
}
location ~ .*\.(js|css)?$
{
expires 1h;
access_log off;
}
access_log off;
error_log /dev/null;
}
web访问:
浏览器访问phpmyadmin.66office.com
附录:
附录1、phpMyAdmin 官方安装文档
https://docs.phpmyadmin.net/zh_CN/latest/setup.html#
附录2、User management
phpMyAdmin does not handle user management, rather it passes the username and password on to MySQL, which then determines whether a user is permitted to perform a particular action.
————————————————
声明:本文由 66办公「66office.com」原创,欢迎转载,转载请保留链接。