Tuesday, June 8, 2010

Grub 2 after reinstalling Windows XP/Vista/Win7

Using Ubuntu 9.10 livecd or higher
Here assuming the Ubuntu partition is sda7,and /boot partition is sda6 (if you have a separate /boot partition).
Boot up ubuntu from the livecd,open terminal and run:
sudo -i
mount /dev/sda7 /mnt
mount /dev/sda6 /mnt/boot  #skip this one if not have a separate /boot partition
grub-install --root-directory=/mnt/ /dev/sda

If you miss “grub.cfg” file,use following to recreate:
mount --bind /proc /mnt/proc
mount --bind /dev /mnt/dev
mount --bind /sys /mnt/sys
chroot /mnt update-grub
umount /mnt/sys
umount /mnt/dev
umount /mnt/proc
exit

Using the cd/usb boot up with grub
open the Terminal 
Boot up the grub menu.Type:
grub>find /boot/grub/core.img
grub>root (hdx,y)   (previous command will output the x,y)
grub>kernel /boot/grub/core.img
grub>boot
 
After the boot command,you’ll go into grub2 menu.Select to boot up ubuntu,and run this command to restore grub:
sudo grub-install /dev/sda

Saturday, June 5, 2010

Ubuntu - LAMP php5 userdir

So you migrated your primary webserver to Ubuntu LTS and suddenly your users are complaining that their userdir php pages are not working. They keep being asked to download their php pages or phtml, or whatever. Their user blogs are not working. You have unhappy users, and by this time you are probably one as well.

This may have come up in an earlier upgrade, but whether it is 9.10-10.04 or 8.04lts-10.04lts only is pretty irrelevant. You're feeling the pain.

You have two choices. Tell your users to move to a dedicated hosting environment of their own, or re-enable php scripting in the apache web server.


Code:
sudo nano /etc/apache2/mods-available/php5.conf

Look for the lines that look like:
Code:
    <IfModule mod_userdir.c>
        <Directory /home/*/public_html>
            php_admin_value engine Off
        </Directory>
    </IfModule>
and change or comment the following lines to look like:
Code:
#    <IfModule mod_userdir.c>
#        <Directory /home/*/public_html>
#            php_admin_value engine Off
#        </Directory>
#    </IfModule>
then restart apache. 
Code:
sudo /etc/init.d/apache2 restart

And tell your users that they may need to restart their browsers. (or if they can figure out how, clear their web cache.)

Friday, June 4, 2010

Install Server Packages (script)

sudo apt-get install apache2
sudo apt-get install openssh-server
sudo apt-get install php5 libapache2-mod-php5
sudo apt-get install mysql-server
sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin
sudo apt-get install phpmyadmin
sudo apt-get install php5-mysql mysql-client
sudo /etc/init.d/apache2 restart

##Activating the User's public_html Directory with userdirectory
cd /etc/apache2/mods-enabled
sudo ln -s ../mods-available/userdir.conf userdir.conf
sudo ln -s ../mods-available/userdir.load userdir.load
sudo /etc/init.d/apache2 restart
apt-get install postgresql
 sudo apt-get install phppgadmin
apt-get install vsftpd
apt-get install links
apt-get install vim
apt-get install joe

Install TCC(Testing And Consultancy Cell)  Software Using Script

#/bin/bash
echo -n "Script ready enter Y to continue : "
read yes
if [ "$yes" = "y" ]
then
echo "Script Run"
else
echo "Exit"
exit
fi

cd /media/JAGDEEP
cp tcc.tar.gz ~/public_html
cd ~/public_html
chmod  777 tcc.tar.gz
tar zxvf tcc.tar.gz
chmod -R 755 ~/public_html

echo " Create Mysql database tc and prince_rou "
echo " Using command #create database tc ;  create database prince_rou"
echo -n " Enter your Mysql Root  Password : "
# Connect to the local database server as user root
# You will be prompted for a password.
mysql -h localhost  -u root -p

#
# Now we see the 'mysql>' prompt and we can run
# the following to create a new database for Paul.
#
mysql> create database tcdb;
Query OK, 1 row affected (0.00 sec)

#
# Now we create the user paul and give him full
# permissions on the new database
mysql> grant CREATE,INSERT,DELETE,UPDATE,SELECT on pauldb.* to paul@localhost;
Query OK, 0 rows affected (0.00 sec)

#
# Next we set a password for this new user
#
mysql> set password for paul@localhost = password('mysecretpassword');
Query OK, 0 rows affected (0.00 sec)

#
# Cleanup and ext
mysql> flush privileges;
mysql> exit;
echo "Database created"
# Restore the databases
cd /media/JAGDEEP
mysql -u root -p tc < tc.sql
mysql -u root -p prince_rou < prince_rou.sql
echo " OK Report" 






Thursday, June 3, 2010

Migrate a SQL Server or Access database to MySQL

Migration Tools

There are a wide variety of tools available to help you migrate a SQL Server or Access database to MySQL. We'll look at several different tools so you can choose the one that best suits your needs. The tools we will look at will include the following:
  • MSSQL2MYSQL
  • Microsoft DTS
  • SQLyog
  • Access Export
  • Text Import/Export
SQLYog and the Microsoft DTS wizard offer graphical interfaces that can be used with both MSSQL and Microsoft Access to import tables into MySQL. MSSQL2MYSQL is a script by Michael Kofler that can convert not only the table structure and data, but converts the index information as well. If you use Microsoft Access you may not have access to the above tools, but you can use the data export features of Access.

MSSQL2MYSQL

MSSQL2MYSQL is a creation of Michael Kofler, author of The Definitive Guide to MySQL by Apress. MSSQL2MYSQL is a Visual Basic script that can be executed using either a Microsoft Visual Basic 6 installation or an application that supports VBA such as Microsoft Word or Excel.
Details on usage can be found at the author's web site, which also includes a listing of GUI front-ends that can be used to make MSSQL2MYSQL a bit more user-friendly for non-programmers.
To use MSSQL2MYSQL with VB6, simply copy the text located at http://www.kofler.cc/mysql/mssql2mysql.txt and paste it into the code section of a VB form. You will need to change the constants at the beginning of the code to match your SQL Server and MySQL installations, and you can then proceed to run the VB6 application and your conversion will take place. MSSQL2MYSQL does not provide any visual feedback on the progress of your conversion, and provides a simple messagebox upon completion.
A nice feature of MSSQL2MYSQL is the ability to dump all statements into a text file, which you can then review and edit before executing on the MySQL server.

Microsoft Data Transformation Services

Microsoft DTS is a data manipulation tool that is included with Microsoft SQL Server. DTS is excellent for moving data between various formats and systems such as databases, spreadsheets, and even HTML. The Microsoft Data Transformation Service can be very complex, but most of us will only ever need to use the Import/Export Wizard that is included with DTS.
Using DTS is fairly straightforward, you choose an ODBC data source to read data from, and then select an ODBC data source to convert the data to. You are then given a list of tables to convert, with an option of renaming the destination table and even performing basic transformations on the data before it is inserted into the target database. These transformations are performed using Visual Basic scripting. In addition, you are given control over the table creation statements to be used, allowing you to fine-tune the MySQL table definitions to add parameters such as table handler (InnoDB, BDB, etc) to the script that will be executed.
DTS also has the ability to perform scheduled data transformations, something that can be very useful when you are using MySQL for analysis of SQL Server data or when you just want the latest data available as you work on your application migration.

SQLyog

SQLyog is a third-party commercial tool available to help administrators manage MySQL in a GUI environment. SQLyog is provided by by webyog, a MySQL partner, and a thirty day trial of the tool is provided. SQLyog provides an ODBC import tool that is similar to DTS, offering a straightforward interface that is perhaps even simpler to use than DTS.
SQLyog is capable of scheduled imports of data, and can also be used to synchronize both data and schema between multiple MySQL servers.

Access Export

If you are a Microsoft Access user but do not have access to Microsoft DTS or SQLyog, you may want to use the export capability of Microsoft Access. Access can export its tables to a variety of formats, including ODBC. This allows you to export an Access table to MySQL by way of the Connector/ODBC ODBC driver provided by MySQL AB.
To export an Access table to MySQL, right-click on the table in question and choose the 'Export' option. After several steps your data will be exported to MySQL. The column-type choices made by Access may need to be modified, and you should be aware that Access will not export index information with the data, meaning that you will need to implement indexes on your tables after exporting them.

Text Import/Export

One final way to import data is to export the data from MSSQL/Access in a text format and import it directly into MySQL. When exporting, common formats such as tab-delimited or comma-delimited will work fine for later import into MySQL.
When taking this approach, you will need to manually create the MySQL tables, then import the data with the LOAD DATA command in the mysql command-line client. Additional information on the LOAD DATA command can be found in the "LOAD DATA INFILE syntax" section of the MySQL Reference Manual.
While perhaps the most labor-intensive and time-consuming, this approach gives you the highest level of control over table schema as you manually create the tables before importing data.

Tuesday, June 1, 2010

Quick install guide Django.

 Install Python

Get Python at http://www.python.org

You can verify that Python’s installed by typing python from your shell; you should see something like :(on terminal)
#Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 

Remove any old versions of Django

If you are upgrading your installation of Django from a previous version, you will need to uninstall the old Django version before installing the new version.

Install Django

You've got three easy options to install Django:

Option 1. Get the latest official version

The latest official version is 1.2.1 Here's how to get it:
First, download Django-1.2.1.tar.gz. Then:
tar xzvf Django-1.2.1.tar.gz
cd Django-1.2.1
sudo python setup.py install

Option 2. Get the latest development version

The latest and greatest Django version is the one that's in our Subversion repository (our revision-control system). Get it using this shell command, which requires Subversion:

svn co http://code.djangoproject.com/svn/django/trunk/

After you get it

See the installation guide for further instructions.


Install Apache and mod_wsgi

Basic Configuration

Once you’ve got mod_wsgi installed and activated, edit your httpd.conf file and add:
WSGIScriptAlias / /path/to/mysite/apache/django.wsgi
The first bit above is the url you want to be serving your application at (/ indicates the root url), and the second is the location of a "WSGI file" -- see below -- on your system, usually inside of your project. This tells Apache to serve any request below the given URL using the WSGI application defined by that file.
Next we'll need to actually create this WSGI application, so create the file mentioned in the second part of WSGIScriptAlias and add:
import os
import sys

os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
If your project is not on your PYTHONPATH by default you can add:
sys.path.append('/usr/local/django')
just above the final import line to place your project on the path. Remember to replace 'mysite.settings' with your correct settings file, and '/usr/local/django' with your own project's location.

 

Get your database running

If you plan to use Django’s manage.py syncdbSELECT, INSERT, UPDATE and DELETEALTER TABLE privileges during syncdb but won’t issue ALTER TABLE statements on a table once syncdb permissions. On some databases, Django will need command to automatically create database tables for your models, you’ll need to ensure that Django has permission to create and alter tables in the database you’re using; if you plan to manually create the tables, you can simply grant Django has created it.

Installing an official release

  1. Download the latest release from our download page.
  2. Untar the downloaded file (e.g. tar xzvf Django-NNN.tar.gz, where NNN is the version number of the latest release). If you're using Windows, you can download the command-line tool bsdtar to do this, or you can use a GUI-based tool such as 7-zip.
  3. Change into the directory created in step 2 (e.g. cd Django-NNN).
  4. If you're using Linux, Mac OS X or some other flavor of Unix, enter the command sudo python setup.py install at the shell prompt. If you're using Windows, start up a command shell with administrator privileges and run the command setup.py install.
For more detial click here 

Creating a project

If this is your first time using Django, you’ll have to take care of someinitial setup. Namely, you’ll need to auto-generate some code that establishes aDjango project – a collection of settings for an instance of Django, including database configuration, Django-specific options and application-specific settings. From the command line, cd into a directory where you’d like to store your code, then run the command  django-admin.py startproject mysite. This wil lcreate a mysite directory in your current directory.
The development server Let's verify this worked. Change into the mysite directory, if you haven't already, and run the command python manage.py runserver. You'll see the following output on the command line: Validating models...
0 errors found.

Django version 1.0, using settings 'mysite.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

Database setup

Now, edit settings.py. It's a normal Python module with module-level variables representing Django
settings. Change the following keys in the DATABASES 'default' item to match your databases
connection settings.
ENGINE -- Either
  • 'django.db.backends.postgresql_psycopg2', 'django.db.backends.mysql' or 'django.db.backends.sqlite3'. Other backends are also available.
  • NAME -- The name of your database. If you're using SQLite, the database will be a file on your
    computer; in that case, NAME should be the full absolute path, including filename, of that file.
    If the file doesn't exist, it will automatically be created when you synchronize the database for the
    first time (see below).When specifying the path, always use forward slashes, even on
    Windows (e.g. C:/homes/user/mysite/sqlite3.db).
  • USER -- Your database username (not used for SQLite).
  • PASSWORD-- Your database password (not used for SQLite).
  • HOST --The host your database is on. Leave this asan empty string if your database server is on the
    same physical machine (not used for SQLite).
If you're new to databases, we recommend simply using SQLite (by setting ENGINE to
'django.db.backends.sqlite3'). SQLite is included as part of Python 2.5 and later, so you won't
need to install anything else.
While you're editing settings.py, take note of the
INSTALLED_APPS setting towards the bottom of the file. That variable holds the names of all Django applications that are
activated in this Django instance. Apps can be used in multiple projects, and you can package and
distribute them for use by others in their projects.

By default, INSTALLED_APPS contains the following apps, all of which come with Django:
These applications are included by default as a convenience for the common case.
Each of these applications makes use of at least one database table, though,so we need to create the
tables in the database before we can use them. To do that, run the following command:
python manage.py syncdb