如何在 PHPMyAdmin 中设置表的默认排序(即始终“主键 - 降序”)
尽管它在很多方面令人讨厌,但我在编写 PHP 时一直使用 PHPMyAdmin 来调试数据库问题。默认情况下,它按主键升序对表进行排序。 99% 的情况下,我宁愿默认将最新数据(我的测试数据)显示在顶部,而不是保存的无用的前几条记录。
有没有办法配置 PHPMyAdmin 默认显示最新记录?改变类似的行为?
Even though its obnoxious in a lot of ways I use PHPMyAdmin all the time to debug database issues while writing PHP. By default it sorts tables by primary key ascending. 99% of the time I would rather have the newest data (my test data) shown at the top by default rather than the useless first few records ever saved.
Is there a way to configure PHPMyAdmin to show the newest records by default? To alter similar behavior?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
对于来这里寻找答案的其他人:
在 phpMyAdmin 4.5.0 中,也许在早期版本中,您可以设置 $cfg['TablePrimaryKeyOrder'] 配置如下:
如果表具有主键并且未对其应用其他排序,则这将设置默认排序。
For anyone else who comes here looking for an answer:
In phpMyAdmin 4.5.0, maybe in earlier versions too, you can set the $cfg['TablePrimaryKeyOrder'] config like so:
This sets the default sort if the table has a primary key and that no other sort has been applied to it.
您可以使用您正在浏览的表的名称保存私人书签。
请参阅https://phpmyadmin.readthedocs.org/en/latest/faq.html#bookmarks-can-i-execute-a-default-bookmark-automatically-when-entering-browse-表格模式
You can save a private bookmark with the name of the table you're browsing.
See https://phpmyadmin.readthedocs.org/en/latest/faq.html#bookmarks-can-i-execute-a-default-bookmark-automatically-when-entering-browse-mode-for-a-table
@jeremyclarke,在 phpMyAdmin v3.4.5 中,登录后单击“主页”
然后,
从“更多”菜单中选择“设置”
单击“主框架”选项卡,然后单击“浏览模式”选项卡
,您会发现“默认排序顺序”,默认模式设置为 SMART
因此,选择“ASC”或“DESC”
如果执行上述步骤,它将保存当前会话,
永久保存将其设置在config.php中
http://wiki.phpmyadmin.net/pma/Config#Order
@jeremyclarke, in phpMyAdmin v3.4.5, after login click "home"
then,
from "More" menu choose "Settings"
click "Main frame" tab, then "Browse mode" tab
There you'll find "Default sorting order" the default mode is set to SMART
hence, choose "ASC" or "DESC"
If you do the above steps, it will be saved for the current session,
to save it permanently set it in config.php
http://wiki.phpmyadmin.net/pma/Config#Order
我认为你可以做到这一点。去一张桌子->操作并按降序设置更改表顺序。
下次您浏览时,您首先会看到最新的行。
i think you can do this. Go to a table -> operations and set alter table order by descending.
Next time when ever you browse you get the newest row first.
phpMyAdmin 默认情况下根本不执行任何排序。它只是询问表中的所有记录,然后由 MySQL 决定顺序。
没有办法做到这一点,因为 phpMyAdmin 必须了解每个表的每个主键(假设有一个,并且只有一个)以及如何对其进行排序。
phpMyAdmin 支持书签查询。您可以 DESC 然后为其添加书签。但是,如果您的目标是减少点击次数,它肯定不会减少点击次数。
http://www.phpmyadmin.net/documentation/
phpMyAdmin isn't performing any sorting at all by default. It's simply asking for all records in a table and MySQL is deciding the order.
There's no way to do this as phpMyAdmin would have to be informed about every primary key of every table (assuming there is one, and only one) and how to sort it.
phpMyAdmin does support bookmarking queries. You could DESC and then bookmark that. However, it certainly won't minimize the number of clicks, if that's what you're aim is.
http://www.phpmyadmin.net/documentation/
为什么不使用 heidi SQL
以下是有关如何操作的指南:
启用从主机登录。
首先,获取您的 IP 地址 - http://www.whatismyip.com
希望这是一个静态 IP,否则您将有一些不太安全的选项(如下)
您将需要访问权限才能在数据库上创建用户。您可以通过 Cpanel 或 PHP My Admin 来执行此操作(假设您具有正确的访问级别)。如果您不确定,请谷歌获取说明。如果失败,您可以尝试运行此查询:
如果您没有静态 IP 地址,那么您可以考虑使用通配符,尽管这不太安全。另一个更安全的选项是 SSH 隧道
下载并安装 Heidi SQL
http://www.heidisql.com/download.php
运行安装(当然在 Windows 上)
最后,设置连接,连接。
您会发现 heidi 允许您轻松地对数据列表进行排序,http://www .heidisql.com/screenshots.php?which=data
它还会记住排序和过滤器。
Why don't you use heidi SQL
Here's a guide on how:
Enable login from your host pc.
First of all, get your IP Address - http://www.whatismyip.com
Hopefully that's a static IP, otherwise you have some less secure options (below)
You'll need access to create a user on the database. You can do this through Cpanel, or in PHP My Admin (assuming you have the right level of access). Google for instructions if you are unsure. Fail that you can attemtp to run this query:
If you don't have a static IP Address then you can consider using a wildcard, although this is less secure. Another more secure option is SSH tunneling
Download and install Heidi SQL
http://www.heidisql.com/download.php
Run the install (on windows ofcourse)
Finally, setup your connection, connect.
You'll find that heidi allows you to easily sort the listing of data, http://www.heidisql.com/screenshots.php?which=data
It also remembers sorts and filters too.
只需将此行添加到您的 PHPMyAdmin 配置文件中即可。
在大多数 PHPMyAdmin 版本中,配置文件是 config.inc.php
Just add this line to your PHPMyAdmin configuration file.
in most of PHPMyAdmin versions, the configuration file will be config.inc.php
我使用的是 phpMyAdmin 版本 4.2.3(英文),我只是更新了位于 Libraries 目录中的 DatabaseInterface.class.php 文件中第 488 行的排序顺序变量。行号(也可能是文件)在其他版本中可能会有所不同。
当我打开文件时,变量 $sort_order 等于“ASC”。自从将其更改为 DESC 并通过 FTP 上传后,我的表的排序顺序(在日期 (DATETIME) 上唯一键入)始终为 DESC(首先是最近添加的记录)。
不确定这是否是所有情况的最佳解决方案,但是 满足我的需要。
希望这能
I'm using phpMyAdmin version 4.2.3 (English) and I simply updated the sort order variable on line 488 in the DatabaseInterface.class.php file which resides in the Libraries directory. The line number (and possibly the file) may vary in other versions.
The variable $sort_order was equal to 'ASC' when I opened the file. Since changing it to DESC and uploading via FTP, the sort order for my table (which is uniquely keyed on date (DATETIME) is always DESC (most recently added records first).
Not sure if this is the best solution for all cases, but it suits my needs.
Hopefully this helps.
以上答案都不适合我,我使用的是 PHPMyAdmin 5.2.0
您可以编辑 PHPMyAdmin 的以下文件并将排序顺序设置为 DESC
文件路径:
/usr/share/phpmyadmin/库/类/Config/Settings.php
函数:
setTablePrimaryKeyOrder()
只需在
setTablePrimaryKeyOrder()
函数的开头设置如下设置变量即可。你就可以走了!
None of the above answer work for me, I am using PHPMyAdmin 5.2.0
You can edit the below file for PHPMyAdmin and set the sort order as DESC
Filepath:
/usr/share/phpmyadmin/libraries/classes/Config/Settings.php
function:
setTablePrimaryKeyOrder()
Just set the setting variables as below at the start of the
setTablePrimaryKeyOrder()
function.and you're good to GO!!