MySQL Database Management Foundation for Linux Operations and Maintenance

What is SQL:
SQL is the standard computer language for accessing and processing databases.SQL (Structured Query Language is Structured Query Language)
Role of the database:
Used to store all user information, all service programs need a database, stored accounts, passwords, usage records, deposit balances, etc., as long as the information must be in the database
Classification of SQL languages:

DDL statement Database definition language: database, table, view, index, stored procedure, such as CREATE DROP ALTER
 DML statement database manipulation language: insert data INSERT, delete data DELETE, update data UPDATE
 DQL Statement Database Query Language: Query Data SELECT
 DCL statement database control language: for example, control user access rights GRANT, REVOKE

Install MySQL database in centos7
1. Network yum source installation
In the command interface, type the following to install.

[root@localhost ~]# wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-server-5.7.25-1.el7.x86_64.rpm
[root@localhost ~]#wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-client-5.7.25-1.el7.x86_64.rpm
[root@localhost ~]# wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-common-5.7.25-1.el7.x86_64.rpm
[root@localhost ~]# wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-libs-5.7.25-1.el7.x86_64.rpm

2. Install by compressing the package
Download the package you need to install

Installation package link:
Link: https://pan.baidu.com/s/1bkZzgyydK1WTfxXNQZpi4g
Extraction Code: jfyh

Import downloaded packages into centos
Import with rz command

Unzip and install with yum command
Note: Installation error requires mariadb to be uninstalled first

[root@localhost ~]# yum remove -y mariadb-libs.x86_64

Use MySQL database
1. Install several required software

[root@localhost ~]# yum  install  -y   net-tools.x86_64    libaio.x86_64    perl.x86_64

2. Start the database and set the boot-up self-start as needed

[root@localhost ~]#systemctl start mysqld
[root@localhost ~]#systemctl enable mysqld
[root@localhost ~]#systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2020-03-11 22:27:36 CST; 20h ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
 Main PID: 1510 (mysqld)
   CGroup: /system.slice/mysqld.service
           └─1510 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mys...

Mar 11 22:27:32 localhost.localdomain systemd[1]: Starting MySQL Server...
Mar 11 22:27:36 localhost.localdomain systemd[1]: Started MySQL Server.

3. Modify the default password for the MySQL database
Default password view

[root@localhost ~]# grep 'password' /var/log/mysqld.log 
2020-03-11T14:27:33.739710Z 1 [Note] A temporary password is generated for root@localhost: G#lk9.6Yo!Sv

G#lk9.6Yo!Sv is the default password for MySQL, we need to set our own login password

Change Password Command

Change password to Abcd12345
[root@localhost ~]# mysqladmin   -uroot    -p'G#lk9.6Yo!Sv'    password    'Abcd12345'

Log on to the database

Here the password input is implicit, enter the set password and log in

View the default database

show databases;

Create a database

Using the yuangong library, create a table1 table inside


View header information

Insert data into a table

View employee data

Change age information for user01

Delete Table

Delete database

This is the basic understanding and operation of the database.

Twenty-one original articles have been published. Zambia 2. Visits 352
Private letter follow

Tags: MySQL Database SQL yum

Posted on Thu, 12 Mar 2020 18:51:30 -0700 by rjs