MySQL/phpMyAdmin/Centos PhpMyAdmin
来自康健生活
< MySQL | phpMyAdmin
tar.gz
wget https://files.phpmyadmin.net/phpMyAdmin/4.9.3/phpMyAdmin-4.9.3-all-languages.tar.gz
tar -xf phpMyAdmin-4.9.3-all-languages.tar.gz
mv phpMyAdmin-4.9.3-all-languages/ phpMyAdmin-4.9.3
mv phpMyAdmin-4.9.3 /usr/local/etc
cd phpMyAdmin-4.9.3
cp config.sample.inc.php config.inc.php
phpMyAdmin 放到 web 目录下
mkdir /var/www/pma
cp -Rf /usr/local/etc/phpMyAdmin-4.9.3/* /var/www/pma/
配置主机地址 pma 的虚拟主机
yum install httpd
systemctl enable httpd # 开机启动
systemctl start httpd # 启动
vim /etc/httpd/conf.d/vhosts.conf
<VirtualHost *:80>
DocumentRoot "/var/www/pma"
ServerName pma.kang.com
</VirtualHost>
<Directory "/var/www/pma">
AllowOverride All
Require all granted
</Directory>
重启服务
httpd -t
systemctl restart httpd
关闭防火墙
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
关闭SELinux
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
cat /etc/selinux/config
# This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of these three values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted
sudo systemctl restart php-fpm
sudo systemctl restart httpd
git
Composer
php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
php composer-setup.php
mv composer.phar /usr/local/bin/composer
ln -s /usr/local/bin/composer /bin/composer
切换为国内镜像:
composer config -g repo.packagist composer https://packagist.phpcomposer.com
composer selfupdate
composer create-project phpmyadmin/phpmyadmin
PhpMyAdmin 配置
vi /var/www/pma/libraries/config.default.php
$cfg['PmaAbsoluteUri'] = 'http://ip/phpmyadmin';//填写phpmyadmin的访问网址 $cfg['Servers'][$i]['host'] = 'mysql服务器ip'; // 需要访问的mysql host $cfg['Servers'][$i]['port'] = ''; // mysql端口,如果是默认3306,保留为空即可 $cfg['Servers'][$i]['user'] = 'root'; // mysql用户名 $cfg['Servers'][$i]['password'] = ''; // MySQL password $cfg['Servers'][$i]['auth_type'] = 'cookie'; //认证方式
多库连接
vi phpmyadmin/libraries/config.default.php
/** * allow login to any user entered server in cookie based authentication * * @global boolean $cfg['AllowArbitraryServer'] */ $cfg['AllowArbitraryServer'] = true; //默认是false,改成true
cp phpmyadmin/config.sample.inc.php phpmyadmin/config.inc.php
vi phpmyadmin/config.inc.php
$connect_hosts = array( '1'=>array( "host" => "localhost", "controlhost" => "localhost", "controluser" => "root", "controlpassword" => "kangjian1990", "controlport" => "3306" ), '2' => array( "host" => "192.168.50.20", "controlhost" => "localhost", "controluser" => "mediawiki_user", "controlpassword" => "mediawiki_PasswoRd", "controlport" => "3307" ) ); for ($i=1;$i<=count($connect_hosts);$i++) { /* Authentication type */ /* Server parameters */ $cfg['Servers'][$i]['controlhost'] = $connect_hosts[$i]['controlhost']; /* Select mysqli if your server has it */ /* rajk - for blobstreaming */ }
或者另一种写法
$servers_json_str = file_get_contents('/var/services/web/phpMyAdmin/synology_server_choice.json'); foreach (json_decode($servers_json_str, true) as $server) { $i++; $cfg['Servers'][$i] = $server; }
synology_server_choice.json
[{ "verbose": "MariaDB 10", "auth_type": "cookie", "host": "localhost", "connect_type": "socket", "socket": "\/run\/mysqld\/mysqld10.sock", "compress": false, "AllowNoPassword": false }]
或者
/** * First server */ $i++; /* Authentication type */ $cfg['Servers'][$i]['auth_type'] = 'cookie'; /* Server parameters */ $cfg['Servers'][$i]['host'] = 'data.kang.com'; $cfg['Servers'][$i]['compress'] = false; $cfg['Servers'][$i]['AllowNoPassword'] = false; /* User used to manipulate with storage */ $cfg['Servers'][$i]['controlhost'] = 'localhost'; $cfg['Servers'][$i]['controlport'] = '3306'; $cfg['Servers'][$i]['controluser'] = 'root'; $cfg['Servers'][$i]['controlpass'] = 'kangjian1990'; /* Storage database and tables */ /** * Two server */ $i++; /* Authentication type */ /* Server parameters */ /* User used to manipulate with storage */ /* Storage database and tables */
No categories