Log for Mysql console session

To log Mysql console session use option –tee (two dashes!) with full path to the log file:
mysql -uroot my_db --tee=/tmp/mysql_console.log
As result the file /tmp/mysql_console.log will contains all commands and queries with result of their executions. That might be helpful to keep your queries for using next time or for troubleshooting.

The author of the post, where I found that useful info, said that each time the Mysql session is started with logging the log file will be replaced. In my case it isn’t. As I expected the new messages just are appended to the log file.

VIM and Mysql integration

I use VIM with additional configuration instead of IDE. That configuration includes code explorer using ctag, syntax checking for PHP and Perl and run Perl scripts (syntax highlighting is not a subject of discussion ;)). Also I should run Mysql queries often. So, I decided to add integration with Mysql to VIM. I managed to do that thanks to that simple solution. Just add this code to your .vimrc:
to select database:
map <C-d> :call SwitchDB()<CR>
:function SwitchDB()
: let g:current_db = input("Database > ")
:endfunction

to run query:

map <C-m> :call Doquery()<CR>
:function Doquery()
: if !exists("g:current_db")
: call SwitchDB()
: endif
: let query_string = input(g:current_db . " > " )
: if query_string != ""
: exe "!mysql " . g:current_db . " -e \"" . escape(query_string, '"') . "\""
: endif
:endfunction

So, when you press Ctrl-d the VIM gives you a prompt to type database name, Ctrl-m will run query. Sure you can use the your preferable combinations of keys. Also you may extend the login functionality by adding prompt for database host and user or hardcoded that information in the SwitchDB() function.

Using VIM to construct queries in the Mysql shell even much easier. Just specify VIM as default editor:
export EDITOR=vim
After that type \e in the Mysql shell. It’ll bring you VIM window where you’ll able to type your query. To finish with editing just type ZZ as usual. To run built query type ; and press Enter.

As result we’ll have possibility to run Mysql queries directly from VIM and using VIM to create queries in the Mysql shell.

GooSync goes to 100% commercial

Logo

I’ve used GooSync to sync my Google Calendar with calendar on my Nokia E65 for couple years. It covers all my unassuming needs. But recently I received a notification from GooSync that they discontinue free version of their service. As an option for all free users they offer version Lite for €7 per year. Well it isn’t so big money to help the good and useful service improve its quality or just survive.

Amazon announced international version of Kindle!

Amazon-Kindle-2-Pictures

Good news for all ebook and Kindle fans who live outside US. Amazon decided to sell its Kindle for the rest world. Its price is very attractive – $279 (about €190) plus shipping. Personally I like Kindle. In my opinion its design is perfect. The rest ebook readers look not so nice but they provide more wide functionality such support Russian language or FB2 book format.

In any case, the possibility to buy Kindle officially outside US sounds very good. Will wait a bit till it’ll support Russian language and then will buy it.

Additional mysql server UTF8 confutation

I spent a few day with patching LinuxMCE database connection to pass UTF8 option to the server. But without luck. However I found a way to configure mysql server to skip client’s request about charset and send all data in the defined one. To do that just add following lines in the my.cnf file under mysqld section:
[mysqld]
init_connect='SET NAMES utf8; SET collation_connection = utf8_general_ci;'
default-character-set=utf8
character-set-server=utf8
collation-server=utf8_general_ci
skip-character-set-client-handshake

The option init_connect replaces setting ‘SET NAMES utf8’ from the client and skip-character-set-client-handshake tells to server to ignore charset sent by client and use it default one instead.

I tested this approach with LinuxMCE and it works. The Russian text is displayed on the Orbiter correctly. I tested it with Perl as well and found that Perl script still should set option mysql_enable_utf8 to true.

[via Saiweb]

Traffic jams map with camera view from Yandex

logo
Russian company Yandex which offers a lot of useful services and has Google’s vision of the web business (IMHO) recently announced Moscow map map with traffic jams and live cameras view! That’s really cool service and I didn’t see anything similar before. Additionally there are panoramic views. Similar as Google has.

I’m waiting when the live cameras will be added for St. Petersburg. Or at least panoramic views. Sometimes I’m missing it.