Blog Archives

How to change the login shell for Linux user

Display list of shell Code: less /etc/shells cat /etc/shells more /etc/shells Change the user login shell to /bin/ksh for foo user Code: chsh -s /bin/ksh foo chsh -s /bin/bash username

Posted in MySQL

SSH login without password

Your aim You want to use Linux and OpenSSH to automize your tasks. Therefore you need an automatic login from host A / user a to Host B / user b. You don’t want to enter any passwords, because you want to

Posted in MySQL

Move column in MySQL

Move a column after some other column ALTER TABLE users  MODIFY COLUMN username char(50) AFTER account_type; Move a column to the first position ALTER TABLE users MODIFY COLUMN id INT FIRST;

Posted in MySQL

Crontab — You have new mail in /var/spool/mail/root

This is a basic one, but something that is important. Have you ever added something to the crontab, and every time it runs it adds an entry in  /var/spool/mail/root? That is because STDOUT is writing it to the spool. to prevent this

Posted in MySQL

How to see whats running in PostgreSQL

If you’re familiar with SHOW PROCESSLIST in MySQL and you want a similar response try this in PostgreSQL: select * from pg_stat_activity; or in bash: ps -ef | grep postgres And here is another thing I do: ssh user@server  ’ps

Posted in MySQL

Forgot root password? Reset it (MySQL)

If you need to get into MySQL but don’t have a password all you need is linux root or sudo. Here are the steps. sudo vi /etc/my.cnf   or sudo vi /etc/mysql/my.cnf add this:  skip_grant_tables under [mysqld] sudo /etc/init.d/mysqld restart mysql

Posted in Linux, MySQL, SQL

Where are all the MySQL(and postgresql) servers?

What if you are new to a network, and want to look smart? One way to do that is to know the network before someone tells you. It is also good to know if there are rouge servers out there

Posted in Linux, MySQL

Move database files from one server to another

I like to use scp to transfer files of a database from one box to another, then follow-up with an rsync. this is how I do it: sudo rsync -avz /source/path/* user@boxname:/destination/path/ Lets break it down:   -a, or –archive

Posted in Linux, MySQL, SQL

nodiratime AND noatime?

I once saw a recommendation to mount using nodiratime AND noatime like this: mount -t xfs /dev/md0 /mysql_data -o nobarrier,noatime,nodiratime But then I looked into it further and found this: http://lwn.net/Articles/245002/   that suggested that noatime includes nodiratime ” void touch_atime(struct vfsmount

Posted in Linux, MySQL

Linux performance tuning for MySQL – vm.swappiness

TO CHECK YOUR SWAPPINESS: sysctl -a |grep ‘swappiness’   FOR MySQL SSD or FLASH drives do THIS: sysctl -w vm.swappiness=0    (it is a percent)   FOR web servers swappiness can be set higher. For a mixed or single box

Posted in MySQL