//2016/05/24/
//by xbw///
/环境 centOS6.5 x64 xampp///
装了mysql每个图形界面感觉没底,xampp自带phpmyadmin,服务器那边没有图形界面,就算有访问也不是很方便,看服务器启动phpmyadmin的图形界面url是http://localhost/phpmyadmin,,那肯定http://服务器公网ip/phpmyadmin可以访问的,
但是访问受限制了,只能在本地访问;
Access forbidden!
You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.
If you think this is a server error, please contact the webmaster.
需要修改一下服务器端的配置,我们找到 /opt/lampp/etc/extra/httpd-xampp.conf文件,
# since XAMPP 1.4.3
<Directory "/opt/lampp/phpmyadmin">
AllowOverride AuthConfig Limit
Order allow,deny
Allow from all
Require all granted
#Require local
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</Directory>
<Directory "/opt/lampp/phpsqliteadmin">
AllowOverride AuthConfig Limit
Require local
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</Directory>
注释掉Require local;
添加
Order allow,deny
Allow from all
Require all granted
Allow from all
Require all granted
再访问一下就好了,但是问题又来了,
重新启动 /opt/lampp/lampp restart
MySQL Says: Cannot connect: invalid settings
初始化有问题,跟mysql的root账户的密码有关,找到/opt/lampp/phpmyadmin/config.inc.php文件,
我们发现password初始化那并没有东西,
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';//这里缺少数据库密码
/* Server parameters */
//$cfg['Servers'][$i]['host'] = 'localhost';
//$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = true;
没密码怎么进入数据库呢,加上刚才修改的mysql的密码试了一下,果然可以了,但是蒙逼了,不用账号密码就可以登录了,太危险了,我们发现 $cfg['Servers'][$i]['auth_type'] = 'config';从配置文件中读取用户密码信息的,我们需要换成cookie,就好了。。。
附上点mysql修改密码命令;
linux下进入xampp的mysql
--------------------------------------------------------------
[root@iZ28lh28mjgZ mysql]# cd /opt/lampp/bin/
[root@iZ28lh28mjgZ bin]# ./mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 10.1.13-MariaDB Source distribution
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
修改mysql的root用户密码
--------------------------------------------------------------------
MariaDB [(none)]> use mysql;
Database changed
MariaDB [mysql]> update user set password=password("******")where user='root';
Query OK, 3 rows affected (0.02 sec)
Rows matched: 3 Changed: 3 Warnings: 0
MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [mysql]> exit;
Bye