Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Linux Ask!

Sep 042010
 

Yum repository mirror for old CentOS' versions

Answer:

Most CentOS' mirrors don't host full mirror of Yum repository for all versions of CentOS. If you are using older version of CentOS, you might one-day found the yum update is broken since the mirror no longer contains the files you needed.

In this case, you can modify the file /etc/yum.repos.d/CentOS-Base.repo and change all paths point to the following:

..
baseurl=http://vault.centos.org/...
..

Then do a yum update to reflect the changes.

Sep 022010
 

Simple try catch block in Perl

Answer:

Perl don't have try/catch statement by default, but you can simulate using the following way:

eval {
    print 1/0;
};

if ($@) {
    print "Error message: $@";
};

When executed, it shows:

Error message: Illegal division by zero at test.pl line 7.

Sep 012010
 

Can't connect to local MySQL server through socket

Answer:

Sometimes when you type the mysql command, it shows:

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

The cause of this problem is the MySQL socket file is not in the default location, e.g. /tmp/mysql.sock

To fix, edit the MySQL configurations, e.g. /etc/my.cnf, add the following lines

[client]
socket=/tmp/mysql.sock