mysql

Using Into Outfile in MySQL to Dump Query Results to Text

To save query results to a textfile, use the INTO OUTFILE command at the end of the query. You can also use FIELDS TERMINATED BY "" and LINES TERMINATED BY "" to change the output of the file. You must place the outfile in a directory that is writeable by the MySQL user, so make sure to point the file location to /tmp/. Here's a sample query:

mysql> SELECT *
FROM table_name
WHERE table_id = 1
INTO OUTFILE "/tmp/sample_outfile.txt"
FIELDS TERMINATED BY "|"
LINES TERMINATED BY "\n\n=============\n\n";

| Tags:

Drupal Table Watchdog is Marked as Crashed Error

I ran into a problem the other day where one of my Drupal sites would not open up properly. Drupal is installed atop a MySQL database, and as it turns out, the /var partition had filled up. After removing some of the old log files that I didn't need, I restarted MySQL and found it was running fine for my non-Drupal sites. But, I was still having Drupal problems and noticed the following error in the Admin screen:

| Tags:

Character Set Locations

A few of the programmers in my group were recently talking about how to make sure all of our character sets were identical. Here are all of the places that I have found to control character encoding (for LAMP sites):

mysql

alter database db_name default character set utf8;
alter table table_name default character set utf8;

(to determine character set, use show create database db_name)

php.ini

default_charset = "utf-8"

| Tags:

Create a Tab-Delimited MySQL Dump

To create a tab-delimited MySQL dump, use the -T option in conjunction with the mysqldump command. After the -T, include the folder you would like to place the dump. /tmp is probably the best location, since mysql needs to have write permissions on that folder. The name of the file that will appear is tablename.txt:

[ryans ~]$ mysqldump -u username -p -h localhost tablename -T /tmp

| Tags:
Syndicate content