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.
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>
: let g:current_db = input("Database > ")
to run query:
map <C-m> :call Doquery()<CR>
: if !exists("g:current_db")
: call SwitchDB()
: let query_string = input(g:current_db . " > " )
: if query_string != ""
: exe "!mysql " . g:current_db . " -e \"" . escape(query_string, '"') . "\""
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:
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.
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:
init_connect='SET NAMES utf8; SET collation_connection = utf8_general_ci;'
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.
I was very surprised how pure the Oracle’s command line utility SQL*Plus. Comparing with mysql it lack history, completion and doesn’t allow even edit query. To fix that the utility rlwrap can be used. I installed it via yum under Fedora 11 and run like that:
rlwrap sqlplus db_user@db
To have auto-complete feature you should find file SQL.dict somewhere (drop the comment, please, if you know the place). It contains SQL keywords, functions and commands. The command to run SQL*Plus will be following in that case:
rlwrap -b "" -f $HOME/sql.dict sqlplus db_user@db
To make our life easier we can create an alias in the .bash_profile or .profile:
alias mysqlplus='rlwrap -b "" -f $HOME/sql.dict sqlplus'
There is an another interesting improvement for Linux users – using VIM as default editor of SQL*Plus. I didn’t try it practically yet.
[via Oracle Online]
I did it a few times but always made a search and dug WordPress code. So, just generate a new password:
PHP -r 'echo crypt("new_wp_pass") . "\n";'
and update specified user in the table wp_users:
UPDATE wp_users SET user_pass='generated password hash' where ID='desire user ID';
You may need to remove subversion stuff from some sources to add them onto another repository. Following bash command can do it assuming you’re in the root directory of the sources:
for FILE in
find | grep ".svn"; do if [ -d $FILE ]; then echo "file: $FILE"; rm -rf $FILE; fi; done
The next generation of Nokia Internet Tablet will sport 3G HSPA, a TI OMAP3 processor, OpenGL graphics accelerator, and will run Maemo 5 OS the first release of which SDK was done recently. Supporting of 3G network will give more choices for people to stay online.
[via The Nokia Blog]
When I tried KDE 4.0 first time a few monthes ago I was very disappointed. The system was absolutely unusable. Mainly it was the reason why I didn’t upgrade my Fedora to version 9. But after 10 was released I decided to make an upgrade. I thought that KDE 4.1 should be better. It’s really better but to setup my accustomed environment I spent two days including GNOME configuration because I couldn’t work in KDE. So, I decided to write that post to share my experience and use it my myself what I’ll setup another PC.
Continue reading KDE 4.1 useful tips and tricks