Install and configure MariaDB, springboot, and centosmariadb in Centos or redhat.
1. Install MariaDB
Installation command
yum -y install mariadb mariadb-server
After MariaDB is installed, start MariaDB.
systemctl start mariadb
Set startup
systemctl enable mariadb
Next, configure MariaDB.
mysql_secure_installation
First, set the password. A prompt is displayed, indicating that the password is entered first.
Enter current password for root (enter for none): <-press Enter directly for the first time
Set Password
Set root password? [Y/n] <-whether to set the root user password. Enter y and press ENTER or press Enter.
New password: <-set the password of the root user
Re-enter new password: <-enter your password again
Other configurations
Remove anonymous users? [Y/n] <-whether to delete anonymous users, press ENTER
Disallow root login remotely? [Y/n] <-whether to disable remote root logon. 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.
MariaDB Initialization is complete. Next, test logon.
Mysql-uroot-ppassword
Complete.
2. Configure the MariaDB Character Set
File/etc/my. vi/etc/my. cnfysqld]
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 configurations are complete. Restart mariadb.
systemctl restart mariadb
Then enter MariaDB to view the character set
mysql> show variables like "%character%";show variables like "%collation%";
Displayed
+ --------- + ---------- +
| 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)
Character Set Configuration is complete.
3. Add users and Set permissions
Create a command using mysql> create user username @ localhost identified by 'Password'; create a user and authorize the user
mysql>grant all on *.* to username@localhost indentified by 'password';
Grant Internet login permission
mysql>grant all privileges on *.* to username@'%' identified by 'password';
Grant permissions and grant permissions
mysql>grant all privileges on *.* to username@'hostname' identified by 'password' with grant option;
This is basically the case for simple user and permission configuration.
Only some permissions are granted to change all privileges or all to select, insert, update, delete, create, drop, index, alter, grant, references, reload, shutdown, process, file.
4. spring boot configuration mariadb Database Link
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialectspring.datasource.url=jdbc:mariadb://localhost:3306/Solrsearchspring.datasource.username=rootspring.datasource.password=123456spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
Add the following dependencies to the pom. xml file:
org.mariadb.jdbc
mariadb-java-client
2.1.2