Use of MariaDB under Centos7

Use of MariaDB database

MariaDB preparation

Database operation

MySQL connection principle

Basic operation

First check whether MariaDB is installed under the virtual machine, use the command line

[root@localhost ~]# rpm -qa|grep mariadb

If it exists, it will appear. The

key lies in the server. If it does not exist , install it with Alisource.

yum -y install mariadb-devel
yum -y install mariadb-server

MariaDB preliminary preparation
1. View the status of MariaDB database

service mariadb status

running means it is turned on

service mariadb stop//关闭数据库
service mariadb start//开启数据库
service mariadb restart//重启数据库
select version//查看数据库版本

2. Configuration file

sudo vim /etc/my.cnf
skip-grant-tables //插入语句,跳过权限验证

Insert picture description here
3. Restart the database

service mariadb restart

Database operation
1. Log in to the database

mysql -u root

Insert picture description here
2. Switch to MySQL database
Insert picture description here
3. Modify the database login password and log in
Insert picture description here

Insert picture description here
4. Exit the database
Insert picture description here
MySQL connection principle
(mysql listening port number: 3306; oracle listening port number: 1521)

1.netstat -anp | grep 3306//查看这个端口有没有在侦听,是否建立链接

Insert picture description here
listen means listening and has established a link

2.ps aux | grep mysqld//查看mysql进程

Insert picture description here
The daemon process mysqld is started during the MySQL startup process. The daemon process judges whether the mysql server is running normally. If the mysql server hangs during use, the daemon process will restart the mysql server.
Insert picture description here

3.域套接字

Essentially, a file is created in the local machine, and the client and server communicate through the file, which is inter-process communication. This inter-process communication uses the network protocol 桟

4.服务端和客户端之间的联系

Thread creation is to service/multithread communication to the client
Basic operation
1. Use the database

use [数据库的名称];  #可以切换数据库

2. View the data table in the current database

show tables;

3. The creation of the database requires a specified character set

create database [数据库的名称] charset=[字符集];//用哪种字符集保存数据

Insert picture description here

4. View the process of creating a database

show create database [数据库的名称]charset=[字符集];

Insert picture description here
latin1 is called the name of the character set

character set:

Insert picture description here
For example, when we create test2,
Insert picture description here
Insert picture description here
we can see that the character set type has become utf8.
5. In the process of storing data, there may be garbled problems
Insert picture description here
. 6. View the current character set

show variables like '%character%';

Insert picture description here
Insert picture description here
7. Delete library

drop database [数据库名称];//连带表也会删掉

If the deleted database is not backed up, it cannot be restored. It is not a blow to delete the database! ! !
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_45657288/article/details/107821818