MySQL database from entry to proficiency (Part 1)

What is a database?
    Excel is a data table, and human-operated MySQL is a database, which is convenient     for program     operation
    and storage of data of more than one million levels         . After each command;         2, case insensitive
    



1. Install the database and configure it, you can use Baidu. All default, just set the user name and password.

        -> Select development mode

        -> Check whether the dependent environment has been installed, and click "Next". Select "Yes" in the pop-up prompt box, and then select "Execute".

 ->The default network configuration is fine, the port number is 3306

--> Next, configure the account password. The default super administrator account: root, which is the account with the most authority. The above is to set the password of the super administrator account, and you can also click "AddUser" to add an account.

 

 -> Next, the default is fine, and a service named MySQL57 will be started, which is a program without a UI interface, which can be seen in the task manager.

 -> still default

 -> Now that the first one is configured, let's configure the second one. Still click "Next".

 ->In the pop-up interface, we click "check" to see if we can connect to the database, and a green tick is displayed to indicate that the connection is successful. Click Next and Execute.

 -> When this interface appears, the installation is complete. Click "Finish" to open MySQL Workbench, which is a database editing software.

2. Startup and shutdown

        Versions 5.7 and later can use MySQL Notifer to open. For all versions, you can also right-click "My Computer->Management", open the computer management interface, find "Services and Applications->Services", find MySQL57, and then right-click to start or stop to start and shut down.

3. How to operate MySQL

        It can be operated through the MySQL Workbench editor, which is a UI software that can operate the database. After installing MySQL, you can search for MySQL to find all MySQL-related programs, and you can pin them on the start menu and taskbar.

4. How to use MySQL Workbench to connect to the database

        After opening the MySQL Workbench editor, there is a "+" button in the upper left corner to create a new database link with any name, and then enter the user name, password, ip address and port number.

5. How to use MySQL Workbench to view and create databases

        Right click on the blank space -> Create Schema to create the database. It is necessary to fill in the database name and character encoding format, and we need to select the utf8 type that supports Chinese format. Then we click the Apply application on the lower right, and a dialog box will pop up, which means that the database is not case-sensitive, and we can click OK. Then click Apply and Finish on the pop-up interface. Then we can see the database db1 we created.

 

 

-> To view the database, select a database, that is, a sub-item under Tables, and then right-click to select the first option "Select Rows-Limit 1000"

 6. Table creation

Select Tables under the database db1 we created, right click and select "Create Table" to create a table. Then fill in the table name and the name and type of each column in the table. For the type, you can view the DateType introduction on the MySQL official website. INT represents an integer, VARCHAR(20) represents a string, and the numbers in the brackets represent the maximum length of the string. Then click OK, Apply.

 

7. Add, delete, modify and check MySQL

After creating the Table, we can't add data yet, so we need to add the primary key. Right-click Alter Table or click the "wrench" icon on the right side of the table. After opening, find the username line, check PK, NN will be automatically checked, PK means primary key, NN means cannot be empty, UQ means cannot be repeated, AI means automatic growth, and then click "Apply" in the lower right corner. At this time, we found that data can be added under username and password. After adding data, remember to click "Apply" in the lower right corner, so that the data will be saved in the database. Note that the primary key username cannot be duplicated.

-> Click directly on the blank item below to add data.

-> Select a row and right-click to select "Delete Row(s)" to delete the data.

->Directly select a row of data to modify it.

After all operations are completed, click "Apply" in the lower right corner to apply.

       

8.13- Differences and similarities between primary key and Unique Key (UQ)

Generally, we will add an id to be used as the primary key. Check AI to indicate automatic growth. When we add data and click Apply, the id will automatically increase. There is one and only one primary key, just tick one, don’t make any showy operations, you will cheat yourself. UQ means not to repeat.

 

 

Guess you like

Origin blog.csdn.net/qq_34256136/article/details/128288145