commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for:
There must be no space between -p and the password
Given a dump.sql file, extract table1 creation and data commands. table2 is the one following table1 in the dump file. You can also use the same idea to extract several consecutive tables.
You can put this into your shell sourced file like .bashrc or .zshrc to have a different mysql prompt.
See http://dev.mysql.com/doc/refman/5.1/de/mysql-commands.html for more informations.
Beware that currently with mysql 5.5 the seconds are buggy and won't be displayed if you put this into a .cnf file. With the enironment variable this will work.
Kills all the threads from the user provided in the WHERE request.
Can be refined through the SQL request, of course, see http://dev.mysql.com/doc/refman/5.1/en/processlist-table.html for the available columns.
Count the number of active connections to a MySQL database.
The MySQL command "show processlist" gives a list of all the active clients.
However, by using the processlist table, in the information_schema database, we can sort and count the results within MySQL.
This command will help you to find how many number of connection are made to given mysql and what are the different hosts connected to it with number of connection they are making.
Listens on local port 5500 and connects to remotehost with username user to tunnel the given socket file. Will work with anything, but can be useful if there's a need for a local application to connect with a remote server which was started without networking.
Create a secure tunnelled connection for access to a remote MySQL database.
For example, connect with MySQL Workbench to root@127.0.0.1:13306.
Finds all tables that need optimising and loops through them, running optimise against them. This works server-wide, on all databases and tables.
mtop allows you to monitor the operation of a MySQL application in real time. See, among the high, the number of queries performed per second, slower queries, the number of active processes.
To install on Ubuntu
sudo apt-get-y install mtop
This should probably only be used for testing in a dev environment as it's not terribly efficient, but if you're doing something that might trash a DB and you still want the old data available, this works like a charm.
-H suppress Headers
-I Inserts instead of csv
-R to give ; as the row delimeter.
Probably you can concatenate each line with a ; while importing to the db.
This will show the locations, in order of preference, that MySQL will look for a configuration file
This version compresses the data for transport.