ubuntu下没有比较好用的Mysql的GUI客户端,所以安装了phpmyadmin,安装步骤如下:
sudo apt-get install -y phpmyadmin
这时在地址栏里输入http://localhost/phpmyadmin/回车,会发现浏览器一片空白,这时需要修改一些目录的权限,如下:
sudo chown -R www-data:www-data /etc/phpmyadmin/ sudo chown -R www-data:www-data /usr/share/phpmyadmin/ sudo chown -R www-data:www-data /var/lib/phpmyadmin/
注:www-data:www-data是apache的用户和组
phpmyadmin有三种认证方式config,cookie和http,在cookie和http都需要输入密码,config方式是把用户名和密码写入配置文件,登录时无需输入用户名和密码,直接就可以登录,config的认证方式适合本地phpmyadmin用。
下面是config方式认证的部分配置文件(config.inc.php):
$dbname = 'yourip'; /* Authentication type */ $cfg['Servers'][$i]['auth_type'] = 'config'; $cfg['Servers'][$i]['user'] = 'youruser'; $cfg['Servers'][$i]['password'] = 'yourpassword'; /* Server parameters */ $cfg['Servers'][$i]['host'] = $dbname; $cfg['Servers'][$i]['connect_type'] = 'tcp'; $cfg['Servers'][$i]['compress'] = false; /* Select mysqli if your server has it */ $cfg['Servers'][$i]['extension'] = 'mysql'; /* Optional: User for advanced features */ $cfg['Servers'][$i]['controluser'] = 'pma'; $cfg['Servers'][$i]['controlpass'] = 'pmapass'; /* Optional: Advanced phpMyAdmin features */ $cfg['Servers'][$i]['pmadb'] = $dbname; $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]['designer_coords'] = 'pma_designer_coords'; /* Uncomment the following to enable logging in to passwordless accounts, * after taking note of the associated security risks. */ $cfg['Servers'][$i]['AllowNoPassword'] = TRUE; $i++;
注:其中第四行和第五行,只用config认证方式时才有效。