我在该用户下添加了一个用户,但是当我用该用户登录时,我可以查看所有数据库。一个用户如何只查看分配给它的自己的数据库
答案 0 :(得分:0)
e.g。
$cfg['blowfish_secret'] = 'UltraSecretPassphrase';
通过http:/// phpmyadmin /访问,并使用MySQL root用户名和密码登录。
单击右侧窗格中的SQL选项卡,在标记为“运行SQL查询/查询”服务器“localhost”的文本框中粘贴以下SQL语句并将pmapassword更改为更安全的内容。然后单击“转到”按钮。
CREATE USER 'pma'@'localhost' IDENTIFIED BY 'pmapassword';
GRANT USAGE ON mysql.* TO 'pma'@'localhost' IDENTIFIED BY 'pmapassword';
GRANT SELECT (Host, User, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv, File_priv, Grant_priv, References_priv, Index_priv, Alter_priv, Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv, Execute_priv, Repl_slave_priv, Repl_client_priv) ON mysql.user TO 'pma'@'localhost';
GRANT SELECT ON mysql.db TO 'pma'@'localhost';
GRANT SELECT ON mysql.host TO 'pma'@'localhost';
GRANT SELECT (Host, Db, User, Table_name, Table_priv, Column_priv) ON mysql.tables_priv TO 'pma'@'localhost';
GRANT SELECT (Host, User, Select_priv, Insert_priv, Update_priv, Delete_priv,
Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv, File_priv, Grant_priv, References_priv, Index_priv, Alter_priv, Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv, Execute_priv, Repl_slave_priv, Repl_client_priv) ON mysql.user TO 'pma'@'localhost';
GRANT SELECT ON mysql.db TO 'pma'@'localhost';
GRANT SELECT ON mysql.host TO 'pma'@'localhost';
GRANT SELECT (Host, Db, User, Table_name, Table_priv, Column_priv) ON mysql.tables_priv TO 'pma'@'localhost';
现在我们需要修改phpMyAdmin的配置以支持多个唯一用户。 再次使用您喜欢的编辑器编辑/usr/share/phpmyadmin/config.inc.php并完成以下更改。
删除这2行前面的//并填写上面选择的密码
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = 'pmapassword';
在
上面的行之后添加以下行 $cfg['Servers'][$i]['hide_db'] = 'information_schema';
在结尾之前添加以下行?>
$cfg['AllowUserDropDatabase'] = true;
将服务器扩展行从mysql更改为mysqli
$cfg['Servers'][$i]['extension'] = 'mysqli';