This section of the database connection class, he will automatically load SQL anti-injection function, filtering some sensitive SQL query keywords, but also can increase the Judgment Field Show table status of nature and Show table class to get all
Normal query (SELECT statement used to select data from the database)
The SELECT from syntax is used to query read data from a datasheet.
Grammar:
The code is as follows
Copy Code
SELECT Column1,column1,... From
MySQL is not enabled by default, so the Php_mysql.dll Dynamic Connection library must be activated in php.ini. In addition, PHP also needs access to the MySQL Client connection library. The Windows release of PHP includes a Libmysql.dll file that
MySQL date_add (date,interval expr type) and date_sub (Date,interval expr type)
These functions perform date operations. Date is a DATETIME or date value that specifies the starting time. Expr is an expression that specifies the value of a time
For security reasons root accounts are generally accessible only locally, but you may need to open root remote access permissions during development. The following are the basic steps:
1, login to MySQL, for root remote access authorization,
To enable it, you need to set this in the MySQL configuration options file (MY.CNF):
The code is as follows
Copy Code
[Mysqld]Log-slow-queries
This defaults to logging more than 10 seconds of queries to the log
Method One,
The code is as follows
Copy Code
SELECT table_rows from Information_schema.tables WHERE table_name= ' game ' and Table_schema = DATABASE ();
Usage in PHP
PHP code example
The code is
MySQL often need to obtain random data, for example, to take a random record from the TableName table, the general way of writing is:
The code is as follows
Copy Code
SELECT * FROM TableName ORDER by RAND () LIMIT 1
Method One: The best approach is to change the float field to decimal (16,6). Specific methods: You can set a temporary field, combined with the MySQL keyword binary for accurate replication and so on.
Method Two: Use binary keyword to solve. The
Summary of several common MySQL backup methods:
Direct copy of database files
First, the data in memory is flushed to disk, while the data table is locked to ensure that no new data is written in the copy process:
The code is as
A simple way to remove duplicate values from MySQL
Example:
TableID Name1 A2 b3 C4 C5 b
The library structure is probably like this, this is just a simple example, the actual situation will be much more complicated.
For example, I want to use a
Simple Unique index:
A table that can create a unique index. A unique index means that two rows cannot have the same index value. Here is the syntax to create the index table
The code is as follows
Copy Code
CREATE
MySQL Copy table Data operation I believe that we will not be too unfamiliar, the following for you to detail the MySQL copy table data to the new table steps, I hope you will be enlightened.
1.MySQL copy table structure and data to new table
1.linux under the command to start MySQL:
The code is as follows
Copy Code
Mysqladmin start/ect/init.d/mysql Start (Previous installation path for MySQL)
2.linux Restart MySQL command:
The code is
First, modify the Linux default IO scheduling algorithm.
Linux default IO scheduling algorithm for CFQ, need to modify to Dealine, if it is SSD or PCIE-SSD equipment, need to modify to NoOp, you can use the following two ways to modify.1, online
How to view all authorized usersSELECT DISTINCT CONCAT (' User: ', user, ' @ ', host, '; ') as query from Mysql.user;Revoke permissions that have been given to the MySQL user.Revoke is similar to Grant's syntax, just replace the keyword "to" with
First, download mysql5.7http://mirrors.sohu.com/mysql/MySQL-5.7/Linux Downloads:Input command:wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gzSecond, the establishment of users, as well as the MySQL directory1.
Master (Master) ip:192.168.1.101From (Slave) ip:192.168.1.102Master configuration1, first login to the database, create a copy accountMysql-uroot-pMysql>grant replication Slave,reload,super on *.*to [email protected] ' 192.168.1.102 ' identified by '
Install mysql on Mac and macmysqlInstall mysql using the installation package
Double-click the pkg file to install
All the way down, remember to save the password in the last pop-up box (it is your mysql root Account Password)
Under normal
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