Mariadb安装与配置

2024-2-1 23:32 wsl Ansible自动化 阅读量:1130

1、安装与配置数据库
在控制节点(controller)执行以下操作

# yum install mariadb mariadb-server python2-PyMySQL -y

2 、配置数据库
创建一个 [mysqld] 部分,并将 bind-address 密钥设置为控制器节点的管理 IP 地址 ,以允许其他节点通过管理网络进行访问 。设置其他键以启用有用的选项和 UTF-8 字符集:
# vim /etc/my.cnf.d/openstack.cnf
[mysqld]
bind-address = 192.168.58.100

# bind-address = 控制节点IP

default-storage-engine = innodb
innodb_file_per_table = on
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8

3 、设置开机自启动
# systemctl enable mariadb.service
# systemctl start mariadb.service

4、数据库初始化设置
# mysql_secure_installation


NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY !

In order to log into MariaDB to secure it , we'll need the current
password for the root user.  If you've just installed MariaDB , and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
未设置密码 ,密码为空,直接回车即可
Enter current password for root (enter for none):             回车
OK , successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
设置密码为123
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] n
 ... skipping.

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.
删除测试数据库test
Remove test database and access to it? [Y/n] 
 - 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!
感谢使用


5、登录验证
# mysql -uroot -p123
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 16
Server version: 10.3.20-MariaDB MariaDB Server

Copyright (c) 2000 , 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.001 sec)

MariaDB [(none)]> 

 

版权所有:
文章标题:Mariadb安装与配置
文章链接:https://www.51itlab.net/?post=123
本站文章均为原创,未经授权请勿用于任何商业用途

热门标签