CENTOS7 use YUM to install MARIADB

Now in the server configuration database, usually directly configure MariaDB, it can achieve mysql database connection.

1, install MariaDB

Installation Commands

yum -y install mariadb mariadb-server

Installation MariaDB, first start MariaDB

systemctl start mariadb

Set boot

systemctl enable mariadb

Next related simple configuration of MariaDB

mysql_secure_installation

First, set a password, you will be prompted to enter the password

Enter current password for root (enter for none): <- Enter the first time directly run

set password

Set root password [Y / n] <- whether to set the root password, enter y and press Enter, or just press Enter?
New password: <- set the root password
Re-enter new password: <- Re-enter your settings password

Other configurations

? Remove anonymous users [Y / n] <- whether to remove the anonymous user, enter

? Disallow root login remotely [Y / n] <- prohibit root remote login, enter,

Remove test database and access to it [Y / n] <-? Whether to delete the test database, enter

? Reload privilege tables now [Y / n] <- whether to re-load authority table, enter

MariaDB initialization is complete, the next test Login

mysql -uroot -ppassword

carry out.

 

2, configure MariaDB character set

File /etc/my.cnf

we /etc/my.cnf

Added at [mysqld] tab

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

we /etc/my.cnf.d/client.cnf

Add [client] in

default-character-set=utf8

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

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

Add [MySQL] in

default-character-set=utf8

 All configuration is complete, restart mariadb

systemctl restart mariadb

After entering MariaDB 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)

Character set configuration is complete.

 

3, add users, set permissions

Create a user command

mysql>create user root@localhost identified by 'password';

Direct command to create user and authorization

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

Granted landing rights outside the network 

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

Permission and authorization can be granted

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

Simple user configuration and basic rights on the case.

 

 

, Adding skip-grant-tables in the following mysqld, save and exit.

1. Go to the mysql database:

mysql> use mysql;Database changed

  1. Set a new password to the root, the blue part of their inputs: MySQL>  Update User SET password = password ( "123456") WHERE User = "root";

Query OK, 1 rows affected (0.04 sec)Rows matched: 1 Changed: 1 Warnings: 0

  1. Refresh database MySQL>  flush privileges;

Query OK, 0 rows affected (0.01 sec)

  1. Exit mysql: mysql> quit

Bye

PS: 123456 for the new password, the user may need to modify their own password according to 

After changing for the better, and then modify the my.ini file, delete We just added "skip-grant-tables" line, save and exit and then restart the mysql service on it.

systemctl restart mariadb

 

Remember: When you configure to allow remote login, or only localhost can log database.

Guess you like

Origin www.cnblogs.com/qfdy123/p/11388268.html