linux 下mariadb源码包安装

LINUX 源码包安装

1、  创建用户,并设置密码

以root用户登录:

useradd -g users -d /home/mariadb -m mariadb

passwd mariadb

2、  切换mariadb用户,下载安装包或ftp上传到目标服务器

3、  解压压缩包

tar -xzvf mariadb-10.0.14.tar.gz

4、  编译安装

cd mariadb-10.0.14

cmake . \

-DCMAKE_INSTALL_PREFIX=/home/mariadb \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DEXTRA_CHARSETS=all \

-DWITH_MYISAM_STORAGE_ENGINE=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_FEDERATED_STORAGE_ENGINE=1 \

-DENABLED_LOCAL_INFILE=1 \

-DMYSQL_USER=mariadb

 

make

make install

 

 

 

编译中部分参数详解:

-DCMAKE_INSTALL_PREFIX= 指向mysql安装目录

-DINSTALL_SBINDIR=sbin 指向可执行文件目录(prefix/sbin)

-DMYSQL_DATADIR=/var/lib/mysql 指向mysql数据文件目录(/var/lib/mysql)

-DSYSCONFDIR=/etc/mysql 指向mysql配置文件目录(/etc/mysql)

-DINSTALL_PLUGINDIR=lib/mysql/plugin 指向插件目录(prefix/lib/mysql/plugin)

-DINSTALL_MANDIR=share/man 指向man文档目录(prefix/share/man)

-DINSTALL_SHAREDIR=share 指向aclocal/mysql.m4安装目录(prefix/share)

-DINSTALL_LIBDIR=lib/mysql 指向对象代码库目录(prefix/lib/mysql)

-DINSTALL_INCLUDEDIR=include/mysql 指向头文件目录(prefix/include/mysql)

-DINSTALL_INFODIR=share/info 指向info文档存放目录(prefix/share/info)

Storage Engine相关:

若想启用某个引擎的支持:-DWITH_<ENGINE>_STORAGE_ENGINE=1

如:

-DWITH_INNOBASE_STORAGE_ENGINE=1

若想禁用某个引擎的支持:-DWITHOUT_<ENGINE>_STORAGE_ENGINE=1

如:

-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1

-DWITHOUT_FEDERATED_STORAGE_ENGINE=1

-DWITHOUT_PARTITION_STORAGE_ENGINE=1

Library相关

-DWITH_READLINE=1 启用readline库支持(提供可编辑的命令行)

-DWITH_SSL=system 启用ssl库支持(安全套接层)

-DWITH_ZLIB=system 启用libz库支持(zib、gzib相关)

-DWTIH_LIBWRAP=0 禁用libwrap库(实现了通用TCP包装的功能,为网络服务守护进程使用)

-DMYSQL_TCP_PORT=3306 指定TCP端口为3306

-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock 指定mysql.sock路径

-DENABLED_LOCAL_INFILE=1 启用本地数据导入支持

-DEXTRA_CHARSETS=all 启用额外的字符集类型(默认为all)

-DDEFAULT_CHARSET=utf8 指定默认的字符集为utf8

-DDEFAULT_COLLATION=utf8_general_ci 设定默认排序规则(utf8_general_ci快速/utf8_unicode_ci准确)

-DWITH_EMBEDDED_SERVER=1 编译嵌入式服务器支持

-DMYSQL_USER=mysql 指定mysql用户(默认为mysql)

-DWITH_DEBUG=0 禁用debug(默认为禁用)

-DENABLE_PROFILING=0 禁用Profiling分析(默认为开启)

-DWITH_COMMENT=’string’ 一个关于编译环境的描述性注释

5、  修改my.cnf

 

# ExampleMySQL config file for small systems.

#

# This isfor a system with little memory (<= 64M) where MySQL is only used

# fromtime to time and it’s important that the mysqld daemon

# doesn’tuse much resources.

#

# MySQL programslook for option files in a set of

#locations which depend on the deployment platform.

# You cancopy this option file to one of those

#locations. For information about these locations, see:

#http://dev.mysql.com/doc/mysql/en/option-files.html

#

# In thisfile, you can use all long options that a program supports.

# If youwant to know which options a program supports, run the program

# withthe “–help” option.

 

# Thefollowing options will be passed to all MySQL clients

[client]

#password       =your_password

port            = 13306

socket          = /home/mariadb/mysql.sock

 

# Herefollows entries for some specific programs

 

# TheMySQL server

[mysqld]

port            = 13306

socket          = /home/mariadb/mysql.sock

datadir =/home/mariadb/data

skip-external-locking

key_buffer_size= 16K

max_allowed_packet= 1M

table_open_cache= 4

sort_buffer_size= 64K

read_buffer_size= 256K

read_rnd_buffer_size= 256K

net_buffer_length= 2K

thread_stack= 240K

log-error= /home/mariadb/log/mysqld.log

pid-file= /home/mariadb/bin/mysqld.pid

 

 

 

# Don’tlisten on a TCP/IP port at all. This can be a security enhancement,

# if allprocesses that need to connect to mysqld run on the same host.

# Allinteraction with mysqld must be made via Unix sockets or named pipes.

# Notethat using this option without enabling named pipes on Windows

# (usingthe “enable-named-pipe” option) will render mysqld useless!

#

#skip-networking

server-id       = 1

 

#Uncomment the following if you want to log updates

log-bin=mysql-bin

 

# binarylogging format – mixed recommended

#binlog_format=mixed

 

# Causesupdates to non-transactional engines using statement format to be

# writtendirectly to binary log. Before using this option make sure that

# thereare no dependencies between transactional and non-transactional

# tablessuch as in the statement INSERT INTO t_myisam SELECT * FROM

#t_innodb; otherwise, slaves may diverge from the master.

#binlog_direct_non_transactional_updates=TRUE

 

#Uncomment the following if you are using InnoDB tables

innodb_data_home_dir= /home/mariadb/data

innodb_data_file_path= ibdata1:10M:autoextend

innodb_log_group_home_dir= /home/mariadb/data

# You canset .._buffer_pool_size up to 50 – 80 %

# of RAMbut beware of setting memory usage too high

innodb_buffer_pool_size= 16M

innodb_additional_mem_pool_size= 2M

# Set.._log_file_size to 25 % of buffer pool size

innodb_log_file_size= 5M

innodb_log_buffer_size= 8M

innodb_flush_log_at_trx_commit= 1

innodb_lock_wait_timeout= 50

 

[mysqldump]

quick

max_allowed_packet= 16M

 

[mysql]

no-auto-rehash

# Removethe next comment character if you are not familiar with SQL

#safe-updates

 

[myisamchk]

key_buffer_size= 8M

sort_buffer_size= 8M

 

[mysqlhotcopy]

interactive-timeout

 

6、  初始化数据库

./scripts/mysql_install_db –defaults-file=my.cnf

7、  创建文件夹

mkdir /home/mariadb/log

8、  启动数据库

./bin/mysqld_safe –defaults-file=my.cnf &

9、  为root用户创建密码

./bin/mysqladmin -u root password ‘123’ -S mysql.sock

10、  测试安装(非必须)

perl mysql-test/mysql-test-run.pl

发表评论

邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据