Showing posts with label Tutorials for MySQL. Show all posts
Showing posts with label Tutorials for MySQL. Show all posts

Monday, January 9, 2012

Create a simple mysql database, tables and insert data for Library Books and Patron details

If you want to create a simple database and set up tables for your library management use the following two sql commands:

=> CREATE DATABASE - create the database

=> CREATE TABLE - create the table

=> INSERT - To add/insert data to table

CREATE DATABASE creates a database with the given name. To use this statement, you need the CREATE privilege for the database.

CREATE TABLE creates a table with the given name. You must have the CREATE privilege for the table.

INSERT inserts new rows into an existing table.

Create a simple mysql database, tables and insert data for Library Books and Patron details

First,we need to to have a mysql server installation

$ sudo apt-get install mysql-server

On a default settings, mysql root user do not need a password to authenticate from localhost. In this case, ou can login as root on your mysql server using:

$ mysql -u root

If a password is required, use the extra switch -p:Login as the mysql root user to create database:


$ mysql -u root -p
Enter password:    


Output:

mysql>

Add a database called books

mysql> CREATE DATABASE books;

Now database is created. Use a database with use command:

mysql> USE books;

Now create a table called authors with name, email and id:

mysql> CREATE TABLE authors (id INT, name VARCHAR(20), email VARCHAR(20));

Display your table name just created:

mysql> SHOW TABLES;

Output:
+-----------------+
| Tables_in_books |
+-----------------+
| authors         |
+-----------------+
1 row in set (0.00 sec)

Now add a data / row to table books using INSERT statement:

mysql> INSERT INTO authors (id,name,email) VALUES(1,"Vivek","xuz@abc.com");

Output:
 
Query OK, 1 row affected (0.00 sec)

Add few more rows:

mysql> INSERT INTO authors (id,name,email) VALUES(2,"Priya","p@gmail.com");
INSERT INTO authors (id,name,email) VALUES(3,"Tom","tom@yahoo.com");

Now display all rows:

mysql> SELECT * FROM authors;

Output:
+------+-------+---------------+
| id   | name  | email         |
+------+-------+---------------+
|    1 | Vivek | xuz@abc.com   |
|    2 | Priya | p@gmail.com   |
|    3 | Tom   | tom@yahoo.com |
+------+-------+---------------+
3 rows in set (0.00 sec)
Exit

mysql> exit
Bye

Monday, December 19, 2011

Convert eBooks in Linux

Say you just bought an Amazon Kindle or a Barnes and Noble Nook. You want to convert your eBook collection to .EPUB or .MOBI format. For this, install Calibre. The application not only provides you with a graphical way to manage your eBook collection, but also comes with a set of useful command-line tools. One of these is ebook-convert.
This tool can help you convert between tens of standard formats like EPUB, FB2, LIT, LRF, MOBI, OEB, PDB, PDF, PML, RB, RTF, TCR, TXT, HTML and more. Even CBR and CBZ (comic book formats) are supported.
The syntax is simple:
ebook-convert input_format output_format
For example, if you want to convert a comic book archive to something readable on an e-ink screen, use
ebook-convert filename.cbz filename.epub
or
ebook-convert filename.cbz filename.pdf
Not only will ebook-convert convert the file, but it will also trim the white spaces around the page so they will better fit the small screen of an electronic eBook reader

Block Yahoo Messenger, AOL, MSN and ICQ using IPTABLES

If you’re a network administrator and you’re using Linux on your servers, you can stop the rest of the users from using IM applications by blocking their access to the most-used IM protocols:
ICQ and AOL:
# iptables -A FORWARD –dport 5190 -j DROP

# iptables -A FORWARD -d login.oscar.aol.com -j DR

OP
MSN:
# iptables -A FORWARD -p TCP –dport 1863 -j DROP

# iptables -A FORWARD -d 64.4.13.0/24 -j DROP

Yahoo Messenger:
# iptables -A FORWARD -p TCP –dport 5000:5010 -j REJECT

# iptables -A FORWARD -d cs.yahoo.com -j REJECT
# iptables -A FORWARD -b scsa.yahoo.com -j REJECT

Speed up Samba network access

Dropt these lines into your smb.conf file to speed up Samba access. Find the Global area section and paste them underneath:
read size = 65536

read prediction = true
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192

Depending on your network card and configuration, this should speed up your LAN transfers at least tenfold.

Accessing Samba shares through SSH

Accessing Samba shares through SSH

1diggdigg
In Linux, you can access Samba shares by using a SSH prompt. We need a host PC (65.219.4.23) and a destination PC (192.168.0.81). We’ll use jack as a username but first we’ll create a new mount directory:
mkdir -p /samba/share
Now we connect to it:
ssh -N -L 139:192.168.0.81:139 jack@65.219.4.23 jack@65.219.4.23
Now we do a
umount /samba/share
/bin/mount -t smbfs -o username=jack,workgroup=workgroup_name,password=user_password,
port=139,dmask=770,fmask=660,netbiosname=homecpu
//localhost/share /samba/share

Change your MAC address in Linux

If you wish to change your MAC address in Linux, all you have to do is bring the interface down then use the hw ether switch:
ifconfig eth0 down
ifconfig eth0 hw ether 02:01:02:03:04:08
ifconfig eth0 up

Reset the MySQL password

You forgot your MySQL password. No problem, you can recover it easily. Stop the MySQL service with
# /etc/init.d/mysql stop
…and restart it without a password:
# mysqld_safe –skip-grant-tables &
You’ll get an output similar to [1] 5958. Now press Enter and type the following one after the other:
# mysql -u root

mysql> use mysql;
mysql> update user set password=PASSWORD(”NEW-ROOT-PASSWORD”) where User=’root’;
mysql> flush privileges;
mysql> quit
# /etc/init.d/mysql restart

It’s all done now and you should be able to login with the new password.

Install Firefox 4.0 in Ubuntu 10.10 via apt

The easiest way to install the latest version of Firefox in your Ubuntu is by launching the following command:
sudo add-apt-repository ppa:mozillateam/firefox-stable && sudo apt-get update && sudo apt-get install firefox
This will update your current version of Firefox to 4.0.

Sunday, December 4, 2011

Installation of Microvision Flic barcode scanner on Linux

Use Microvision Flic  Laser Barcode Scanner to catalog your Library collection. Just scan barcodes, no typing needed

Installation instructions

These instructions are for Debian based operating systems (like Ubuntu), but the procedure should be quite similar on any Linux system.
Before using this software you should reset your barcode scanner to factory defaults by scanning the barcode in the user manual. Some of the non-default settings available on the scanner are (not yet?) supported by this software.
  • Download the latest source
  • open a terminal
  • unpack the downloaded file to any directory you like
tar zxvf FlicServ.tar.gz
  • Make sure the two Perl programs are runnable
sudo chmod 755 FlicServ pop
  • Install the required Perl modules and applications
sudo apt-get install libdevice-serialport-perl libthreads-perl  
libthreads-shared-perl xautomation
  • Go ahead and add a global shortcut for the pop application. If you don't know how to do this follow the example in Adding universal shortcuts in ubuntu/gnome but add a shortcut to /path/to/pop instead of /usr/bin/emacs 

Tethered use

This has been tested with the serial cable that comes with the Flic and also the serial cable connected via a R232-USB adapter, but any cable from Microvision should work.
  • First find out which port the scanner is connected to for example /dev/ttyUSB0. I will use /dev/ttyUSB0 in all of the examples from now on. Just switch out /dev/ttyUSB0 with whatever port your scanner is connected to.
  • Open a terminal
  • Start the application
./FlicServ /dev/ttyUSB0
  • Start scanning barcodes. Every time you scan a code you should see the text
pushed xxxxxxxxx
  • in the terminal where xxxxxxxxx is the barcode you scanned.
  • You can also disconnect the barcode scanner from the cable, go away and scan a whole bunch of barcodes, come back and reconnect the scanner. All of the scanned codes should be pushed automatically and the scanner gives you a little blipblipblip to let you know that it's memory is empty.
  • Now open a text document in your editor of choice and hit the global shortcut key you previously added. The first barcode you scanned should now be inserted.
  • The terminal should now show the text
poped xxxxxxxxx
  • This can be repeated as many times as you needed.
  • Pushing and poping can be done in any order, at any time.

--noserver

If you add the --noserver switch when starting the application the application will automatically pop barcodes as soon as you scan them.

--linefeed

If you add the --linefeed switch when starting the application the software will simulate pressing enter after a barcode is poped. --linefeed works both in --noserver and regular mode.

Adding universal shortcuts in ubuntu/gnome

 Adding universal shortcuts in ubuntu/gnome
  • Hit Alt+F2, enter the command gconf-editor and hit Run to launch the Configuration Editor
  • Navigate to apps->metacity->global_keybindings
  • For each keyboard shortcut you wish to add change the value of one of the run_command_x entries where x is a number between 1 and 12. Metakeys must be inserted between <>. For example the key combination Ctrl+Alt+1 you would enter as <Control><Alt>1. For the winkey use <Super>.
  • Navigate to apps->metacity->keybinding_commands
  • For each x you changed in the previous step change the value of the command_x key to the command you wish to be run when pressing the keyboard shortcut.
  • The keyboard shortcut should start working instantly.
Example: To make the keyboard shortcut Winkey+e start emacs do the following:
  • Navigate to apps->metacity->global_keybindings
  • Change the value of the run_command_1 entry to <Super>e
  • Navigate to apps->metacity->keybinding_commands
  • Change the value of the command_1 key to /usr/bin/emacs

Friday, December 2, 2011

LINUX MANUAL FOR LIBRARIANS


Debian Package management tools
dpkg is a  Debian packaging tool which can be use to install, query, uninstall packages.
dpkg  -i packagename 
e.g. dpkg -i bluefish-2.04.deb
How to remove an installed package
dpkg  -r packagename
e.g. dpkg -r bluefish
Other useful dpkg commands
dpkg -r Packagename
Remove/Delete an installed package except configuration files
dpkg -s Packagename | grep Status
To find out if Debian package is installed or not
apt-get  APT is acronym for Advanced Package Tool. It supports installing packages over internet (ftp or http). You can also upgrade all packages in single operations, which makes it even more attractive.
apt-get install Packagename
e.g. apt-get install samba
This command installs packages.....

How to uninstall a package
apt-get remove Packagename
e.g. apt-get remove samba
Directory and File Manipulation
cd - change working directory. E.g. /Home/koha
mv Helps to rename/move location of files/directories
mv f1 f2 renames f1 to f2
rm -rf dirname Kill off an entire directory and all it’s includes files and subdirectories
mv filename Move the file called filename to the /home/dirname /home/dirname directory