Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Tuesday, December 17, 2013

How to reset mysql root password

Login to database with user root,
then select database mysql and update password field with no password.
$ mysql -u root -p
mysql> use mysql;
mysql> update user set password = '' where user = 'root';

or, you may delete the password only for localhost:
mysql> update user set password = '' where user = 'root' and host = 'localhost';

Wednesday, October 19, 2011

How to check mail queue in qmail?


# /var/qmail/bin/qmail-qstat 
# nice find /var/qmail/queue/mess/ -type f | xargs grep '^From: '  | awk '{print $2}' | sort | uniq -c | sort -n | tail
# nice -20 find /var/qmail/queue/mess/ -type f |xargs egrep '^From|^To' |sort -k1 |uniq |sort -k2 |uniq -c -f 1 |sort -n |tail

The watch Linux command line tool

This little utility executes a program repeatedly at a set interval and displays its output.

I've been using it with mysqladmin's processlist command like this: # watch -n 1 /usr/bin/mysqladmin -uroot -pMYPASSWORD processlist I 've been using with mysqladmin's processlist command for the Plesk installed server like this: # watch -n 1 /usr/bin/mysqladmin -uadmin -p`cat /etc/psa/.psa.shadow` processlist Note that this does put your password on display at the top of the command window whilst watch is running. If you don't want that, you could write a little bash script instead like this one: #!/bin/sh while : do sleep 1 clear mysqladmin -uroot -pMYPASSWORD processlist done Either way, we get a display of the MySQL process list every second in a Terminal window and it becomes very easy to see which processes are causing trouble.

Thursday, October 13, 2011

Find heavy processes in Linux

▽ CPU Usage rate descending order

# ps auxw | sort -k3 -nr

▽ Memory Usage rate descending order

# ps auxw | sort -k4 -nr

▽Memory Usage rate descending order

# ps auxww | less | sort -k4 -n

Friday, October 7, 2011

Debian Aptitude

1. aptitude update: Update the local cache of available packages (formerly apt-get update.
2. aptitude upgrade: Upgrade available packages (formerly apt-get upgrade).
3. aptitude dist-upgrade: Upgrade available packages even if it means removing stuff (formerly apt-get dist-upgrade).
4. aptitude install pkgname: Install package (formerly apt-get install).
5. aptitude remove pkgname: Uninstall package (formerly apt-get remove).
6. aptitude purge pkgname: Uninstall package and config files (formerly apt-get --purge remove).
7. aptitude search string: Search for a package with "string" in the name or description (formerly apt-cache search string).
8. aptitude show pkgname: Show detailed of a package (formerly apt-cache show pkgname).
9. aptitude clean: Delete downloaded package files (formerly apt-get clean).
10. aptitude autoclean: Delete only out-of-date package files but keep current ones (formerly apt-get autoclean).
11. aptitude hold pkgname: Fix a package at its current version and don't upgrade it automatically (formerly an obscure echo-to-file command). unhold to remove the hold.

Friday, September 16, 2011

MySQL connection from an external host

MySQL permits the connection from localhost by default. For permitting the connection from an external host, it needs to set up in the following procedure. Add account to the user table of Database mysql.

[root@4a-o01-b3 ~]# mysql -u root -p ※Loging to MySQL by root.
Enter password: ※response password

mysql> select user,host from mysql.user;
+------+--------------------------+
| user | host                     |
+------+--------------------------+
| root | 127.0.0.1                |
| root | example.com              |
| root | localhost                |
+------+--------------------------+



■The items of the above-mentioned setup are as follows.

root@127.0.0.1 - IP Address "127.0.0.1(Namely, a local host)"can be accessed by user root.

root@example.com - HOST "example.com(Here, this is also a local host. )"can be accessed by user root.

root@localhost - localhost "localhost(Namely, a local host)"can be accessed by user root.

Only connection from a localhost can be performed in this stage.
Run following command to permit the connection from an external host. (※Fo example, username "bogati"、The external host who connects"nepal.com"、DB to be used "test" is set up)。


mysql> show databases; ※ Check a list of the existing database.
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+

mysql> grant all privileges on test.* to bogati@"nepal.com" identified by 'password' with grant option;
Query OK, 0 rows affected (1.00 sec)

mysql> select * from user where user="bogati"\G ※ check of executed command.
*************************** 1. row ***************************
Host: nepal.com
User: bogati
Password: *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29

...................................................

■Moreover, to connect from all the hosts, a wild card is specified as follows.

mysql> grant all privileges on test.* to bogati@"%" identified by 'password' with grant option;
Query OK, 0 rows affected (0.00 sec)

mysql> select * from user where user="bogati" && host="%"\G ※ check of executed command.
*************************** 1. row ***************************
Host: %
User: bogati
Password: *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29

...................................................

■To connect from all the hosts of LAN set up as follows.

mysql> grant all privileges on test.* to bogati@"192.168.122.%" identified by 'password' with grant option;
Query OK, 0 rows affected (0.00 sec)

mysql> select * from user where user="bogati" && host="192.168.122.%"\G ※ check of executed command.
*************************** 1. row ***************************
Host: 192.168.122.%
User: bogati
Password: *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29


■To connect from an external host.

After setting up the permission from an external host.
check that whether login is actually possible from an external host or not.
Since it becomes conditions that MySQL is installed in an external host also , when there is no environment, it is necessary to install.

Now connect from nepal.com

[root@nepal.com]# mysql -h example.com -u bogati -p

After the execution of the above-mentioned command, if login is successful, it will be the completion of a setting.

Thanks

Sunday, March 6, 2011

Installing VMware tools on lenny

There is a better way installing ‘open-vm-tools’:

1. Adding ‘contrib’ and ‘non-free’ to ‘/etc/apt/sources.list’

deb http://ftp.gb.debian.org/debian/ lenny main contrib non-free
deb-src http://ftp.gb.debian.org/debian/ lenny main contrib non-free
deb http://security.debian.org/ lenny/updates main contrib non-free



# apt-get update
# apt-get install module-assistant open-vm-source open-vm-tools
# module-assistant prepare
# module-assistant build open-vm-source
# module-assistant install open-vm-source
# reboot

Install WordPress on Debian Lenny

First, update your DNS and point blog.example.com to the server.

# aptitude install mysql-server php5 wordpress



# chown :www-data /etc/wordpress/*
# mkdir /usr/share/wordpress/wp-content/uploads
# chown www-data:www-data /usr/share/wordpress/wp-content/uploads
# chown -R www-data:www-data /usr/share/wordpress/wp-content/themes


Create /etc/apache2/sites-available/blog file

ServerName blog.example.com
DocumentRoot /var/www/blog.example.com/

AllowOverride All
Order Deny,Allow
Allow from all


Run the following commands:

# a2ensite blog
# /etc/init.d/apache2 reload
# ln -s /usr/share/wordpress /var/www/blog.example.com
# cd /usr/share/doc/wordpress/examples
# sh setup-mysql -n blog blog.example.com


Now, access http://blog.example.com/ to continue the configuration of wordpress.

Wednesday, December 8, 2010

Add multiple email addresses to plesk server

■Create a list like below.

# vi list
01@example.com,test123
02@example.com,test123
03@example.com,test123
04@example.com,test123
05@example.com,test123
06@example.com,test123
07@example.com,test123
08@example.com,test123
09@example.com,test123
10@example.com,test123

■Create mail add script in the server.

# vi mailadd.sh
#!/bin/bash

for x in `cat list`;
do
MAIL=`echo $x | cut -d , -f 1`
PASS=`echo $x | cut -d , -f 2`
/usr/local/psa/bin/mail -c $MAIL -passwd $PASS -mailbox true
done

■Check the list of email id and password.

# vi mailchk.sh
#!/bin/bash


for x in `cat list`;
do
MAIL=`echo $x | cut -d , -f 1`
PASS=`echo $x | cut -d , -f 2`

expect -c "
set timeout 60
spawn telnet 0 110
expect \"+OK\" ; send \"USER $MAIL\r\"
expect \"+OK\" ; send \"PASS $PASS\r\"
expect \"+OK\" ; send \"QUIT\r\"
expect \"+OK\" ; send \"QUIT\r\"
"
done

If everything is ok run mailadd.sh . This is the very simple way to add more email id and password at once in Plesk server.

Saturday, November 13, 2010

Install fonts in CentOS

Nepali fonts

# yum install scim-tables.i386
# rpm -ivh http://mirror.centos.org/centos/5/os/i386/CentOS/m17n-db-nepali-1.3.3-48.el5.noarch.rpm
# rpm -ivh http://mirror.centos.org/centos/5/os/i386/CentOS/scim-tables-nepali-0.5.6-7.i386.rpm

Japanese fonts

# yum install "@Japanese Support"

Hindi fonts

# yum install "@Hindi Support"

Chinese fonts

# yum install "@Chinese Support"