Connecting to the database
SQL is the core of operating the database, and it is also the sentence at the beginning of this chapter: MySQL for PHP programmers is to convert business into tables structure. Do a good job of adding, deleting, modifying, and checking in the business.
Structured Query Language (SQL), referred to as SQL, is a special-purpose programming language. It is a database query and programming language used to access data and query, update and manage relational databases. System; also the extension of the database script file.
SQL is the most important relational database operating language, and its influence has exceeded the database field and has been valued and adopted in other fields, such as data retrieval in the field of artificial intelligence.
SQL is a database application language for the relational model, developed by IBM in the 1970s for its relational database System R.
SQL is an American standard for database language adopted by the American National Standards Institute (ANSI) in October 1986. Subsequently, the International Organization for Standardization (ISO) promulgated the official international standard for SQL. In April 1989, ISO proposed the SQL89 standard with integrity characteristics, and in November 1992, the SQL92 standard was announced.
Although each database system is slightly different, they basically follow the SQL 92 standard. Or made some simple extensions and changes on SQL 92.
After you learn the SQL syntax of MySQL, you can learn other SQL syntax invariably.
SQL statements can be divided into 3 categories according to their functional scope:
1. Data definition language (DDL, Data Definition Language) statement: Data definition statement, used to define different data Segments, databases, tables, columns, indexes, etc. Commonly used statement keywords include create, drop, alter, etc.
2. Data Manipulation Language (DML, Data Manipulation Language) statements: Data manipulation statements, used to add, delete, update and query database records, and check the integrity of the data. Commonly used statement keywords mainly include insert, delete, update, select, etc.
3. Data Control Language (DCL, Data Control Language) statement: Data control statement, a statement used to control the direct permission and access levels of different data segments. These statements define the database, tables, fields, user access rights and security levels. The main statement keywords include grant, revoke, etc.
Installation method
Method 1
Installation Finally, you can find the command line terminal operation of MySQL Command Line click operation in the list of start menu. The effect is as shown in the figure:
Method 2
If it is added to the windows environment variables, you can Operate directly from the command line.
In the command line, you can connect to the database server through the following command:
mysql -h localhost -u root -p
In the above command: mysql means the mysql database startup tool.
Note: Usually we do not enter the password directly. Instead, enter your password after pressing Enter. Because the characters when entering the password are invisible, you can directly press Enter to log in after entering the password. Prevent anyone nearby from taking away important passwords.
If there are no other problems, the following content will appear after successful login:
mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 7 Server version: 5.6.25 MySQL Community Server (GPL) Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
The Chinese meaning above is translated to mean that you are welcome to use the MySQL command line operation tool. At the end of each command, you can enter \g or ;
mysql is currently connected for the 7th time.
The current database version is the 5.6.25 community support version. Follow the GPL agreement.
Copyright: 2000 to 2015. Owned by Oracle and its subsidiaries.
If you need help, use the ‘help;’ or ‘\h’ command to display the help content, and use the ‘\c’ command to clear the command line history.
mysql>
mysql > means waiting for input instructions.
Note:
There is such a prompt after successful login, which may not be understood by everyone:
Your MySQL connection id is 7
represents the 7th connection login, and the ID is incremented by 1 for each login. The next display will be the 8th time.