How To Export MySQL data to CSV file
In this article I'll show you how to export MySQL database to a CSV file.
1. Export MySQL data to CSV file using a simple "SELECT" statement
If you want to export your mysql table into a csv file you need to run the following command:
# mysql -u username -ppassword database -e "SELECT * INTO OUTFILE '/tmp/filename.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\r\n' FROM table;"
username is your mysql username
password is your mysql password
database is your mysql database
table is the table you want to export
You can find the exported CSV file in the /tmp directory. The name of the file is filename.csv.
2. Export MySQL data to CSV file using "sed"
If you want to export your mysql table into a csv file you need to run the following command:
Print This PostPHP Security Tips – Securing PHP by hardening PHP configuration
When it comes to security, ignorance is definitely not blissful. There are several methods to increase the security of your PHP environment.
In this article I will discuss how to secure PHP by hardening PHP 5 configuration.
1. allow_url_fopen ( enabled by default )
This directive allows PHP's file functions ( file_get_contents, include and require statements ) to retrieve data from remote locations, like FTP or HTTP.
If an attacker can manipulate the arguments to those functions, they can use a URL under their control as the argument and run their own remote scripts. The vulnerability is called Remote file inclusion or RFI.
; Disable allow_url_fopen in php.ini for security reasons
allow_url_fopen = Off
The setting can also be applied in apache's httpd.conf :
# Disable allow_url_fopen for security reasons
php_admin_flag allow_url_fopen Off
It prevents URLs from being used in PHP. A command like include ("http://www.example.com/evil_script.php") will not be allowed to execute. Only files that reside within your site can be included: include("/var/www/html/config.inc.php").
Print This PostHow To monitor Apache traffic in real-time with apachetop
Apachetop is a very useful program that displays the stats for Apache in real time. Apachetop can show you how many requests per second are coming in, what files have been accessed and how many times. It can also show you who is hitting the sites and where they are coming from.
1. Installing apachetop
To install apachetop in CentOS, Fedora:
# yum install apachetop
Make sure you have DAG repository enabled.
Print This PostHow To mount ISO images in FreeBSD and Linux
An ISO image is an archive file (disk image) of an optical disc using a conventional ISO (International Organization for Standardization) format. ISO image files typically have a file extension of .ISO.
The name "ISO" is taken from the ISO 9660 file system used with CD-ROM media, but an ISO image can also contain UDF file system because UDF is backward-compatible to ISO 9660.
1. Procedure to mount ISO images under Linux
You can mount an ISO image via the loop device under Linux. It's possible to specify transfer functions using loop device.
Print This PostAndroid: How To Set Up ADB/USB Drivers for Android Devices
Before you begin make sure you entirely read the tutorial.
1. Download Android SDK and USB drivers
Download the latest AndroidSDK from Google and extract the AndroidSDK.zip file to C:\AndroidSDK.
Download and install HTC Sync from HTC (HTC Sync is not required for ADB but it's the easiest way to install usb drivers).
If you are using HTC Hero and Microsoft Windows 7 (and you experience problems with driver installation) you have to follow this procedure to install usb drivers and HTC Sync.
Workaround for HTC Hero Sync Problem in Windows 7 – 3 easy steps
Many user who are running Windows 7 are having trouble syncing their HTC Hero to their computer, as the driver is not installed properly in Microsoft Windows 7. The following guide is a workaround.
In order to get HTC Hero synchronizes with Windows 7 do the following:
1. Download latest synchronization tool from HTC, namely HTC Sync.
2. Install HTC Sync program on the computer. At this moment, your computer still unable to recognize your phone.
3. Manually update the HTC drivers for Windows 7, using the following driver
Print This PostHow To Install Tomcat 6 on Ubuntu
Apache Tomcat is a servlet container developed by the Apache Software Foundation. Tomcat implements the Java Servlet and the JavaServer Pages (JSP) specifications from Sun Microsystems, and provides a "pure Java" HTTP web server environment for Java code to run.
1. Install required packages
# sudo apt-get install tomcat6 tomcat6-admin tomcat6-examples
Tomcat depends on a lot of other packages and the package manager will take care of that.
2. Check the services
Make sure the service is responding by entering the following url in a browser:
http://ipaddress:8080/
Replace ipaddress with the ip address of your server
Print This PostHow To Set Up VSFTPD virtual users ( Berkeley DB + PAM )
vsftpd is a GPL licensed FTP server for UNIX systems, including Linux and FreeBSD. It is secure, stable and extremely fast.
vsftpd will handle:
- Virtual IP configurations
- Virtual users
- Standalone or inetd operation
- Powerful per-user configurability
- Bandwidth throttling
- Per-source-IP configurability
- Per-source-IP limits
- IPv6
- Encryption support through SSL integration
- etc...
If you are hosting several web sites, for security reasons, you may want the webmasters to access their own files only. This article describes how you can install and configure vsftpd to work with virtual users.
A virtual user is a user login which does not exist as a real login on the system in /etc/passwd and /etc/shadow file. Virtual users can therefore be more secure than real users, because a compromised account can only use the FTP server but cannot login to system to use other services such as ssh, telnet or smtp.
Print This PostRPM Package manager – Using RPM Commands
RPM Package Manager is a package management system. The name RPM refers to two things: a software package file format, and software packaged in this format.
This document contains an overview of the principal RPM commands for installing, uninstalling, upgrading, querying, listing and checking RPM packages on your Linux system.
To install a RPM package, use the command:
# rpm -ivh foo-1.1-2.i386.rpm
Take a note that RPM packages have a file of names like foo-1.1-2.i386.rpm, which include the package name (foo), version (1.1), release (2), and architecture (i386).
Print This PostInstalling PowerDNS with MySQL backend and PowerAdmin On CentOS
PowerDNS is a MySQL-based DNS server, written in C++ and licensed under the GPL. PowerDNS can be managed through a web interface (PowerAdmin). This guide shows how to install it on CentOS 5.
1. Installing MySQL
# yum -y install mysql mysql-server
2. Enable MySQL on boot and start MySQL server
# chkconfig --levels 235 mysqld on
# service mysqld start
Make sure the MySQL server is running:
# netstat -tap | grep mysql
tcp 0 0 *:mysql *:* LISTEN 28179/mysqld
3. Set password for user root
# mysqladmin -u root password your_password
Print This Post