1, check and modify the MySQL my.ini configuration file
Copy Code code as follows:
Default-character-set=utf8
2, the establishment of the database is to specify the character set
Copy Code code as follows:
DEBIAN6 System:
First install MySQL bar:
Open terminal (root) User Login
Apt-get Purge mysql-server-5.5
After the installation is complete:
By default, MySQL only allows local logins, so you need to modify the configuration file to bind
1. CREATE indexIndexing is especially important for queries as a major application. Most of the time the performance problem is simply because we forgot to add the index, or we didn't add a more efficient index. If you do not index, then look for
MySQL has been supporting inserts since version 4.1 ... On DUPLICATE KEY UPDATE syntax, which requires 3 SQL statements (select,insert,update) to be executed, and reduced to 1 statements to complete.
For example, the Ipstats table structure is as
MySQL default data file storage directory/var/lib/mysql, now to modify the directory to/home/data/mysqlCd/homemkdir data//In the home directory to build the data directoryMysqladmin-u root-p shutdown//stop MySQL service process:mv/var/lib/mysql/home/
One, the most common MySQL most basic way to paging:
Copy Code code as follows:
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 aware of
View database status:service mysqld Status
Start database:service mysqld start
Access to the database:mysql-u root-p123456;
List database: showdatabases;
Select database: UsedatabaseName;
List table: showtables;
Displays the properties of the
When the website runs very slowly, I especially know why so slow, so I check, the database is absolutely an important part of the running SQL is absolutely can not let go. Usually when doing projects, I will also pay attention to the writing of SQL
How to recover after MySQL mistakenly deletes ibdata1
If you mistakenly delete the MySQL innodb related data file ibdata1 and log file ib_logfile* in the online server,How should it be recovered?
It's supposed to be a cold sweat, right?============
Data replication classification between database tablesWhen using database development, the data between some tables is often imported into each other. Of course, you can write program implementation, but the program often needs to develop the
This time mysqldump may not be very good, use the following method can solve this problem.Method One, insert, and select in conjunction with
1, create a new table, such as New-table, contains the name of the field to be exported, such as A,b,c2.
Optimization principle: Small table driving large table, that is, small data sets drive large datasets.
############# principle (RBO) #####################
SELECT * from "A where ID" (select ID from b) is
equivalent to: For
select IDs from B
When using MySQL, if you find that transactions can not be rolled back, but hibernate, Spring, JDBC and other configurations are not obvious problems, do not worry, first look at the table MySQL created there is no problem, that is the type of table.
Suppose that the two table a,b,b is associated with a table through a field ID, and a table has a one-to-many relationship with Table B. Assuming that a field name exists in table B, you now need to query the records in table A. Get the name
Compared to other methods to achieve MySQL's read and write separation, the use of thinkphp framework to achieve MySQL read and write separation is simple and easy-to-use, the configuration file sample code is as follows:
' Db_type ' => ' mysql
When our website reaches a certain scale, the various optimization of the website must be carried out. And the optimization of the website, for the database optimization is the most important. The following author will share with you the
In the MySQL database, Opened_tables represents the number of open tables, the following is a detailed description of the reasonable configuration of the MySQL open_table.
MySQL Opened_tables represents the number of open tables, and the following
Method 1: Using the Set password command
Mysql-u root
mysql> SET PASSWORD for ' root ' @ ' localhost ' = PASSWORD (' Newpass ');
Method 2: With Mysqladmin
mysqladmin-u root Password "Newpass"
If Root has already set the password,
The environment: under the virtual machine
Server: Ubuntu 14.04 LTS
Database: 5.5.37Port: 3306
Main ip:192.168.63.133
From ip:192.168.63.134
Authorized account:
User:suxh
password:111111
All right, finish up. Environment: We directly
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.