Friday, August 12, 2011

Use Google Apps for dual Deployment and Disaster Recover.

I have setup our Exchange Server, DNS Servers and Google Apps to Dual Deploy our email and to act as a secondary mail server.   In my opinion the best solution possible.

I looked at Google Apps before and didn't really see the potential.  Then my son in-law told me that you could use it and use your own domain with it and that got be thinking about the potential.  This is incredible.  You can have up to 50 users and each user can have 7 Gigs of space for emails.  That is more than I allow on our Exchange server.

Although I'm a big fan of MS Exchange I thought that maybe I could use Google Apps as a backup email in case Exchange fails.  I already have 1 Disaster Recovery solution in place.  I'm using Double-Take at a remote site to replicate our Exchange server.  Some would fill this is enough, but with Google Apps I have a complete solutions.

Here is what Google Apps offers me:

When our Exchange Server goes down and it does.  I don't have to fail over to the Disaster Recovery Site immediately.  Google Apps gives me time since the email will continue to flow to Google Apps we can continue to do business as usual.  I then have time to determine how serious the problem is, how long the Exchange server will be down and if we should fail over to our Exchange server at the Disaster Recovery Site.

I have a place for all the users email to be autoachive.  If they delete something on the Exchange server they can retrieve it on Google Server.

Here is how you setup Google Apps to Act as a Secondary email server and as an archive server.

1. You need to setup a Google Apps Account.  Choose the Standard Account if you have less than 50 users.  http://www.google.com/apps/intl/en/group/index.html
2. Once you enter your domain name or purchase the domain name then you need to verify that you are the administrator.  This can be a little tricky if you are using a production domain name.
3. Fortunately for me I have my own DNS servers so I was able to make the changes.  I used the html method to authenticate.   I setup my CNAME so that I could type docs.domain.com and it would go to the google docs website and I added the google MX host information to my MX records.  Now, you can either put them first and remove your current entry or you can get them the same values as your current email servers.  You will not be able to verify until Google see them as the top MX records.   I moved my current MX record to a higher value to verify my domain.  After my domain was verified I gave my current MX records a lower value so they were first.   For my sub-domain authentication I gave the google MX record the same value as my current MX records and google verified my sub-domain.
4.  Now I did the same thing to my internal DNS so that from my PC I could resolve the MX records from within my company.
5.  So in my CNAME I use that to give shorter URL to connect to my google sight.  The way I don't have to type the www.google.com/a/domainname.  Instead I can type email.domainname.com or docs.domainname.com.   In my MX records I have my subdomain that I setup at Google Apps with the same value as my MX records for my Exchange servers.  Ex:
@ mail.domainname.com. 10
gmailalias ASPMX.L.GOOGLE.COM.
@ mail2.domainname.com 20
gmailalias ALT1.ASPMX.L.GOOGLE.COM. 20

Don't forget your "." after FQDN

This provides the ability to use DUAL - Deployment by way of the Alias "gmailalias".  There are more steps to getting this to work.  I'll explain those below.


6. To get emails to go to my Google Apps email if exchange goes down you need to add Google to your MX record as secondary email servers.  Below the enters above I have the Google Apps MX records.  In other words, if Exchange goes down the next MX record will be used to delivery mail for "domainname.  I'm not talking about the alias emails.  I don't get emails coming to me with the alias domain, that is used to forward emails to my Google emails.  So in my case the next MX record for my "domainname" is "mail-Dr" with a value of 20.  Well, my "mail-DR" isn't setup to receive email only to receive replication and I would need to manually failover and start the services before I would receive any emails.  So then the next MX record would be the google account.  So here are the Google MX records.




http://www.google.com/support/a/bin/static.py?page=guide.cs&guide=22229&topic=22230

Monitor MySQL queries in Real Time

Just a quick tip on monitoring the queries that mysql is handling on a production site. You can use the mysqladmin tool to return a list of the processes currently being handled. Combining this with the UNIX watch command allows a real-time monitoring of what's going on.
watch -n 1 mysqladmin processlist
The "-n 1" specifies that mysqladmin executes every second. Depending on your set-up, you may need to specify a mysql user and password:
watch -n 1 mysqladmin --user= --password= processlist

LVM Snapshot script

LVM Snapshot script
Used for copying a MySQL schema to a test environment


There are so many ways to do this, but our need was to not have any production down time* and have the test database available ASAP.  

I wrote up a little how to and I thought I might share it so others could use it.  Like I said there are many ways to do this so just take a look and use the logic that works for you. 

A Method to copy Data to a test environment


This method will copy all data in a volume and MySQL a test environment with no downtime.  The method used could also be used for backing up data or replication.
Here are the steps needed to accomplish the copy to test.
1.       Add an additional hard drive for Storage. 
2.       Configure the disk using fdisk and then create a Physical Volume with the pvcreate command.*
3.       Add the Physical Volume to the VolGroup with the vgextend command.*
4.       Setup MySQL to run a second instance.*
5.       Run the this script.

#! /bin/sh

user=username
pwd=password
olddb=originalname
newdb=newname
socket=/tmp/mysql.sock2

#This will remove LVM and stop the second instance of MySQL .
mysqladmin -u$user -p$pwd --socket=$socket shutdown 
sleep 4
umount /dev/VolGroup01/databackup
lvremove -f /dev/VolGroup01/databackup

#This will flush mysql and Lock Tables and LVM snapshot (see below)**
mysql -u$user -p$pwd < lvm_snapshot

#At this point the volume and MySQL files have been copied

#This will will mount the LVM snapshot to /mnt/databackup
 mount -t ext3 /dev/VolGroup01/databackup  /mnt/databackup

#This will start the second instance of MySQL on port 3305
mysqld_multi start 2

#This is needed to allow enough time for MySQL to start and create the mysql.sock2 file
sleep 4

#This will login to the second instance of MySQL and rename the schema to dl4test. 
mysqlconn="mysql -u$user -p$pwd -S $socket -h localhost"

$mysqlconn -e "CREATE DATABASE $newdb"
params=$($mysqlconn -N -e "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='$olddb'")

for name in $params; do
      $mysqlconn -e "RENAME TABLE $olddb.$name to $newdb.$name"; done;

$mysqlconn -e "DROP DATABASE $olddb"

#This will grant user saitest access to the newdatabase schema
$mysqlconn -e "GRANT ALL PRIVILEGES ON newdatabase.* TO 'username'@'%' IDENTIFIED BY 'saitest'";

This script takes about 10 seconds to run and requires no down time in production.  
Note: the schema name change does not change any stored procedures so a script or logic would need to be added in order to create those after renaming the schema.

*More Information on Setup:
1.  Use fdisk to setup the disk. 
Type fdisk /dev/sdb1 (or whatever device your new hard drive is) and press Enter.  Then press, m,n,e(choose the defaults), p, and w to save the changes.  
2.  Create a Physical Volume.
Type “pvcreate /dev/sdb1”
3. Extend the Volume Group.
Type “vgextend VolGroup01 /dev/sdb1”

4. Add a second instance of MySQL.
Modify the /etc/my.cnf with the following changes.
a.       Add a [mysqld_multi] section that looks like this:
[mysqld_multi]
mysqld          = /usr/bin/mysqld_safe
mysqladmin      = /usr/bin/mysqladmin

b.      Rename [mysqld] to [mysqld1]
c.       Add a [mysqld2] section with the following parameters:
[mysqld2]
port            = 3305
datadir         = /mnt/databackup/mysql
socket          = /tmp/mysql.sock2
pid-file        = /mnt/databackup/mysql/mars-snapshot-test.pid2
log_error       = /mnt/databackup/mysql/error2.log
To start the second instance of mysql use the following command:
“mysqld_multi start 2”
To stop the second instance of mysql use the following command:
Mysqladmin –uusername –ppassword –socket=/tmp/mysql.sock2 shutdown.
To login to the second instance of mysql you will need to login using the socket:
Mysql –uusername –ppassword –S /tmp/mysql.sock2 –hlocation

DownTime - we run this at night when there are a minimal of users. 
Long queries at the time of the LVM snapshot will call some downtime.


** Here is the content of the lvm_snapshot file
FLUSH TABLES WITH READ LOCK;
system lvcreate -L 220G -s -n databackup /dev/VolGroup01/LogVol01;
UNLOCK TABLES;
QUIT





Thursday, June 3, 2010

Error 126, 1068, 70020 unable to VPN

I had an employee with the following problem.  They were unable to VPN and were receiving the errors in the Title.  They were also unable to connect to some wireless AP at customer's site.   Here is what I did.  One i stopped Eset from Scanning the C:\windows\system32 directory.   This allowed the Windows Remote Management Access service to start.   I then looked at HKEY_LOCAL_MACHINE\System\Services\RASMAN\PPP\EAP and noticed that Symantec had entry in 13,25, but not 26.   I read somewhere to delete all entries except these 3 because they are windows default entries.  Since Symnatec (Symantec was installed on this computer, but removed) had entries in I decided to delete 13 and 25.  I deleted them and then rebooted hoping they would self populate, but they did not.

I then exported these registry entries from another Vista computer and then imported them.  The problem was now fixed.
 

Tuesday, February 16, 2010

I was struggling trying to get Outlook 2007 to connect to my Exchange 2003 server...

Here is what I did.

I was trying to add a new user, but I continued to get a message that Exchange was unavailable or offline.  Yet, no one else was complaining and I could connect using OWA.   So I figured it was a problem with the client computer. 

Where it prompts to put in the Exchange Server name I put in the Domain Controller name instead.  This quickly resolved to the name of the exchange server and then I was connected.   I was able to finish setting up the new user.   So I could resolve the name by going to the DC instead of the exchange server.  Time to look at the services on the exchange server.  I noticed that the Microsoft Exchange System Attendant had stop running.  This is needed to resolve Active Directory information.    So if you run into this problem make sure this services is running.  

Thursday, June 18, 2009

How to remove a GPT Partition

I bought a USB hard drive and it was formatted for apple with the GPT partion.  My windows XP machine recognized the hard drive, but not the partition.  I had to format the drive, but was unable to through the Disk management console or in the usual way.

Here is what you will need to do:

type the following command at the command prompt.

1. cmd
2. diskpart
3. list disk
4. select disk x (choose the disk you want to format)
5. clean
6. exit

You are now ready to format the disk in windows.

Thursday, June 11, 2009

How to change the IP Address in SCO Unix

cd to /var/spool/lp/admins/lp/interfaces
vi the printer that you want to change the IP Address.
Look for the line: PERIPH=xxx.xxx.xxx.xxx (example PERIPH=192.168.1.24)
Change the IP Address to whatever you want.

****If your printer was on a HP JetDirect then check to make sure the PORTNO=9100****

After you make the change, then save the file.

disable the printer with this command:
disable printername
Then enable the printer with this command
enable printername

You should be able to print to the printer with the new IP Address.

Wednesday, June 10, 2009

Log interactive session in MySQL

There are two ways to start recording your interactive session in MySql.

1. From the Command line:
(I'm only typing the command "mysql" and will assume that your username and password is saved in your home directory in ".my.cnf" file.

mysql --tee=filename database
ex: myssql --tee=tmp.txt dl4demo09

2. From within Mysql:
mysql> \T output.file
Logging to file 'output.file'

Thursday, August 7, 2008

How to confiure an IPhone to use Exchange

I struggle to get the president of our company Iphone to work with our windows 2003 server. 
I used this document to setup the IPhone.
http://support.apple.com/kb/HT2480
The phone validated and appeared to be working fine, but no email, calendars or contacts would appear in the phone.  Although phone would report that it was updated.

I realized that I was getting an error when I tried from a browser to hit https://registerdomainname/oma
I found this article below that I tried first.  I was able to connect to the server just fine.  However, I realized that I was not requiring SSL connections.
http://support.microsoft.com/?id=883380
Once I enable require ssl connections I had the same error.  I looked a little further and found this document that solved the problem.
http://support.microsoft.com/kb/817379

Friday, June 27, 2008

Upgrading Hyper-v to the final release wasn't as smooth as I thought it would be.

I was a little surprise that the upgrade wasn't as seamless. I followed the instruction from http://support.microsoft.com/kb/950050, but still had issues. After the upgrade, I couldn't start any of my VMs. I had to delete and create new ones. Then my network adapter was removed, so I had to create a new network adapter. My VM finally came up, but the mouse didn't work, so I had to install the new integration services. I just finished that. My system is rebooting, so I'll see what other problems I'll run into.

Thursday, June 5, 2008

How to mount a vhd file to the host

Why would you want to do that? Well there are many reasons, but most important is to get to the data.

Here is how I do it.

I use Ben's script
http://blogs.msdn.com/virtual_pc_guy/archive/2008/02/01/mounting-a-virtual-hard-disk-with-hyper-v.aspx

I just edit the script and put in the drive, path and filename of the vhd that I want to mount. After editing and saving I double-click on my vbs file and it is mounted. I have one called mount vhd.vbs and one called unmount vhd.vbs. The only difference is the two scripts is the last line VHDService.Mount(VHD) to mount andVHDService.unMount(VHD) to unmount.

I then open up Disk Management under computer management. You should see a volume that is offline. Right click on choice "online". The disk will come on line and be assigned a drive letter. That's it. Now just go into explore and take a look at the disk.

Update - How to backup Virtual Server in Windows 2008

I've made some changes to how I backup my Virtual servers. The other way I wasn't able to copy over the previous backup so I wasn't get the lastest backup. Here is what I am doing now.

I have 3 files that I use.
1. script.dsh
Here's the content of it.
#DiskShadow script file
set context persistent nowriters
set metadata c:\diskshadowdata\example.cab
set verbose on
begin backup
#add volume c: alias SystemVolumeShadow
add volume d: alias DataVolumeShadow

create

#expose %SystemVolumeShadow% r:
expose %DataVolumeShadow% p:
exec c:\diskshadowdata\backupscript.cmd
end backup
#End of script

As mentioned in the previous post I explained where I got this and what changes I made. The only difference from the previous post is that I'm using the P drive instead of the Q drive.

File #2 - backupscript.cmd
I:
rmdir /S /Q backup
mkdir backup
cd \backup
P:
xcopy /E /Y "virtual servers" I:\backup\
mountvol P:\ /D

After the first file creates the shadow copy of my D drive and mounts it on the P drive, I use this file to remove the previous backup (because I don't have room and for some reason it was not overwriting the previous backup) and then copy the virtual servers.
There are definitely better ways to do this, but here is what this script does.
I change to the I drive which is the drive my USB hard drive is mount to. I then remove the directory that contains the previous nights backup. I don't have room on the USB drive to house more than one backup. I then create the same directory to put the backup virtual files in. Then I switch to the P drive which has the latest mount shadow copies in and start copying just the directory that contains the virtual server files. That directory is called "virtual servers". After the copy is done then I unmount the P drive. If you don't then you will not be able to successfully run the first script the next time you run it.

File #3 - Backup.bat
C:
cd \diskshadowdata
diskshadow /s script.dsh

This file is the one that I have the task scheduler setup to use for the nightly backup. Because I don't have my pathing setup I just cd to the diskshadow directory which has all three files in and run the "diskshadow /s script.dsh" command.

I hope I didn't confuse you.

Ask if you have any questions and I will try to explain better.

Friday, May 23, 2008

Backing up volume shadow copies in Windows 2008 (Hyper-v) Virturals using Diskshadow

The script I had for backing up my Windows 2005 Virtual server does not work in Windows 2008 using Hyper-v. So I started looking for another solution. Here is what I'm doing to backup my Virutal servers in Windows 2008. In Windows 2008 there is a new tool called "diskshadow". This link below shows how to use it and they have a script to get your started.
http://technet2.microsoft.com/windowsserver2008/en/library/e962537d-b759-4368-b6f1-e8391cf7b2211033.mspx?mfr=true
I don't need to create a shadow copy of my system drive nor to mount it, so I just commented out the two lines:
#add volume c: alias SystemVolumeShadow
#expose %SystemVolumeShadow% p:

For testing I run this command from the command prompt: DISKSHADOW /s script.dsh
If all is well I set up a task schedule to run this.

So what this script does is create a shadow copy and mounts it to the P and Q drives. I don't need the mount to P so my script will only mount my shadow copy of my D drive to Q. I then have a script that runs an xcopy command to backup my "virtual servers" folder to my USB hard drive which is mounted to the I: drive.

The last line of my backup script is to remove the Q: drive mount. If you don't remove the mount before you run the script you will get an error. So unmount the shadow copies that are mount before running the script. To unmount use this command. "mountvol driveletter:\ /D"

So the last line in my backup script I have "mountvol P:\ /D" so that the P: drive is available the next time I run the script.dsh the P: drive is available to mount to.

Tuesday, May 6, 2008

Here is how to change a Windows KMS license to a MAK license.

First run this command from a dos prompt and put in your MAK license Key.

slmgr -ipk xxxxx-xxxxx-xxxxx-xxxxx-xxxxx
http://support.microsoft.com/kb/929826/

Next. Go to system's properties in the control panel and click on activate windows now. After click on it you will activate it with a MAK license.

Friday, May 2, 2008

Force removal of a domain controller

I tried to remove a domain controller today from a virtual environment and was unable to. I found this article that shows you how to force the removal of the domain controller.
http://support.microsoft.com/kb/332199

Friday, April 25, 2008

Upgrade Window's virtual host server from 2005 to 2008

I found out that when you upgrade from Windows Virtual server 2005 to Hyper-v you want to remove the vmadditions from your windows maching prior to moving them to the Windows 2008 server that has hyper-v installed. It is alot easier.

I have mouse problems when I just moved a MS 2005 Virtual Server to Windows 2008. When I removed VMaddition, I didn't have the mouse problems. It was alot easier to upgrade the hyper-v guest components.

Double-Take Invalid License when you upgrade to Windows 2008

My host system has 4 virtual servers on it. When I upgrade the host from Windows 2003 to Windows 2008 I now get an invalid license error in Double-take. I'm on hold right now. When I get the problem resolved I will tell you what they had me do. I'm hoping that they just issue me a valid license for this. We'll see.

Well, I just spoke to Mike Brown. He said that it appears that Double-take is determining that with Hyper-v guest components that it is a physical server instead of a virtual one. He gave me a 6 day key until they could resolve the issue. They will get back to me.

Double-take are really good at support. You can talk to someone that speaks english and they are pretty knowledgeable.

Friday, April 18, 2008

How to create a shadow copy and mount it.

To create a shadow copy run this command.
vshadow -scsf D:

To list the shadow copies run this command.
vssadmin list shadows

To mount to a directory run this command:
mountvol D:\mountpoint \\?\Volume{21bf079c-f9db-11dc-b4a5-0015173b1ee7}\

You could also mount it to a drive using the vshadow command.
vshadow.exe -el={ShadowID},Driveletter:
example: vshadow.exe -el={4cdd0ee7-6448-4ab7-9c55-576c9dd9d41d},P:


To remove the mountpoint from the directory run this command.
mountvol D:\mountpoint /d

Wednesday, April 16, 2008

Terminal Server 2008 doesn't like it when you change the name of the server

I have Windows 2008 setup with Terminal Services running really well. I then changed the name of the server and Terminal server doesn't want to work anymore. The Event Log is suggesting that it is not running. However, it is running. So I uninstalled it and reinstalled it with a new certificate, but still no luck.

I haven't been able to find an answer for this one. I guess uninstall terminal services before change the name and then reinstalled it afterwards.

I can use SteadyState for the Kiosk

Microsoft has introduced SteadyState for locking down computers so the public or users don't ruin them. You can reset them.

I read an article today about it in the January technet magazine page87. I will build a virtual XP machine to try it out. I'll write more once I get it setup.

This is how I'm backing up my Virtual Servers

I've been trying to figure out a way to backup my virtual servers unto a External USB Hard drive. This server will be our disaster recovery server and the facility where it will be hosted does not do backup tapes. So I wanted a way to back to a 1TB hard drive. I thought about the online backups, but they were going to be too expensive for the size that we have and toooooooo slow. Have you every tried to restore from one of those sites? I've had customers do it and it takes forever.

I looked at many scripts that our out there. Most caused my VM to hang. The one that I settled on is from: http://blogs.msdn.com/adioltean/archive/2005/01/20/357836.aspx
His name is: Adi Oltean

His script creates a Shadow Copy and mounts it to a Drive. For instance, his script will take a shadow copy of my D: drive where my Virtual Servers reside and mount them to my H: drive. I don't have an H: drive normally, but his script will mount this volume(Shadow Copy) that is created to whatever drive you select that is not already in use.

From there you can go to your H: drive or whatever drive you selected and view copy of your Virtual Servers.

This is great. From here I copy the files to my USB Hard drive which I have mounted as my Q: drive. Because the files that are now on H: are not in use, you can copy them without any file in use errors.

Here is what I've done.
I created a small script that start off my unmounting the volume from H: that was created the night before. I then call for Adi Oltean's script to create the Shadow Copy and mount it to my H: drive. Then I start a xcopy command to copy it over to my backup folder on the Q: drive. Remember the Q: drive is my external USB Hard drive.

@echo This will remove the mounted volume.
mountvol H:\ /D

@echo This script will create a shadow copy and mount it to H:
createshadow.cmd D: H:

@echo This will copy the Virtual Server to Q:\backup.
H:
xcopy /E /Y "virtual servers" Q:\backup\

So on my D: drive I have my script which is the one above that I call backupVMs.bat and Adi Oltean's script createshadow.cmd. I setup the task scheduler to run every night. It takes about 6 hours to backup my approximately 660 Gigs.


How to Activate a sprint Cell phone for Free

I wanted to replace a phone that was dead with one that my company let me borrow until the one that I ordered on ebay arrived. Here is what I did.

First go to this website: http://www4.sprint.com/WLSApp/esnswap/do/Welcome?id12=UHP_AlreadyCustomer_Link_ActivateYourPhone

Put in your cell phone number and click "Continue"

Login in with your username and password. If you haven't setup an account you will need to.

After logging in you will need to select your phone and click on "Upgrade or Active Phone". The box will open and then click on "Activate".

Once your click on "Activate" You will receive warning that the current phone will no longer be able to make or receive calls, etc.

That's ok. You want to replace it anyways.

You will be taken to a webpage that has information about your cell phone. Print it out because you will need it.

For my Cell phone, I was given a code that allowed me to get into the configuration menu.

From there I went into the Basic Menu and I put in my MDN/PTN. Which is my 10 digit cell phone number. Next I had to put in my MSID/IMSI number. I believe this is the 10 digit cell phone number from the main phone number on the account. The webpages shows 5 zeros before the number. Just ignore those and put in the last 10 digits. Next it will ask for the SID/BID number. The webpage shows 5 digits, but drop off the "0" and put in the last 4 digits. Press "Ok" or "END". When the phone comes up it will be on the Sprint Network. You should be able to make and receive phone calls.

Now, if you have problems. You can call 1.877.345.7895 for help. The tech will help you. This may be a better options for most people.

Monday, April 14, 2008

Unable to connect to Virtual Servers using VMRCPLUS

I've had this happen a couple of times. I tried to connect to the server using VMRC PLus and it would just hang. Here is what I've done to fix the problem.

1. Stop the Virtual Server services. You may need to use task manager to kill off the VM processes.

2. Navigate to C:\documents and Settings\All Users\Application Data\Microsoft\Virtual Server\Virtual Machines\

3. Move or delete all of these files. I usually just move them to another folder, but then later I delete them.

4. Now start the Virtual Server service

5. You should be able to connect to the server using VMRC Plus.

6. After you connect your virtual servers will be missing. Don't worry, just add them back.

7. Click on "Virtual Machines" and then "add".

8. Drill down to where you keep the Virtual servers and add each one back. They will be intact and should startup without any problems.

Good Luck.

Friday, March 14, 2008

Upgrade MySQL from 4.1 to 5.1 Linux

How to Upgrade from MySQL 4.1 to MySQL 5.1

I downloaded the files.

MySQL-server-community-5.1.23-0.rhel4.i386.rpm
MySQL-client-community-5.1.23-0.rhel4.i386.rpm
MySQL-shared-compat-5.1.23-0.rhel4.i386.rpm
MySQL-devel-community-5.1.23-0.rhel4.i386.rpm
MySQL-shared-community-5.1.23-0.rhel4.i386.rpm

Put them in a directory. I put mine in /tmp/mysql directory

First create a backup of the current Data.

Note: When doing multiple databases be sure to include the “s” at the end of databases. When doing a single database then only type database without the “s”.

To create a complete backup of all the databases do this:

# mysqldump –u root –p –-all-databases> alldatabases.sql

Or to compress the file do this:

# mysqldump –u root –p –-all-databases |gzip > alldatabases.sql.gz

 
To create a backup of individual database then do this:
 
# mysqldump –u root –p -–database database > databasebackup.sql
# mysqldump –u root –p -–database database1 > databasebackup1.sql
# mysqldump –u root –p -–database database2 > databasebackup2.sql

Or to compress the file do this:

 
# mysqldump –u root –p -–database database |gzip > databasebackup.sql.gz
# mysqldump –u root –p -–database database1 |gzip > databasebackup1.sql.gz
# mysqldump –u root –p -–database database2 |gzip > databasebackup2.sql.gz
 
If you want to backup multiple database to one file then do this:
# mysqldump –u root –p -–databases database database1 database2 > databasebackup.sql
 
Or to compress the file do this:
 
# mysqldump –u root –p -–databases database database1 database2 |gzip > databasebackup.sql.gz
 
You can also just backup the database tables with NO DATA.  This will just keep the table structure, but NO DATA.   Don’t run this on “mysql” database.  You will need the users and authentication to get back in.   Use this command:
 
# mysqldump –u root –p -–no-data -–database database > databasestructure_nodata.sql
 
To do multiple database use this command:
 
# mysqldump –u root –p -–no-data -–databases database database1 database2 > database3structure_nodata.sql
 
Once the data is protected then you can do the upgrade.
 
service mysqld stop
rpm -Uvh --nodeps MySQL-server-community-5.1.23-0.rhel4.i386.rpm
rpm -Uvh MySQL-client-community-5.1.23-0.rhel4.i386.rpm
rpm -Uvh MySQL-shared-community-5.1.23-0.rhel4.i386.rpm
rpm –Uvh MySQL-shared-compat-5.1.23-0.rhel4.i386.rpm
rpm -Uvh MySQL-devel-community-5.1.23-0.rhel4.i386.rpm
vi /etc/my.cnf
# Comment out the base-dir line under [mysqld.server] - RHEL 4 / MySQL bug
adduser mysql
cd /var/run
mkdir mysqld
chown -R mysql:mysql /var/run/mysqld
chown -R mysql:mysql /var/lib/mysql
service mysql start
mysql
 
Now you will need to fix the table structure problem with this command:
 
# mysql_upgrade –u root –p
 
You will probably see some errors about our databases.  That should be ok.  
 
Then login with the credentials.
 
If things go wrong and you need to restore; here is how to restore the data.
 
# mysql -u [username] -p [database_to_restore] < [backupfile]
 
You have to create the database first if it doesn’t exist already.  Here is the command to do that:
 
# mysqladmin -u USERNAME -p create DATABASE 
 
OR you can create it within MySQL
 
# mysql –u root –p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 50
Server version: 5.1.23-rc-community MySQL Community Edition (GPL)
 
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
 
mysql> CREATE database database1;
Query OK, 1 row affected (0.02 sec)
 
To see all the databases in MySQL issue this command from within MySQL
Mysql> SHOW databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| database           |
| database1          |
| database2          |
| database3          |
| mysql              |
| test               |
+--------------------+
7 rows in set (0.00 sec)