How to install the database mysql in centos

switch user

1. Switch to the root user for operation

Install the service client

1. Install mariadb service

yum install -y mariadb-server

2. Install mariadb command line client

yum install -y mariadb

3. Install mariadb C library

yum install -y mariadb-libs

4. Install mariadb development kit

yum install -y mariadb-devel

Modify file configuration

1. Change the /etc/my.cnf.d/client.cnf file
[client] and add a line of configuration default-character-set=utf8
insert image description here
2. Change the /etc/my.cnf.d/mysql-clients.cnf file
[mysql] and add a line of configuration default-character-set=utf8
insert image description here
3. Change /etc/my.cnf.d/server.cnf configuration
[mysqld] add configuration
collation-server = utf8_general_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
sql-mode = TRADITIONAL
insert image description here

start test

1. Restart the service

systemctl restart mariadb

2. Set the service to start automatically

systemctl enable mariadb

3. View service status

systemctl status mariadb

insert image description here

use

1. Use the command line client to try to connect, and there is no password by default

mysql -uroot

insert image description here
2. View the mariadb version number

select version();

insert image description here
3. Check the character set configuration

show variables like '%char%';

insert image description here

set password

1. Exit the mysql server and return to the shell

mysql_secure_installation

You will be prompted before entering the password, just enter Y, and then you will enter the password twice. After the input, you will be prompted to enter all Y
insert image description here
2. Use the command line client to try to connect (with password)

mysql -uroot -p

insert image description here
insert image description here
The installation is complete

Guess you like

Origin blog.csdn.net/qq_44443986/article/details/117782240