Monday, July 2, 2007

Changing Passwords in MySQL

To set the root's password the first time:
$ mysqladmin -u root password NEWPASSWORD
To change the root's password:
$ mysqladmin -u root -p'OLDPASSWORD' password NEWPASSWORD
Or you can use the MySQL Client:
mysql> USE mysql;
mysql> UPDATE user SET PASSWORD=PASSWORD("NEWPASSWORD") WHERE User='root';
mysql> FLUSH PRIVILEGES;
To reset root's password, run mysqld_safe --skip-grant-tables:
$ /etc/init.d/mysqld stop
$ mysqld_safe --skip-grant-tables &
$ mysql -u root
mysql> UPDATE mysql.user SET PASSWORD=PASSWORD("NEWPASSWORD") WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> quit;

# Restart mysqld
$ /etc/init.d/mysqld stop
$ /etc/init.d/mysqld start

Sunday, June 3, 2007

How to make the 'less' command not clear screen after exit?

You can use the use option:
-X or --no-init

e.g. alias less='less -X'
If you want to use it long term, the PAGER is a useful variable to set in your .bashrc files:
export PAGER='less -X'
To make less exit if the content fits on one screen, use:
-F or --quit-if-one-screen

export ACK_PAGER='less -RFX'

Thursday, May 3, 2007

How to Stop ssh from Clearing Console on Exit?

It was not obvious but there is an explicit clear command in the logout script that clears the content of the terminal. This is what my .bash_logout file looks like:
# ~/.bash_logout

/usr/bin/clear
Commenting the line, /usr/bin/clear, will do the trick.