how to recover mysql root password

Follow three easy steps  to recover mysql root password.
 
irst of all stop mysqld service

#service mysqld stop or /etc/init.d/mysqld stop

start with skip grant table option

#mysqld_safe –skip-grant-tables &

now login with root without any password

# mysql -u root

here you got it!
now for own safety change mysql root password

mysql> set password=PASSWORD(‘yourpasswd’);
mysql> flush privileges;

now stop mysql service and start it again 

How to repair corrupted mysql databases

Solution :1

Login to server with root access

Stop mysql using following command

/etc/init.d/mysql stop

Run following command to check all the tables in the database

Run following command to check all the tables in teh database

/usr/bin/myisamchk /var/lib/mysql/databasename/*.MYI

Run following command to repair all the tables in the database

/usr/bin/myisamchk -r /var/lib/mysql/databasename/*.MYI

Then recheck again using following command

/usr/bin/myisamchk /var/lib/mysql/databasename/*.MYI

Restrart MySql service using following command

/etc/init.d/mysql restart

Solution : 2

If you want repair DB using myisamchk, you need to shutdown MySQL service before proceeding otherwise it will corrupt some other databases.

Alternatively, if you do not want to shut down MySQL, you can use mysqlcheck. 

mysqlcheck [DBNAME]

To repair the database tables: 

mysqlcheck -r [DBNAME]

also we can use the commands

mysqlcheck -u{username} -p{password}  –check –optimize –auto-repair –all-databases

Disk Space Commands on Linux

Show files by size, biggest last:

ls -lSr

Show top disk users in current dir.

du -s * | sort -k1,1rn | head

Show free space on mounted filesystems

df -h

Show free inodes on mounted filesystems

df -i

Show disks partitions sizes and types

fdisk -l

List all packages by installed size (Bytes) on rpm distros

rpm -q -a –qf ‘%10{SIZE}\t%{NAME}\n’ | sort -k1,1n

SOME OPEN VZ COMMANDS AND CONFIGURATION FILES

Following are some important commands which are normally used while working on a Hardware Node. 

1) vzlist -a : Shows list of all the VPS’s hosted on the Node.
2) vzctl start VPS_ID: To start the VPS.
3) vzctl stop VPS_ID : To stop (Shut Down) the VPS
4) vzctl status VPS_ID : To view the status of the particular VPS
5) vzctl stop VPS_ID –fast : to stop the VPS quickly and forcefully
6) vzctl enter VPS_ID : To enter in a particular VPS
Configuration Commands
1) vzctl set VPS_ID –hostname vps.domain.com –save: To set the Hostname of a VPS.
2) vzctl set VPS_ID –ipadd 1.2.3.4 –save : To add a new IP to the hosting VPS.
3) vzctl set VPS_ID –ipdel 1.2.3.4 –save : To delete the IP from VPS.
4) vzctl set VPS_ID –userpasswd root:new_password –save : to reset root password of a VPS.
5) vzctl set VPS_ID –nameserver 1.2.3.4 –save : To add the nameserver IP’s to the VPS.
6) vzctl exec VPS_ID command : To run any command on a VPS from Node.
7) vzyum VPS_ID install package_name : To install any package/Software on a VPS from Node.
Here VPS_ID refers to the ID of the Particular VPS.
 8)vzctl destroy VPS_ID-To destroy particular vps
 9)vzcalc -v VPS_ID-To show resources used by a VPS
 10)vzcpucheck-To check CPU usage by OpenVZ
 11)vzcpucheck -v-To get CPU usage per VPS
 12)vzctl exec 103 df-to Execute commands inside particular vps container.

Default Locations

  1. /vz - Main directory for OpenVZ.
  2. /vz/private - Each VPS is stored here i.e. container’s private directories
  3. /vz/template/cache - You must download and store each Linux distribution template here.
  4. /etc/vz/ - OpenVZ configuration directory.
  5. /etc/vz/vz.conf - Main OpenVZ configuration file.
  6. /etc/vz/conf - Softlinked directory for each VPS configuration.
  7. Network port - No network ports are opened by OpenVZ kernel.

Configuring Nameservers at registrar end

Setup nameservers at different registrars;

Fabulous.com

1) Click on manage -> nameservers > and then “create nameserver” at the very bottom of the page under “Nameserver Edit.”
2) FQDN is ns1 followed by your domain registered at fabulous, followed by its IP address. Click “continue” and repeat for ns2.

Enom.com

login
Click on Registered Domains
Click on the domain name in question
Click on DNS Server Settings
Enter in your DNS Servers here then click save and you are DONE!!!!

domains >> advanced tools >> register a nameserver

http://www.enom.com/domains/RegNameServer.asp

Register a NameServer Name
Note: The domain name must be in
the customer’s account.
(Example: To register NS1.myname.com,
the domain name myname.com
must be registered to you at eNom.)

Update a NameServer IP
Note: The domain name must be in
the customer’s account.

Delete a NameServer
Note: The domain name must be in
the customer’s account.
If there are any domains using this nameserver
the deletion process will fail

1&1

1. Login to your account
2. Click Manage Your Domains
3. Check the domain you want to edit
4. At the top of the list, hit arrow next to DNS, then Edit DNS Settings
5. In the drop down box, hit My Name Server
6. Fill in your custom nameservers

A Small Orange

If you registered your domain through A Small Orange, you’ll need to login to the customer/billing area at https://customers.asmallorange.com.
1. Select My Sites -> Domains
2. Select the Domain from the list on the left by clicking on the link.
3. Select Register Nameserver on the left and enter the ns1.example.com and the IP address. Click Submit
4. Repeat for ns2.example.com
5. Select Change DNS from the menu list on the left.
6. Enter ns1.example.com and ns2.example.com
7. Done!

DirectNIC

1. Login to your account.
2. Click Domain Manager
3. To the right of the domain name, there are three icons: a telephone, and computer and a house (I think). Click the computer (middle icon).
4. Before you enter the Nameservers, you need to click on the link above for “Create Nameserver”.
5. create the ns1 and ns2 with your IP addresses.
6. When you’re done, go back to Domain Manager and select the computer icon next the your domain again.
7. Enter the nameservers you just created and click Modify.

DomainSite

1. Login to your account
2. Select Manage Registered Domain Names.
3. Click on the domain name you wish to add nameservers for.
4. Select Register a Name Server.
5. Type ns1 in the Host Name box
6. Enter the ns1 IP.
7. Click continue.
8. Click Register.
9. Click Continue managing
10. Select Register a Name Server.
11. Enter ns2 in the hostname box.
12. Enter the ns2 ip in the IP Address box.
13. Click continue.
14. Click Register.
15. Change your nameservers to the ones you’ve just created.

GoDaddy

1. Login to your GoDaddy Account.
2. Click on My Account
3. Click on Manage Domains
4. Click on the domain name you want to modify.
5. In the lower left corner of the page, there is a Host Summary. Click Add.
6. Enter the ns1 and ns2 and IP addresses. Then click OK.
7. Click the Nameservers icon across the top.
8. Change the nameservers to the ones you just created.

Ref: http://help.godaddy.com/article.php?article_id=668&topic_id=&prog_id=GoDaddy&

Mydomain

(Also applies to Dotster)

1. Log into your account, and navigate to the “My Domains” page.
2. Under the “STEP 1. CHOOSE …” header, click on the domain you want nameservers under.
3. Under “Name Servers”, click “Register Name Server”
4. Enter “ns1″ (no quotes) in the “Host Name” box, and your first nameserver IP.
5. On the success page, click “Back to Domain Information”.
6. Repeat steps 3. to 5., using your second nameserver IP.
7. Under “Name Servers”, click “Update Name Servers”.
8. Change the nameserver to the ones you’ve just created.

Namecheap

1. Login to your account.
2. Click Manage Domains
3. Click on the domain name.
4. On the left, click on Nameserver Registration
5. for the first two (ns1 ns2), enter the IP addresses.
6. click add nameservers
7. Go back to manage domains
8. Select the domain
9. Click Domain Name Server Setup.
10. Change the Nameservers to your custom nameservers

Network Solutions

1. Login to Account Manager
2. Click the check box next to the domain you want to manage, then click “Edit DNS”
3. Ignore the warnings and click the “continue button under “Move DNS to A New Name Server” (do not select DNS Manager Continue)
4. Ignore the warning on the next page, and click Continue
5. Enter your custom nameservers, ns1.example.com and ns2.example.com and click Continue
6. On the next screen, enter the IP addresses for those nameservers and click Continue.
7. Ignore the warnings and click Save DNS.

OpenSRS

1. Login into your domain control panel.
2. Once logged in go to Name servers
3. Scroll down to the bottom of the page and click on the link following If you want to create or modify a name server which is based on yourdomain.com
4. At the bottom of this page type in ns1 then the IP Address provided to you by A Small Orange if you are a VPS Customer in the host name field. If you are shared or a reseller for the host name type in 64.22.96.90. Then click on Create Name Server
5. After that repeat #4 but then use ns2 and use the other IP Address A Small Orange provided of you are a VPS Customer but use 67.19.36.196 if you are a shared or reseller customer.
6. After 72 hours head over back to the Control Panel and go back to nameservers. Now type in ns1.youdomain.com and ns2.yourdomain.com and you are now done.
7. Now Jump up on your desk and say “I did it. I made nameservers.”

Register.com

1. Login to your domain control panel.
2. Click on the domain you wish to change.
3. Scroll all the way to the bottom, and under “Advanced Technical Setting”, click on “Managed Registered Name Servers”
4. On the next screen, look for Register DNS Server.
5. Enter “ns1″ for DNS Server, and the IP address (notice the domain name is pre-defined). Click the Continue button.
6. On the next screen (a confirmation screen), click Continue.
7. Repeat steps 3 – 6.
8. Now that the Nameserver IPs are registered, you can look for the section “Domain Name System Servers”
9. Enter ns1.example.com and ns2.example.com.
10. You’re done. Do a victory jig.

Stargate

1. Login to customer control panel
2. Enter your domain name example.com into the Jump to Domain field and use the drop down menu to select Domain Registration Service.
3. In the Domain Management Console, select the button “Manage Child Name Server”.
4. Enter ns1 for hostname field next to your domain example.com and enter the IP address 1.2.3.4 below it.
5. Click on the Modify Name Server button.
6. Change the nameservers to ns1.example.com and ns2.example.com that you created in Step 4.
7. Do a victory jig while the DNS propagates throughout the Internet.

qmail management

How To Manage QMail Queue In Linux?

1) To check the mail queue from command line, you can use the command :

#
/var/qmail/bin/qmail-qstat

messages in queue: 10

messages in queue but not yet preprocessed: 0

2) You can examine the queue with qmail-qread.

# /var/qmail/bin/qmail-qread

3) From the qread command you get the message’s id . In the above example , one of the id is 524514 . Now you can find the file holding the email in/var/qmail/queue with “find “command.

# find /var/qmail/queue -iname 524514

/var/qmail/queue/remote/22/524514

/var/qmail/queue/mess/22/524514

/var/qmail/queue/info/22/524514

4) From the mail header you get the IP address

vi /var/qmail/queue/mess/22/524514

5) If you wish to remove the emails with some patterns , you can use qmail-remove ( You can download it from here )

#
/etc/init.d/qmail stop

(Stop qmail before removing)
# /var/qmail/bin/qmail-remove -r -p “Time Passing”

(considering that “Time Passing” was the subject of the email )

The above steps can be used to track Spammers .

Do you wish to completely remove all the mails from queue? Just run the below commands.

find /var/qmail/queue/mess -type f -exec rm {} \;

find /var/qmail/queue/info -type f -exec rm {} \;

find /var/qmail/queue/local -type f -exec rm {} \;

find /var/qmail/queue/intd -type f -exec rm {} \;

find /var/qmail/queue/todo -type f -exec rm {} \;

find /var/qmail/queue/remote -type f -exec rm {} \;

How to enable SMTP authentication in some common email clients

To enable SMTP authentication in some common email clients:

Microsoft Outlook Express:

  1. Select Tools and then Accounts.
  2. Click the Mail tab.
  3. Select the account you want to to enable authentication on and choose Properties.
  4. Click the Servers tab.
  5. Select the “Outgoing Server” Tab
  6. Tick “My server requires authentication”.
  7. Click the Settings button.
  8. Ensure you also select the “Use same settings as my incoming mail server” option.
  9. Choose Apply.
  10. Choose Close.
  11. Choose Close.

Microsoft Outlook XP and 2003:

  1. Select Tools and then Email Accounts
  2. Highlight View or change existing e-mail accounts then Choose Next.
  3. Select the account you want to to enable authentication on and choose Change.
  4. Choose More Settings.
  5. Select the Outgoing Server Tab
  6. Tick My outgoing server requires authentication.
  7. Ensure you also select the Use same settings as my incoming mail server option.
  8. Choose OK.
  9. Choose Next.
  10. Choose Finish.

Mozilla Thunderbird:

  1. Select Tools and then Account Settings.
  2. Scroll to the bottom of the account list and select Outgoing Server (SMTP).
  3. Select the account you want to to enable authentication on and choose Properties.
  4. Select the correct outgoing server and click Edit.
  5. In the Security and Authentication section, tick the Use name and password checkbox.
  6. Ensure your username is showing in the box, it should be in the format user+domain.tld
  7. Choose OK.
  8. Choose OK.

Mac Mail Client OSX 10.4 upwards:

  1. Choose the Mail menu and click Preferences.
  2. Choose the Accounts tab
  3. Click the arrow box on the Outgoing Mail Server (SMTP) pop-up list and choose Add Server.
  4. In the Outgoing Mail Server field enter your SMTP mail server address.
  5. Select the check box on the Authentication list and choose Password.
  6. In the User Name field, enter your full email address or username.
  7. In the Password field, enter your e-mail password.
  8. Click OK.

Without SMTP authentication enabled you may receive some of the following related errors:

550 rejected RCPT – your.hostname.com [111.111.111.111] is currently not permitted to relay through this server. Perhaps you have not logged into the pop/imap server in the last 30 minutes or do not have SMTP Authentication turned on in your email client. 250 Reset OK

SMTP error from remote server after RCPT command:host your.hostname.com [111.111.111.111]:
530 Relaying not allowed (enable smtp authentication on your email client)

503 valid RCPT command must precede DATA

JunkMail rejected – your.hostname.com (hostname) [111.111.111.111] is in an RBL, see http://www.spamhaus.org/query/bl?ip=111.111.111.111 – This error is caused by the IP beingin the Policy Block List (PBL), an example is here:http://www.spamhaus.org/pbl/query/PBL174229.