Create and delete indexes
The creation of the primer can be done in the CREATE TABLE statement, or you can add indexes to the table separately with the CREATE INDEX or ALTER TABLE. The deletion index can be implemented using ALTER TABLE or DROP
MySQL writes data usually with INSERT statements, such asINSERT into Person VALUES (John, 20), (Dick, 21), (Harry,) ...;
Sometimes, however, you need to import data from text or export data to text in order to insert large amounts of data or
Recently encountered such a problem, in the MySQL stored procedure, the cursor operation, you need to perform a conitnue operation. As we all know, there are three kinds of cursor loops in MySQL, loop,repeat,while three loops, the same way. Never
MySQL under INSERT and update triggers can no longer use the update and insert operations, the official explanation is to prevent the death cycle, the solution is directly to new in the field assignment, but also very convenient, but also explains
The MySQL service failed to start properly because it was not properly shut down. After reinstalling then still cannot enter the root account hint 1045 error.
Workaround:
1. Stop Service
2, modify My.ini, find "mysqld", add a line under it
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
The usual way to set up a self-add field:
Add when creating a table:
CREATE TABLE table1 (ID int auto_increment PRIMARY key,...)
Add after creating a table:
ALTER TABLE table1 Add ID int auto_increment primary key self-add field, be sure to set
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
1. Database operationGo to command line: mysql-uroot-p123456View database: show databases;View Database creation statement: show create DATABASE test;Creating the database: Create DB test CharSet UTF8MB4;Select database: Use test;Delete database:
MySQL Version: 5.7The new version of the My.ini file has been changed, resulting in a method that previously enabled the query log is no longer applicableThe new version is enabled in the following ways:1. Modify the C:\ProgramData\MySQL\MySQL
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
MySQL Index basics
Basic concepts:
An index is a special database structure that can be used to quickly query specific records in a database table. Indexes are an important way to improve database performance. An index is created on a
1. First verify that the server is in a secure state, that is, no one can connect to the MySQL database arbitrarily.Because the MySQL database is completely password-protected during the reset of the root password of MySQLStatus, other users can
Lamp or LNMP environment, if MySQL is installed independently, you need to authorize:
Standalone installation of MySQL on a single server
After installation, optimize the server.
Authorized
Examples are as follows:Create
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.
An introduction to the optimistic and pessimistic locks in MySQL and how to use them simply.
The probability of being asked about the optimistic lock and pessimistic lock interview in MySQL is still relatively large.The pessimistic lock of MySQL:
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 '
Using putty to operate MySQL database is not very convenient, just want to use navitcat ssh to connect to the remote MySQL server, you can dynamically modify the data operation. According to the opinions of many netizens online, landlord use the
Mysql uses one table to update another table. mysql updates another table.
Solution 1: Modify 1 column
Update student s, city cSet s. city_name = c. nameWhere s. city_code = c. code;
Solution 2: Modify multiple columns
Update a, B
Set a. title =
Mysql uses group by for group sorting and mysqlgroupby for group sorting
Yesterday, I had a need to deduplicate and rank the database data. The same user had the highest score, the lowest time, and the earliest data to participate in the activity.
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