Recently Todd Farmer shared an interesting story about the mysql command line prompt in MySQL 5.7: how it was changed to provide more context and why the change was finally reverted. This made me think that after using the command line client for MongoDB for awhile, I would love seeing a much more modern mysql shell prompt. Here are a few examples of what a modern command line client can do.
Add dynamic information to the prompt
If you use replication with MongoDB, you have probably noticed a nice feature of the prompt: it is replication aware. What I mean is that for a standalone instance, the prompt is simply:
>
When you configure this instance to be the primary of a replica set named RS, the prompt automatically becomes:
RS:PRIMARY>
and for secondaries, you will see:
RS:SECONDARY>
And of course if an election is triggered and roles are switched, the prompt is updated accordingly to reflect the change.
Such a feature may not be easily transposed to MySQL as the allowed replication topologies are more flexible: for instance with master-master replication or for chained replication, some servers may be both a master and a slave.
However if you look a bit deeper how the MongoDB shell prompt can be customized, it is very flexible as you can set the prompt variable to the result of any Javascript function. So for instance if you write this:
var prompt=function() {
return db.getName()+"/"+ISODate().toLocaleTimeString()+"> ";
}
Your prompt will be changed to something like:
test/11:37:51>
And the change can be persisted by defining the prompt variable in a ~/.mongorc.js file.
If I could do something similar with MySQL, I would for instance be able to know the replication lag of a slave or the uptime of MySQL and so on and so forth. That would be incredibly useful in some situations.
Better help system
Let’s assume I want to manually fail over to a secondary in a MongoDB replica set. I can simply instruct the master that it should no longer be the master. But what is the exact command?
I know that it is rs.xxx because all replica sets functions have this format, so let’s simply open the shell and type rs. and all the available options show up:
> rs. rs.add( rs.constructor rs.propertyIsEnumerable( rs.syncFrom( rs.addArb( rs.debug rs.prototype rs.toLocaleString( rs.apply( rs.freeze( rs.reconfig( rs.toString( rs.bind( rs.hasOwnProperty( rs.remove( rs.valueOf( rs.call( rs.help( rs.slaveOk( rs.conf( rs.initiate( rs.status( rs.config( rs.isMaster( rs.stepDown(
Here again, I’d love to see something similar with MySQL. For instance each time I need to convert a timestamp to a human readable date, I have to look at the documentation to find the exact function name.
Actually I could have used the built-in help system to find the name of the function, but it is much more convenient to look at the documentation.
Conclusion
What’s your opinion on which new features a modern mysql shell should provide? If many people agree on a set of features, it could be worth filing a feature request to get a better mysql command line client in a future version of MySQL.
The post MySQL shell prompt vs MongoDB shell prompt appeared first on MySQL Performance Blog.
Microsoft today announced that it will consolidate its Visual Studio Premium and Ultimate offerings for enterprises into a single product once it launches Visual Studio 2015 later this year. Now called Visual Studio Enterprise With MSDN, this new version will include all of the features developers were getting with Visual Studio Ultimate (IntelliTrace in production, CodeLens support, etc.).
Data analysis often involves looking at a large set of pretty uniform, well-structured data. But as companies continue to gather more electronic documents in all kinds of forms (and formats), those traditional techniques don’t work anymore. Companies like Palantir and IBM (with Watson) are now making it easier for data scientists and technical users to query unstructured textual…
Google is launching an update to Drive for Work and Drive for Education today that introduces a number of new tools for users who need to have greater control over how their data is shared both internally and with external customers. Over the next few weeks, both Google Drive for Work and Google Drive for Education users will get access to these new tool. 
Given the world’s shift toward video, both in terms of consumption and creation, it’s almost surprising how tedious and painstaking the process of post-production collaboration can be. Lots of services focus on pieces of the problem, like accelerated file sharing or review in-progress collaboration, but there isn’t really a service that covers everything, end-to-end.…
DroneDeploy is on a mission to make drones accessible to industrial users who have a business need for conducting outdoor landscape mapping and monitoring. So, in other words, it wants drones to be put to work by people other than enthusiastic dorks with a gadget habit — doing tasks like helping farmers spot crop damage and disease.
India’s Snapdeal has been on an acquisition spree in the last several months, tapping into the $1.1 billion it has raised from the likes of Softbank to expand from being a marketplace for goods into a platform for all kinds of online transactions. The latest chapter in this story is today’s news that it has acquired a majority stake in RupeePower, a provider of loans and credit…
IBM is wasting little time when it comes to the Internet of Things. The company outlined a major Internet of Things strategy tonight with a series of announcements that included a $3B investment to establish an Internet of Things unit inside of Big Blue along with a partnership with The Weather Company.
Enterprise mobile applications – like enterprise cloud applications a decade before – are poised to become a $100 billion market opportunity. I’ve worked with enterprise technologies exclusively for more than a decade and have watched as cloud apps took the enterprise by storm, giving businesses more flexibility and power than ever before. Now, enterprise mobile is taking a…