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
service mariadb stop//关闭数据库
service mariadb start//开启数据库
service mariadb restart//重启数据库
select version//查看数据库版本
2. Configuration file
sudo vim /etc/my.cnf
skip-grant-tables //插入语句,跳过权限验证
3. Restart the database
service mariadb restart
Database operation
1. Log in to the database
mysql -u root
2. Switch to MySQL database
3. Modify the database login password and log in
4. Exit the database
MySQL connection principle
(mysql listening port number: 3306; oracle listening port number: 1521)
1.netstat -anp | grep 3306//查看这个端口有没有在侦听,是否建立链接
listen means listening and has established a link
2.ps aux | grep mysqld//查看mysql进程
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.
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.服务端和客户端之间的联系
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=[字符集];//用哪种字符集保存数据
4. View the process of creating a database
show create database [数据库的名称]charset=[字符集];
latin1 is called the name of the character set
character set:
For example, when we create test2,
we can see that the character set type has become utf8.
5. In the process of storing data, there may be garbled problems
. 6. View the current character set
show variables like '%character%';
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! ! !