MySQL Basic understanding "relational database and NoSQL, MySQL operation process and system, library operation, table operation, data operation, character set operation, and PHP as client operation database" There is no doubt about the connection itself

Source: Internet
Author: User
Tags php script mysql command line

1. Relational database
Repository for permanent data storage
PHP variables are only temporary storage space "use memory space" to save variables during PHP script execution.

Relational database: Use the relationship between the two to describe the entity information. "Using two-dimensional table field names and fields values to describe"
"Relational databases are not meant to use foreign keys to construct two tables as associations, but rather to implement the form of a two-dimensional table that describes entities."

Nosql:not only SQL "SQL represents the language for manipulating relational data"
So NoSQL is referring to the non-relational database "typically data of key-value pairs (Redis, memcache)"
"NoSQL can add information as it is, without needing to correspond to all the content of the information (reducing the input information)"
"Non-relational database is the data for fast reading and flexible structure"
Cached data is basically a nosql type

The problem between the ranks of the relational database "No need to be too tangled"
SQL: Structured Query Language "i.e. relational database language"


2. Procedures for working with MySQL
Database System "MySQL itself is a database system. The system is a complete set of tools for manipulating data. "
Data System = The subject part of the database "+ Data management System" the operational data of the tool system "
MySQL itself also needs to store the data "this needs to be noticed in daily life"

Database operations are basically the C/S architecture "requires the client, SQL Server extension is the same"
C/S Architecture "different servers provide different ways of terminal access"
b/S Architecture "b/S architecture is accessed via HTTP protocol, different servers are consistent and require browser access"

"MySQL Operation Flow"
MySQL service is provided through the MYSQLD process
The MySQL client "first needs to connect and authenticate the service, then issue an operation instruction, then the MySQL service accepts the instruction, then executes the instruction and returns the execution result"
The above interaction is a normal connection "last disconnect"

The MySQL service process is mysqld "itself has instruction set, configuration related, and related connection processing situation"
MySQL client is the MySQL command line end


3.mysql Server System
PHP uses the extension to operate MySQL, at this time the PHP process through the connection to operate mysqld, to achieve the operation of the data. At this point the PHP script process is the MySQL client

The concept of data storage:
Data exists under fields, and then multiple fields are stored in one piece of data, and more than one piece of data is combined into a single table. The last multiple tables form a library, and then a database server is composed of multiple libraries

That's the constituent body of the data. "A more detailed understanding of the database"


4. Library Operations
Delete and change "operation and command"

"Data Storage"
DataDir This configuration configures the location of the library where the database data resides "as the content of the stored data"
Because MySQL is placed under the system for each inventory, it is sensitive to case sensitivity depending on the system "Windows and Linux"
Special keywords cannot be the name of the database "but you can use the anti-quotation marks, the Special keyword is wrapped to declare that the keyword is the name" "But when you create a library, do not use special words to do the library name can be"
Anti-quote "use in MySQL" "Reverse quotation mark next to the 1 key"


5. Table Operations
Use library name "SELECT Database"
Use the library name to specify a scope, and then use the library name to implement the file's determination of "form of data storage"

Create a field in a table "because MySQL has a fixed data type, you need to specify the data type when you create it (strongly typed)"
Adding and deleting the problem of the operation "These are nothing"


6. Operation of the data
Operations on the data
It's basically about a row of data.
Change and delete

' = ' in sql is ' = = ' "There are no assignment statements in SQL"

7. Character Set operation
Character set "GBK and UTF8"
Describes the graphics that are visible and the encoding that is transmitted when it is called a character set. "Is that you've already set up a graphic to display the assumed character"

The encoding of the data store "encoding itself is assumed to be good in the OS"
Different character set selections can be implemented only when used in a database system.
CharSet can

The encoding of the data is also mapped to the field.
"How to determine the encoding"
(1) First look at the code of the field, if it exists, determine
(2) If the field does not have an encoding set, view the encoding of the table. If there is, determine the data encoding
(3) If the table is not encoded, find the encoding of the library
(4) If the library does not have an encoding, then use the system to determine "or MySQL configuration file set default encoding"
"So in real-world programming, it's simple and clear to use libraries to set up code. This also has the priority of encoding selection "

Note: The client operation, the encoding of the query (which is often required in the project.) This is the focus of coding consistency) "
(1) Encoding of the data sent by the client "set names code to declare what the encoding of the data passed by the client is"
(2) The client receives the data encoding of the server
(That is, we need to specify the encoding passed in the PHP script and ensure that it is consistent with the code of the MySQL service "This is the focus of coding consistency")
"and the PHP script to get MySQL results after the display also need to and the script itself encoding consistency processing, to ensure the consistency of the coding display!!! 】

8.php Operational Database
"This piece does not need to be too imagined, normal thinking can be."
PHP uses PHP extensions to establish a connection to the MySQL service. "Connect Authentication"
The connection problem can be understood correctly by sending PHP SQL statements as URL-addressable.

"As for how the client and MySQL services connect with the network SSH connection is no different, only need to declare IP, port and user information can be verified." "" and the number of connections is no different from the number of nginx connections.
"Have an understanding of network connections"

MySQL Basic understanding "relational database and NoSQL, MySQL operational processes and systems, library operations, table operations, data manipulation, character set operations, and PHP as client operations database" No questions about the connection itself

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.