phpMyAdmin是一個以PHP為基礎(chǔ),以Web-Base方式架構(gòu)在網(wǎng)站主機(jī)上的MySQL的數(shù)據(jù)庫管理工具,讓管理者可用Web接口管理MySQL數(shù)據(jù)庫。借由此Web接口可以成為一個簡易方式輸入繁雜SQL語法的較佳途徑,尤其要處理大量資料的匯入及匯出更為方便。其中一個更大的優(yōu)勢在于由于phpMyAdmin跟其他PHP程式一樣在網(wǎng)頁服務(wù)器上執(zhí)行,但是您可以在任何地方使用這些程式產(chǎn)生的HTML頁面,也就是于遠(yuǎn)端管理MySQL數(shù)據(jù)庫,方便的建立、修改、刪除數(shù)據(jù)庫及資料表。也可借由phpMyAdmin建立常用的php語法,方便編寫網(wǎng)頁時所需要的sql語法正確性。
phpMyAdmin是一個非常受歡迎的基于web的MySQL數(shù)據(jù)庫管理工具。它能夠創(chuàng)建和刪除數(shù)據(jù)庫,創(chuàng)建/刪除/修改表格,刪除/編輯/新增字段,執(zhí)行SQL腳本等。
phpMyAdmin安裝
先從phpMyAdmin官方或者ucbug下載都可以。
進(jìn)入之后有download按鈕,點擊導(dǎo)航欄的Download鏈接,進(jìn)入下載界面,這里下載最新版的5.0.2
PHP版本:7.1及以上
Mysql版本:5.5及以上
1、下載phpMyAdmin
[root@localhost ~]# wget https://files.phpmyadmin.net/phpMyAdmin/5.0.2/phpMyAdmin-5.0.2-all-languages.tar.gz
2、解壓phpMyAdmin
[root@localhost ~]# tar xf phpMyAdmin-5.0.2-all-languages.tar.gz
3、拷貝到訪問目錄下面(根據(jù)自身目錄配置)
[root@localhost ~]# mv phpMyAdmin-5.0.2-all-languages /usr/local/nginx/html/phpMyAdmin
4、修改phpMyAdmin配置文件
[root@localhost ~]# cd /usr/local/nginx/html/phpMyAdmin
[root@localhost phpMyAdmin]# cp config.sample.inc.php config.inc.php
[root@localhost phpMyAdmin]# vim config.inc.php
找到$cfg['blowfish_secret']配置項,后面默認(rèn)為空,這里我們可以隨便設(shè)置一個復(fù)雜的字符串,用來加密使用:
32位字符串:PTOb45P2yyV*XXEdXQsKhA1VtFKurcHG
然后$cfg['Servers'][$i]['auth_type']這一項默認(rèn)為cookie,表示每次都要登錄,我們不用修改,這樣比較安全,然后$cfg['Servers'][$i]['host'] = '127.0.0.1';這里建議設(shè)置成Mysql的IP地址(因為這里使用的數(shù)據(jù)庫在本地),則無論是本地還是遠(yuǎn)程只要mysql授權(quán)都沒有問題,一定要注意,建議使用IP地址。
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = false;
保存并退出。
5、創(chuàng)建緩存模板文件目錄
[root@localhost phpMyAdmin]# mkdir tmp
[root@localhost phpMyAdmin]# chown -R www.www /usr/local/nginx/html/phpMyAdmin
6、編輯Nginx配置文件(根據(jù)自身配置)
[root@localhost phpMyAdmin]# vim /usr/local/nginx/conf/nginx.conf
#配置內(nèi)容如下
server {
listen 80;
server_name localhost;
location / {
root html/phpMyAdmin;
index index.php index.html index.htm;
}
location ~* \.php$ {
root html/phpMyAdmin;
fastcgi_connect_timeout 300s;
fastcgi_send_timeout 300s;
fastcgi_read_timeout 300s;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
7、啟動phpMyAdmin(使用的LNMP環(huán)境)
[root@localhost phpMyAdmin]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost phpMyAdmin]# nginx -s reload
8、訪問phpMyAdmin
瀏覽器訪問服務(wù)器IP+端口,如下圖
9、登錄phpMyAdmin,輸入用戶名和密碼,如下圖
10、激活高級功能完全設(shè)置
在phpMyAdmin的sql目錄下有個create_tables.sql文件。傳到本地計算機(jī)等待上傳
[root@localhost phpMyAdmin]# cd sql
[root@localhost sql]# ll
total 28
-rw-r--r-- 1 www www 10948 Mar 21 12:17 create_tables.sql
-rw-r--r-- 1 www www 1665 Mar 21 12:17 upgrade_column_info_4_3_0+.sql
-rw-r--r-- 1 www www 671 Mar 21 12:17 upgrade_tables_4_7_0+.sql
-rw-r--r-- 1 www www 5691 Mar 21 12:17 upgrade_tables_mysql_4_1_2+.sql
11、導(dǎo)入create_tables.sql文件
導(dǎo)入成功會生成phpmyadmin數(shù)據(jù)庫。
12、Mysql授權(quán)
進(jìn)入Mysql控制臺
mysql> grant all on phpmyadmin.* to admin@'127.0.0.1' identified by '12345678';
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
13、修改config.inc.php文件
[root@localhost sql]# cd ..
[root@localhost phpMyAdmin]# vim config.inc.php
/* User used to manipulate with storage */
$cfg['Servers'][$i]['controlhost'] = '127.0.0.1';
$cfg['Servers'][$i]['controlport'] = '3306';
$cfg['Servers'][$i]['controluser'] = 'admin';
$cfg['Servers'][$i]['controlpass'] = '12345678';
/*Storage database and tables */
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
$cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
$cfg['Servers'][$i]['relation'] = 'pma__relation';
$cfg['Servers'][$i]['table_info'] = 'pma__table_info';
$cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';
$cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';
$cfg['Servers'][$i]['column_info'] = 'pma__column_info';
$cfg['Servers'][$i]['history'] = 'pma__history';
$cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';
$cfg['Servers'][$i]['tracking'] = 'pma__tracking';
$cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
$cfg['Servers'][$i]['recent'] = 'pma__recent';
$cfg['Servers'][$i]['favorite'] = 'pma__favorite';
$cfg['Servers'][$i]['users'] = 'pma__users';
$cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
$cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
$cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches';
$cfg['Servers'][$i]['central_columns'] = 'pma__central_columns';
$cfg['Servers'][$i]['designer_settings'] = 'pma__designer_settings';
$cfg['Servers'][$i]['export_templates'] = 'pma__export_templates';
14、重啟phpmyadmin
[root@localhost phpMyAdmin]# nginx -s reload
15、訪問phpMyAdmin
瀏覽器訪問服務(wù)器IP+端口,如下圖