安装MariaDB

yum安装:
yum groupinstall mariadb mariadb-client
其中mariadb包组为服务,包含以下安装包:
mariadb-server: mandatory package
mariadb-bench: optional package
mariadb-test: optional package
其中mariadb-client为客户连接端
Mariadb: mandatory package
MySQL-python: default package
mysql-connector-odbc: default package
libdbi-dbd-mysql: optional package
mysql-connector-java: optional package
perl-DBD-MySQL: optional package
设置开机启动
systemctl start mariadb
systemctl enable mariadb
设置数据库安全性:
/usr/bin/mysql_secure_installation
交互界面
设置数据库管理员root口令
禁止root远程登录
删除anonymous用户帐号
删除test数据库
/usr/bin/mysql_secure_installation:行379: find_mysql_client: 未找到命令

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.

Set root password? [Y/n] y 是否设置root密码
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是否禁止root远程登录
… 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.

Remove test database and access to it? [Y/n] n 是否删除测试数据库
… skipping.

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

Reload privilege tables now? [Y/n] 配置是否生效
… 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!

编译完成的二进制包安装:
创建用户账户:
mariadb在运行时会以mariadb身份运行。
groupadd -r -g 27 mysql
useradd -r -g 27 -u 27 -d /data -s /sbin/nologin mysql
准备数据目录
mkdir /data
chown mysql.mysql /data
准备二进制程序:
tar -xvf mariadb***.tar.gz -C /usr/local
cd /usr/local ;ln -sv mariadb*** ./mysql (将解压出来的文件夹创建一个软连接为mysql,因为安装时需要用到的文件名称为mysql)
chown -R root.mysql /usr/local/mysql注:改变软连接的权限
chown-R root.mysql /usr/local/mysql/ 注:mysql改变的是软连接需要加/
创建配置文件:
注:配置文件查找路径为:后面的配置会覆盖前面相同的配置。
/etc/my.cnf
/etc/mysql/my.cnf
–default-extrafile=/PATH/TO/CONF_FILE
~/.my.cnf
mkdir /etc/mysql/
cp -p /usr/local/mysql/support-files/my-huge.cnf /etc/mysql/my.cnf
更改配置文件:vim /etc/mysql/my.cnf
[mysqld]中添加三个选项:
datadir = /data
innodb_file_per_table = on采用innodb数据引擎,每个表单独为一个文件
skip_name_resolve = on 禁止主机名解析
创建数据库文件
/usr/local/mysql/scripts/mysql_install_db –help显示帮助信息
cd /usr/local/mysql/;./scripts/mysql_install_db–datadir=/data –user=mysql
此命令只能在mysql文件夹下运行,使用全路径运行./mysql_install_db运行都会出错
准备日志文件
日志在/etc/my.cnf文件中定义,log-error=/var/log/mysqld.log。
touch /var/log/mysqld.log
chown mysqld /var/log/mysqld.log
准备服务脚本,并启动服务
cd /usr/local/mysql/ ;cp ./support-files/mysql.server/etc/rc.d/init.d/mysqld
chkconfig –add mysqld
service mysqld start
安全初始化
/user/local/mysql/bin/mysql_secure_installation
连接器地址位于:/user/local/mysql/bin/mysql
添加环境变量:
vim/etc/profile.d/mysql.sh
export PATH=/usr/local/mysql/bin:${PATH}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值