Since school so many years, have come to learn from an example is the fastest and most effective, and can cultivate a strong practical ability, which is a very
A good way to learn. Try not to visit. For example, when you look at a book, start with
MySQL can be connected to the Web through PHP in two ways, a MySQL-related function via PHP, and another ODBC-related function via PHP
The related functions are as follows:
MySQL function
Mysql_affected_rows: Gets the number of columns affected
MySQL allows storage results to be paged for complex queries.
It seems that few people are talking about paging, are we all addicted to limit m,n?In the case of indexing, limit m,n speed is sufficient, but when searching for complex conditions,where
MySQL server has gone awayThe most common cause of gone away errors for MySQL server has is that the server timed out and closed the connection. By default, if nothing happens, the server closes the connection after 8 hours. You can change the time
CONCAT () is a string concatenation functionReplace () is a string substitution function
CONCAT (parameter 1, parameter 2,...)
CONCAT (String, FROM_STR,TO_STR)Returns the string str, where all occurrences of the string from_str are replaced by
Let's take a look at the MySQL Load data InFile outfile Import Export Oh, this is the way we run the Windows Cmd.exe and then use the following statement in the DOS command method.
Load Data InFile The opposite isSelect * from ' tabletest ' into
Method OneUsing phpMyAdmin, this is the easiest, to modify the MySQL library's user table,But don't forget to use password.function。 Method TwoUsing Mysqladmin, this is a special case of the previous declaration.Mysqladmin-u root-p Password
GROUP by Modify Program。
Imagine a table named sales with a profit column for the year, country, product, and record sales profit:
CREATE TABLE www.111cn.net
(
Year INT is not NULL,
Country VARCHAR is not NULL,
Product VARCHAR not NULL,
General MySQL the most basic page-way:
The code is as follows
Copy Code
SELECT * from content ORDER BY id desc limit 0, 10
In the case of small and medium data, such SQL is sufficient, the only problem to be
Host172.16.0.21172.16.0.22centos6.2Use yum to install MySQL separately
Create a new library for MySQL on 21
CREATE DATABASE ' replytest1 '/*!40100 DEFAULT CHARACTER SET UTF8 * *;
Building a table
CREATE TABLE ' replytest1 '. ' Test1 ' (' ID '
The reason is that many times, in order to secure, do not allow MySQL management tools to connect the formal environment on the line, in this case, you can not rely on the MySQL management tools to transform the code to solve the problem of Chinese
Timed execution Script:
Perform
The code is as follows
Copy Code
CRONTAB-E * * */bin/bash yourpath/mysqlbak.sh
Open an automatic execution file
The code is as follows
Copy Code
Remember, the original and Linux under the solution is not the same.
The code is as follows
Copy Code
# Killall-term MYSQLD//Kill all MySQL processes first#/usr/local/bin/mysqld_safe--skip-grant-tables &
will
The ORDER by null purpose is to force the ordering to be disabled for query results. When you check the query by explain, if you see a using Filesort in the extra column, this has a certain effect on performance, especially when group by is used,
Originally my idea is to use PHP for the loop to execute the SQL statements more than once, but later a thought, doing so in the data is not much good, if more data, query so many times do not know how much resources to consume.
After trying to
In the face of large data volumes, large file SQL operations, we need to rely on MySQL powerful command operations:
1. Database Import command
The code is as follows
Copy Code
Mysql-h Localhost-u Root-pUse dbnameSOURCE
MySQL gets the total number of group statistics for a field that can be retrieved from within the group by, and the number of records grouped is not counted.
The sql_calc_found_rows of MySQL uses the number of rows that get the query to write in
Ysql two ways to view user permission commands:
A. Use MySQL grants
How to use:
The code is as follows
Copy Code
Mysql> show grants for Username@localhost; instance:Mysql> show grants for root@localhost;+----------------
DATE_FORMAT (date, format)Format the date value based on the format string. The following modifier can be used in the format string: % M month name (January ...... December)% W name of the week (Sunday ...... Saturday)% D indicates the date of the
The NOW () function returns the current date and time with ''yyyy-MM-DD HH: MM: s'' and can be saved directly to the DATETIME field.CURDATE () returns today's DATE in 'yyyy-MM-DD 'format and can be saved directly to the DATE field.CURTIME () returns
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