Mariadb通用二进制安装

mariadb介绍:MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可 MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。在存储引擎方面,使用XtraDB(英语:XtraDB)来代替MySQL的InnoDB。
MariaDB由MySQL的创始人Michael Widenius(英语:Michael Widenius)主导开发,他早前曾以10亿美元的价格,将自己创建的公司MySQL AB卖给了SUN,此后,随着SUN被甲骨文收购,MySQL的所有权也落入Oracle的手中。MariaDB名称来自Michael Widenius的女儿Maria的名字。
MariaDB基于事务的Maria存储引擎,替换了MySQL的MyISAM存储引擎,它使用了Percona的 XtraDB,InnoDB的变体,分支的开发者希望提供访问即将到来的MySQL 5.4 InnoDB性能。这个版本还包括了 PrimeBase XT (PBXT) 和 FederatedX存储引擎
官网:https://www.mariadb.org
下载安装包:
这里写图片描述这里写图片描述这里写图片描述这里写图片描述点击箭头指向下载。

1)
  添加系统用户:mysql

[root@sunny ~]#groupadd -r -g mysql
[root@sunny ~]#useradd -r -g 666 -u 666 -m -d /app/data mysql
[root@sunny ~]#id mysql
uid=666(mysql) gid=666(mysql) groups=666(mysql)

2)
 准备数据目录,以/app/data为例,建议使用逻辑卷。

[root@sunny ~]#chown mysql:mysql /app/data
[root@sunny app]#ll
total 16
drwx------. 3 mysql mysql   78 Sep 25 11:43 data

3)
 准备二进制程序

[root@sunny ~]#tar xf mariadb-10.2.8-linux-x86_64.tar.gz –C /usr/local
[root@sunny ~]#cd /usr/local;ln -sv mariadb-VERSION mysql
[root@sunny ~]#chown -R root:mysql /usr/local/mysql/

4)准备配置文件
  配置格式:类ini格式,各程序由单个配置文件提供配[prog_name]
  配置文件查找次序:后面覆盖前面的配置文件
/etc/my.cnf–>/etc/mysql/my.cnf–>–default-extra file=/PATH/TO/CONF_FILE–> ~/.my.cnf

[root@sunny ~]#mkdir /etc/mysql
[root@sunny ~]#cp /usr/local/mysql/support-files/my-huge.cnf  /etc/mysql/my.cnf 
[root@sunny ~]#vim /etc/mysql/my.cnf 
[mysqld]中添加三个选项:
datadir = /app/data
innodb_file_per_table = on
skip_name_resolve = on  #禁止主机名解析

这里写图片描述.

5)
创建数据库文件

[root@sunny ~]#cd /usr/local/mysql/#必须在这个路径下才能创建。
[root@sunny mysql]#./scripts/mysql_install_db --datadir=/app/data --user=mysql #运行脚本,创建完成后,里面一个myspl就是一个数据库。

6)创建日志文件

[root@sunny ~]#mkdir /var/log/mysqld/
[root@sunny ~]#touch /var/log/mysqld/mysqld.log
[root@sunny log]#chmod -R 700 mysqld/

7)准备服务脚本,并启动服务

[root@sunny mysql]#cp support-files/mysql.server  /etc/init.d/mysqld 复制文件
[root@sunny ~]# cp support-files/mysql.server/etc/init.d/mysqld   #复制启动脚本
[root@sunny ~]# vim /etc/my.conf 
datadir = /usr/local/msyql/data/   #指定数据库路径,不然无法启动mysql
innodb_file_per_table = on #设置后当创建数据库的表的时候表文件都会分离开,方便复制表,不开启创建的表都在一个文件
skip_name_resolve = on  #跳过名称反解,Mysql每次使用客户端链接时都会把ip地址反解成主机名
[root@sunny mysql]#chkconfig --add mysql
[root@sunny mysql]#chkconfig myspld on #输入这个能跳过上一步。
[root@sunny mysql]#service mysqld start #执行后报错,启动失败。
Starting mysqld (via systemctl):  Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
                                                           [FAILED]

8)指定PATH路径。

[root@sunny ~]#vim /etc/profile.d/mysql.sh
export PATH=/usr/local/mysql/bin:$PATH  #指定路径。

9)安全初始化

[root@sunny ~]#mysql_secure_installation
/usr/local/mysql/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

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]    #删除匿名账号
 ... 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]   #是否禁止root账号远程登录,生产环境中一定要禁止
 ... 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!

10)查看是否能登录数据库

[root@sunny ~]#mysql -u root -p #-p后面可以直接跟密码。-p跟密码连在一起,中间不用加空格。
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 36
Server version: 10.2.8-MariaDB-log MariaDB Server

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

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

MariaDB [(none)]> 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值