欢迎投稿

今日深度:

源码包编译安装Mariadb,源码编译mariadb

源码包编译安装Mariadb,源码编译mariadb


从官网下载源码包

点击后出现下面这个页面

点击箭头所指的,即可开始下载。

下载完后通过scp(或别的方法)上传至Linux机器

MariaDB 5.5及更高版本使用cmake编译,所有得先安装cmake,这里使用编译安装cmake.

编译环境及依赖关系

[ root@localhost ~ ]#yum groupinstall -y Development Tools
[ root@localhost ~ ]#yum -y install ncurses-devel zlib-devel
获取cmake :
[ root@localhost ~ ]#wget https://cmake.org/files/v3.9/cmake-3.9.3.tar.gz
[ root@localhost ~ ]#tar xf cmake-3.9.3.tar.gz -C /usr/local/
编译安装:
[ root@localhost ~ ]# cd /usr/local/cmake-3.9.3/
[ root@localhost ~ ]# ./configure 


此过程非常耗时,需要耐心等待。
接下来安装Mariadb
[ root@localhost ~ ]#tar xf mariadb-5.5.57.tar.gz -C /usr/local/mysql

[ root@localhost /usr/local/mysql ]#
    cmake  -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
    -DSYSCONFDIR=/etc \
    -DDEFAULT_CHARSET=utf8 \
    -DDEFAULT_COLLATION=utf8_general_ci \
    -DWITH_EXTRA_CHARSETS=all \

# 注:
#第一行是mysql主程序安装目录
#第二行是配置文件目录
#第三行默认字符集为utf8
#第四行默认的字符集效对规则
#第五行安装所有字符集

最后:
[ root@localhost /usr/local/mysql ]# make && make install
创建mysql用户:
[ root@localhost / ]# useradd -M -s /sbin/nologin mysql
[ root@localhost / ]#chown mysql:root /usr/local/mysql/
MariaDB配置文件创建及更改。
[ root@localhost / ]# cp support-files/my-medium.cnf /etc/my.cnf   
#复制配置文件
[ root@localhost / ]# cp support-files/mysql.server  /etc/init.d/mysqld  
#复制启动脚本
[ root@localhost / ]# vim /etc/my.conf 
datadir = /usr/local/msyql/data/  
#指定数据库路径,不然无法启动mysql
innodb_file_per_table = on
 #设置后当创建数据库的表的时候表文件都会分离开,方便复制表,不开启创建的表都在一个文件
skip_name_resolve = on  
#跳过名称反解,Mysql每次使用客户端链接时都会把ip地址反解成主机名

设置Mysql环境变量
[ root@localhost / ]# echo "export PATH=$PATH:/usr/local/mysql/bin">>/etc/profile :设置mysql环境变量
执行脚本初始化数据库
[ root@localhost / ]#/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/mydata/ 
安全初始化mysql及设定(前提先启动Mysql服务: server mysqld start)
[ root@localhost / ]#  /usr/local/mysql/bin/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!
测试能否登录入数据库
[ root@localhost ~ ]#mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 38
Server version: 5.5.57-MariaDB Source distribution

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)]> 

www.htsjk.Com true http://www.htsjk.com/mariadb/29781.html NewsArticle 源码包编译安装Mariadb,源码编译mariadb 从官网下载源码包 点击后出现下面这个页面 点击箭头所指的,即可开始下载。 下载完后通过scp(或别的方法)上传至Linux机器 MariaDB 5.5及更高版本使...
相关文章
    暂无相关文章
评论暂时关闭