通过使用*nix命令行shell,我可以方便地为常用命令创建别名。我想对MySQL客户端做一些类似的事情。我经常运行的一个常见的例子是:
select option_value from wp_options where option_name = 'home' or option_name = 'siteurl';是否有办法这样做,这样我就把"siteurl“命名为”siteurl“,并由此产生上述结果吗?
是的,我大致熟悉存储过程和函数,尽管我不知道如何对实例进行全局使用。
发布于 2013-11-28 13:46:04
在bash中,尝试将其添加到.bashrc中(使用数据库访问信息执行适当的替换):
alias siteurl='mysql -u<youruser> -p<yourpassword> <yourdatabase> -e "select option_value from wp_options where option_name = 'home' or option_name = 'siteurl';"在此之后,您将打开的每个shell都有可用的命令(别名) siteurl,它将输出该查询的结果。
https://stackoverflow.com/questions/20267712
复制相似问题