Wednesday, November 11, 2009

import CSV into mysql

LOAD DATA LOCAL INFILE '/importfile.csv'
INTO TABLE test_table
FIELDS TERMINATED BY ','

Export a table on MySQL

select * into outfile '/tmp/outfile.txt' fields terminated by ',' from my_table_name;

Thursday, October 22, 2009

Install TC Expect on Ubuntu

I have an Ubuntu machine, and want to install Expect on this machine using apt-get.
However, the current version of TCL doesn't have Expect. Therefore, I have to remove tcl8.3 first prior to install expect

Here are the steps
# apt-get remove tcl8.3
# apt-get install tcl
# apt-get install expect

Missing Expect on ActiveTCL

Previously, Expect is included on ActiveTCL installation. But regarding to the size of the installer, the new version doesn't have Expect included on the installer.
We need to redownload Expect and install it.

Here is the command to do that:
teacup install Expect

Monday, September 28, 2009

Restore mysql database from command prompt

mysql - u user_name -p your_password database_name < file_name.sql

Thursday, September 24, 2009

My note on creating a user

To avoid wasting time and reinventing the wheel every time I created a new user on my server, I think I have to record the steps so I can save my time

Here are the steps:
1. adduser username
2. edit /etc/httpd/conf/extra/directadmin-vhosts.conf
3. create a new file, /etc/httpd/conf/extra/user-username.conf
4. Use :%s/oldstring/newstring/g to edit the file above
5. service httpd restart
6. Set quota for the user

If the user needs MySQL, need the following steps also:
1. mysql -u admin-name -p
2. create database;
3. grant all privileges on database.* to username@localhost identified by 'password';

That's it.

Quota in Linux

To set quota for the user, use the command below:
/usr/sbin/setquota

Then to see the quota, use the command below:
/usr/sbin/repquota