LOAD DATA LOCAL INFILE '/importfile.csv'
INTO TABLE test_table
FIELDS TERMINATED BY ','
Wednesday, November 11, 2009
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
Tuesday, April 7, 2009
Command of the day
date +"%m-%d-%y" | awk '{print "filename filename" $1}'| xargs mv
The command above will rename a filename into filename with date of the day.
Wednesday, March 18, 2009
Command of the day
ps aux | grep http | awk '{print $2}' | xargs kill
Wednesday, March 11, 2009
Install FreeTDS on Ubuntu
I've been struggling to install FreeTDS on Ubuntu. Fortunately, google is still the best friend. I found the link below and manged to install it.
http://ubuntuforums.org/showthread.php?p=6823026
I copied the posting here as well. Thanks for Mahalie for the post.
-----------------------------------------------------------------------------------------------
After a lot of doc reading at PHP.net, FreeTDS and here and trying and then backing out of several attempts to get my Ubuntu Lamp on Dapper Drake LTS to connect via ODBC to a Microsoft SQL Server on our corporate network I found a step-by-step tutorial that worked for me here:http://benlinus.blogspot.com/2007/08...module-in.html
Here is how I did it - already running working LAMP with PHP5.
add the following line:
To confirm if MSSQL support is available, create a new php file and execute phpinfo() function.
To test my connection tried code from PHP.net using MSSQL_CONNECT
If you don't have errors, it's working. If you have 'cannot open default DB' then make sure your permissions for the user is set property on the MS SQL server and that their default database is the one you are pointing at.
Here is how I did it - already running working LAMP with PHP5.
Code:
sudo apt-get install freetds-dev sudo apt-get source php5 cd php5-5.1.2/ext/mssql sudo apt-get install php5-dev sudo phpize sudo ./configure --with-mssql sudo make cd modules cp mssql.so /usr/lib/php5/20051025 sudo vi /etc/php5/apache2/php.ini
Code:
extension = mssql.so
Code:
sudo /etc/init.d/apache2 restart
To test my connection tried code from PHP.net using MSSQL_CONNECT
PHP Code:
// Server in the this format: \ or
// , when using a non default port number
$server = 'DBSERVERNAME.corp.DOMAIN.com';
$link = mssql_connect($server, 'UserName', 'UserPassword');
if(!$link)
{
die('Something went wrong while connecting to MSSQL');
}
?>
Test
Monday, February 9, 2009
Yahoo Messenger
I'm installing a firewall, and discover that users need to treat Yahoo Messenger differently for a specified group. Therefore I need to know which ports are being used by YM.
Here are list of the ports:
- Messages: 5050, 80, 23 and any port
- Voice: 5000 and 5001
- Webcam: 5100
Subscribe to:
Posts (Atom)