vicker313 tech blog

September 8, 2009

Change IP in Command Prompt

Filed under: Windows — Tags: , , — vicker313 @ 8:00 am

In Windows, we can issue the following command to set static IP address in Command Prompt:

netsh interface ip set address "Local Area Connection" static 192.168.0.10 255.255.255.0 192.168.0.1 1

where the 3 IPs are Machine’s IP, Subnet Mask and Gateway

Or to set dynamic IP:

netsh interface ip set address "Local Area Connection" dhcp

Advertisements

Change File Attribute in Command Prompt

Filed under: Windows — Tags: , , — vicker313 @ 8:00 am

To change file attributes in Windows using Command Prompt:

attrib [+|-][ahsr] filename

Where + means enable the attribute, means disable the attribute.

a: Archive
h: Hidden
s: System File
r: Read Only

Example:

attrib +sh filename means make the file a hidden system file

attrib -r filename means make the file not read only

September 1, 2009

Transfer MySQL Database Offline

Filed under: MySQL — Tags: , , — vicker313 @ 8:00 am

Transfer MySQL database offline means, stop MySQL service, copy the database directory and paste it to another location directly. However it will be difference when transferring MyISAM database and InnoDB database:

  • MyISAM: simply copy past the database directory (data\databasename) will do since all the data files are inside the directory
  • InnoDB: need to copy the whole data directory (data), which all the databases will be copied as well. After you paste the directory to the destination, you need to remove the ib_logfile0 and ib_logfile1 before start the MySQL service

Choose Between MyISAM and InnoDB in MySQL

Filed under: MySQL — Tags: , , — vicker313 @ 8:00 am

We can choose how the data store in table at MySQL, by defining the storage engine:

create table test (id int) engine = [myisam|innodb];

It will use the default storage engine stated at database if the engine option in create statement is not defined. Two commonly used storage engines:

MyISAM

  • Fast in select and insert
  • Less reliable
  • No foreign key checking, where user can inset foreign key that does not exist
  • All the files (FRM, MYI and MYD) are placed at database directory (data\databasename), which make the transfer of database is easy
  • Each database data is stored in different data files and directory
  • No need to maintain

InnoDB

  • Slow in select and insert
  • More reliable
  • Has foreign key checking
  • Only FRM files are placed at database directory (data\databasename), while other files like IB_LOGFILE0, IB_LOGFILE1, IBDATA1 and MYSQL-BIN files are placed at data directory, which you need to copy the whole data directory when transferring database
  • All databases data are mixed in a single data file
  • Need to maintain the database from time to time by purging the binary log
    PURGE BINARY LOGS TO 'mysql-bin.010';
    Or
    PURGE BINARY LOGS BEFORE '2008-04-02 22:46:26';

Blog at WordPress.com.