[Daily update-mysql base]-1. Know MySQL

Source: Internet
Author: User
Tags mysql client

1. Database

The operation of the program requires a lot of data support, such as we want to calculate 1+2= in the program? , then we need to put the numbers 1 and 2 in memory, or even put them in a variable, before we can do the math.


For example, we are going to design a program to query the weather information for each day of the past five years, how to design it, we are not likely to run the program every time, let the program on the Internet to crawl the past 5 years of all the weather information, so time-consuming and laborious. This time we need to use the database to help us to save the last five years of weather information, and in accordance with the format we need to save, until we want to query, directly from the database to be taken out, display to the user can be, thus saving the time to crawl online resources, but also reduce the data structure of the efficiency. In a swoop n get,


So we need to remember a word, the operation of the program, without data, more said that the program is actually the operation of data.


This shows that the data is a very important part, if the learning process, do not make the data clear, the program itself is not any egg.


1.1 What is a database

A database is a warehouse that organizes, stores, and manages data in accordance with its data structure. To put it more simply, a database is a place to store data.


In our cognition. Water cups are used to fill water, so for water, the Water Cup is the database. And what can be used to store things in the computer world?



The Excel file is used to save the table. Word documents are used to store text information.


Then we know now, in the computer, the file is used to save information, the information here is the data, but the data type is different, such as JPG file is used to save the picture, the data is the picture type.


So the question is, where does the file exist?


Files are stored under the folder, in Linux, folders are called directories, and all files are stored in the directory.


The same reason, the database is the same, the database is a large folder, the folder is saved a lot of files, the file is stored in the data we want to store.



1.2 Common databases

For PHP, MySQL database is the most common, MySQL is the world's most popular open source database, currently belongs to Oracle Company. It is a relational database. The relational database is a database system based on the relational model. A relational model refers to a two-dimensional tabular model, similar to an Excel table. and its corresponding non-relational database, called a NoSQL database, such as MongoDB.


1.3 Common concepts of databases

Library: The library is the sum of some column data tables. As we said before, the entire database system is a large folder, and a library is a small folder under this large folder.

Table: The entity that records the data, which is the file that holds the data, is placed under the Library folder.

Row row: A row of data, a row of data with structure, similar to a row of data in Excel

Column columns: A column of data,

Recording record: A piece of data is also called a record

Fields field: A column is also called a field, usually a field will have a name

SQL: Used to release the specified language to the database, the database is managed by SQL, for example, to add a new piece of data, you need to write an SQL statement.


MySQL uses the C/s architecture, that is, the need to install MySQL server and MySQL client, link to the server through the client, and then the client by writing SQL statements to manage the database.


2. Install MySQL

If you are using an integrated environment, basically comes with MySQL server and client, so do not install, if not, you need to download a MySQL installation package on the MySQL official website, installation package installation is simple, are visual interface, directly according to the prompt installation can be, it should be noted that When installing, select the installation directory, you must choose the directory without Chinese, or bring some unnecessary trouble.


2.1 Starting the MySQL server

The simplest way to do this is to find Mysqld.exe running it in the MySQL installation directory.

Of course, as programmers, we prefer to use command-line mode, which is used in CMD:

net start MySQL start MySQL server

net stop MySQL stop MySQL server


2.2 Using the MySQL client

With the server, that is, in our computer has been installed on the database server, this time we need to manage the database, we have to use the MySQL client, of course, there are many database management tools, such as: PhpMyAdmin, Navicat and so on. Or that sentence, directly on the command line, open cmd. In cmd, go to the MySQL installation directory, locate the bin directory, and then use the MySQL command to use the MySQL client.


For ease of use, it is recommended that the directory where the client commands reside is set to the environment variable.


3. Connect to MySQL

Command:


Mysql-u <username>-P

The simplest connection Database command,



-U: Specifies the user name of the login database, typically root. Because a root account is created by default

-P: Specifies the password. After entering the above command, you will be prompted to enter a password after pressing ENTER.


MySQL can also pass in other parameters:

-H: Specifies the database server address of the connection, if not specified, will default to localhost, which is the native

-P: Specifies the port number of the database, which is 3306 by default. If you modify the port number, you must specify.



[Daily update-mysql base]-1. Know MySQL

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.