centos7安裝配置MariaDB10

1:添加 MariaDB yum 倉庫mysql

vi /etc/yum.repos.d/MariaDB.repo
在該文件中添加如下內容保存:sql

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

2:安裝 MariaDB數據庫

yum install MariaDB-server MariaDB-client -y

(1)安裝完畢後,當即啓動數據庫服務守護進程。centos

systemctl start mariadb

(2)設置 MariaDB 在操做系統重啓後自動啓動服務安全

systemctl enable mariadb

(3)查看 MariaDB 服務當前狀態測試

systemctl status mariadb

3:對 MariaDB 進行安全配置編碼

設置 MariaDB 的 root 帳戶密碼,刪除匿名用戶,禁用 root 遠程登陸,刪除測試數據庫,從新加載權限表。url

mysql_secure_installation

Set root password? [Y/n] Y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

4:基本配置centos7

(1)設置數據庫字母大小寫不敏感spa

vi /etc/my.cnf.d/server.cnf

在[mysqld]下加上】
lower_case_table_names=1

(2)設置MariaDB數據庫默認編碼

vi /etc/my.cnf.d/client.cnf
在[client]字段里加入
default-character-set=utf8

vi /etc/my.cnf.d/server.cnf
在[mysqld]字段里加入
character-set-server=utf8

(3)修改默認端口號3306修改成3366

vi /etc/my.cnf.d/client.cnf
在[client]字段修改
port=3366

vi /etc/my.cnf.d/server.cnf
在[mysqld]字段里加入
port=3366

(4)修改最大鏈接數

vi /etc/my.cnf.d/server.cnf
[mysqld] 下面增長下面配置:
max_connections=1000

查看最大鏈接數
show variables like '%max_connections%';

(5)修改max_allowed_packet 

vi /etc/my.cnf.d/server.cnf
[mysqld] 下面增長下面配置:
max_allowed_packet=16M

5:最後重啓 MariaDB 配置生效

systemctl restart mariadb
相關文章
相關標籤/搜索