Restore MySQL config file

I have installed mysql-server on my laptop running Debian back in awhile. For that reason, I forgot the root password. Just recently, I need to use MySQL server for one of my assignments. So, I was playing around in /etc/mysql/ directory hoping that I could get rid of the server and then reinstall it. The commands apt-get remove mysql-server didn’t seem to remove files/directories related to MySQL. Then, I decided to delete the /etc/mysql/ manually.

After I reinstalled mysql-server, a few config files ,contained in /etc/mysql direcotry, were never reinstalled. As always, I turned to Google for helps. With a few different combination of keywords, I found a solution to problem.

First, let’s completely remove mysql-server:

$ sudo apt-get remove --purge mysql-common
$ sudo apt-get remove mysql-server

Then reinstall mysql-server again:

$ sudo apt-get install mysql-common mysql-server

This time, I carefully chose a root password which was easy enough to remember. And voilla, it worked!

$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.0.45-Debian_1-log Debian etch distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.


Tomcat 6 on Debian Lenny

I need to install Tomcat 6 for a school assignment. I thought the installation process was easy as counting 123, but it turned out to be a few hours long of head scratching. Well, the first start is to setup a few environment variables as required by Tomcat:

export CATALINA_BASE# JAVA_HOME and Path to java, javac
export JAVA_HOME;
export PATH=${JAVA_HOME}/bin:${PATH}:.

It can be stored in a file, and run with source to load those variables.

Then when I tried to run Tomcat with the following command, there was some error with the BASEDIR:

kenno@kampongcham:~$ $CATALINA_HOME/bin/
The BASEDIR environment variable is not defined correctly
This environment variable is needed to run this program

I wasted a few hours trying to search for solutions on Google, and as when I was about to temporarily give up for dinner, I found an unexpected answer from one of the blogs.

“I need to set all the shell scripts in $CATALINA_HOME/bin to be executable”

So let’s fix it:

kenno@kampongcham:~$ cd $CATALINA_HOME/bin
kenno@kampongcham:~/bin/apache-tomcat-6.0.13/bin$ chmod +x *.sh

Finally, it’s done. We can now run tomcat without any errors:

kenno@kampongcham:~/bin/apache-tomcat-6.0.13/bin$ ./
Using CATALINA_BASE:   /home/kenno/bin/apache-tomcat-6.0.13
Using CATALINA_HOME:   /home/kenno/bin/apache-tomcat-6.0.13
Using CATALINA_TMPDIR: /home/kenno/bin/apache-tomcat-6.0.13/temp
Using JRE_HOME:       /usr/lib/j2sdk1.6-sun/bin

That’s it folks. When you setup Tomcat on your machine, make sure you specify the correct path to all the variables mentioned above.

Thanks to Michael for the solution: Tomcat 6 on OSX

Bash Command Shortcuts

How many times do you find yourself using arrow keys to scroll to the beginning or the end of line of the command line in bash terminal? Do you use backspace to delete every character of what you type to clear the command line? Well, if you answer “yes” to any of the two questions, continue reading.

I, myself, have been doing this a lot because I couldn’t remember the shortcut keys to do those tasks. So, I decided to write them here as a reference that could be referred to in the future. You can easily find the same or even thorough information on the web.

Useful Shortcut Keys
Key sequence What it does
Ctrl + U Delete to the end of line
Alt + D Delete to the end of current word
Alt + Backspace Delete to the start of current word
Ctrl + A Move to the start of line
Ctrl + E Move to the end of line
Ctrl + Left Arrow Move one word to the left
Ctrl + Left Arrow Move one word to the right

I hope those shortcuts could save you some time and the fingers from getting sore.