Linux Centos or redhat install MariaDB and spring boot configuration using mariaDb

1. Install MariaDB

install command

yum -y install mariadb mariadb-server

After installing MariaDB, start MariaDB first

systemctl start mariadb

set startup

systemctl enable mariadb

Next, perform simple configuration related to MariaDB

mysql_secure_installation

The first is to set the password, and you will be prompted to enter the password
Enter current password for root (enter for none): <– Press Enter for the first
run
Set root password? [Y/n] <– Whether to set the root user password, enter y and Press Enter or press Enter directly
New password: <– Set the password of the root user
Re-enter new password: <– Enter the password you set again
Other configuration
Remove anonymous users? [Y/n] <– Whether to delete anonymous users, return Car
Disallow root login remotely? [Y/n] <–Whether to prohibit root remote login, press Enter,
Remove test database and access to it? [Y/n] <– Whether to delete the test database, press Enter
Reload privilege tables now? [ Y/n] <– Whether to reload the permission table, press Enter to complete the
initialization of MariaDB, and then test the completion of logging in to
mysql -uroot -ppassword
.

2. Configure the character set of MariaDB

File /etc/my.vi /etc/my.cnfysqld] label added

init_connect='SET collation_connection = utf8_unicode_ci' 
init_connect='SET NAMES utf8' 
character-set-server=utf8 
collation-server=utf8_unicode_ci 
skip-character-set-client-handshake

file /etc/my.cnf.d/client.cnf

vi /etc/my.cnf.d/client.cnf

add in [client]

default-character-set=utf8

file /etc/my.cnf.d/mysql-clients.cnf

vi /etc/my.cnf.d/mysql-clients.cnf

add in [mysql]

default-character-set=utf8

All configuration is complete, restart mariadb

systemctl restart mariadb

Then enter MariaDB to view the character set

mysql> show variables like "%character%";show variables like "%collation%";

shown as

+————————–+—————————-+
| Variable_name | Value |
+————————–+—————————-+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+————————–+—————————-+
8 rows in set (0.00 sec)
+———————-+—————–+
| Variable_name | Value |
+———————-+—————–+
| collation_connection | utf8_unicode_ci |
| collation_database | utf8_unicode_ci |
| collation_server | utf8_unicode_ci |
+——————-+————–+
3 rows in set (0.00 sec)
The character set configuration is complete.

3. Add users and set permissions

Create a command to create a user and authorize it with mysql>create user username@localhost identified by 'password';

mysql>grant all on *.* to username@localhost indentified by 'password';

Grant access to external network

mysql>grant all privileges on *.* to username@'%' identified by 'password';

Grant permission and can authorize

mysql>grant all privileges on *.* to username@'hostname' identified by 'password' with grant option;

Simple user and permission configuration is basically the same.
Only some permissions are granted, and all privileges or all are changed to select, insert, update, delete, create, drop, index, alter, grant, references, reload, shutdown, process, and file.

4. Spring boot configure mariadb database link

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
spring.datasource.url=jdbc:mariadb://localhost:3306/Solrsearch
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver

Add the following dependencies to the pom.xml file

<!-- https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client -->
<dependency>
    <groupId>org.mariadb.jdbc</groupId>
    <artifactId>mariadb-java-client</artifactId>
    <version>2.1.2</version>
</dependency>

Linux System Tutorial: How to Check MariaDB Server Versionhttp :
//www.linuxidc.com/Linux/2015-08/122382.htm Implementation of MariaDB Proxy Read-Write Separationhttp : //www.linuxidc.com/Linux/2014- 05/101306.htm
The method of compiling, installing and configuring MariaDB database under Linuxhttp : //www.linuxidc.com/Linux/2014-11/109049.htm CentOS system uses yum to install MariaDB database http://www.linuxidc.com/ Linux/2014-11/109048.htm Install MariaDB and MySQL coexist http://www.linuxidc.com/Linux/2014-11/109047.htm How to migrate MySQL 5.5 database to MariaDB 10 on Ubuntu http://www. linuxidc.com/Linux/2014-11/109471.htm [Translation] Install MariaDB on Ubuntu 14.04 (Trusty) Server http://www.linuxidc.com/Linux/2014-12/110048htm For a detailed introduction to MariaDB: please click here MariaDB The download address: please click here For more information about CentOS, see the CentOS special page






http://www.linuxidc.com/topicnews.aspx?tid=14

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326164795&siteId=291194637