Save MySQL query results into a text or CSV file
Posted by Quinn McHenry in MySQL
MySQL provides an easy mechanism for writing the results of a SELECT statement into a text file on the server. using extended options of the into OUTFILE
Command method. Note that each line is followed by one; indicates that a command statement ends.Format: grant select on database. * To username @ login host identified by "password" Example 1: Add a user named "test1" with the password "ABC" so
The biggest problem with coding is that
Database a server storage code (assuming the server, database, table, and field are all the same)Database B connection code, which is very critical. After MySQL 5.0 is started, the client configuration in my.
A small experience I have summarized previously, if a large number of records are inserted into MySQL at one time:
1. Use transaction. Enable a transaction for the insert operation.
2. concatenate multiple insert statements into one insert
A few days ago, the company came to a new person and accidentally kicked off the power supply. At that time, my machine was still running the server program.
The above is the background. When I restart the service, I find that connection to the
To optimize the query, try to avoid full table scanning. First, consider creating an index on the columns involved in where and order:
. Try the following tips to prevent the optimizer from selecting a table scan error:
· Use analyze
No reading or reading. It will only be written according to the existing code .... Dumb
Compile an imgstore table created in SAE. The structure of the imgstore table is as follows:
$mysql = new SaeMysql();$mysql->setCharset(GBK);$sql = "SELECT *
MySQL: 1. do not export the statement for table creation, because the table has been created: exported by default, drop table first and then create table; 2. add ignore to the exported insert statement to allow repeated execution: Ignore is not
Content transferred from Sohu gulei PPTGains from viewing MySQL source code
1. provide theoretical basis for Optimization2. Learn the algorithms and ideas for solving the problemFilesort algorithm (Sorting Algorithm) 1. Read all data to be sorted
2.
When using MySQL, you must pay attention to security issues. The following are 23 notes for MySQL:
1. If the connection between the client and the server needs to span and pass through an untrusted network, you need to use an SSH tunnel to encrypt
Let's start with a common example:
1. Get the current time and format it.
DECLARE I INT;SET I = date_format (now (), '% Y % m % D ');
ADDTIME (date2, time_interval) // Add time_interval to date2
CONVERT_TZ (datetime2, fromTZ, toTZ) // convert the
Link: http://imysql.com/node/298
I have previously written about how to obtain MySQL procedure results through PHP. However, this method cannot adapt to multiple result sets. A multi-result set refers to multiple SELECT queries and multiple result
SUBSTRING_INDEX (str, delim, count) mysql> SELECT SUBSTRING_INDEX ('www .mysql.com ','. ', 2);->' www. mysql 'mysql> SELECT SUBSTRING_INDEX ('www .mysql.com ','. ',-2);->' mysql. the usage of the following SQL statement is reprinted:
The results of
I wrote a program yesterday and needed to write a database. I called MySQL's c API. A link error occurred during compilation:
/Usr/lib/MySQL/libmysqlclient. A (SSL. O) :(. GNU. linkonce. D. _ vt_q25yassl7message + 0x8): Undefined reference to '_
MySQLMedium, singleStore procedure (SP)Not an atomic operation,OracleIt is atomic. The following stored procedure, even if the statement2Failed, statement1Will still beCommitTo the database:
SQL code 1-1:
Create table testproc (id int (4) primary
1. Installation
Sudo apt-Get install mysql-server mysql-Client
2. Restart, start, and stop
Sudo/etc/init. d/MySQL restart | START | stop
You can also use this command to shut down the database mysqladmin-u root-p123456 shutdown.
3. Add and modify
[Compile]
Innodb is compiled as a plug-in by default in the form of Dynamic Links (*. so). You can./configure -- help | less to view details.
After installation, it will be placed in./lib/mysql/plugin. The parameters will be loaded later: --
Install the mysql database in Ubuntu. It has just been installed successfully today. Let's summarize the following for the reference:
First, we adopt the simplest installation method, that is, the terminal installation method. Open the
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service