1.1

部署mariadb数据库到linux(源码编译安装)

介绍

Mariadb是mysql原作者另外开发的一个版本,mariadb使用方法和mysql一样,可以直接用mysql的客户端连接.

编译安装过程

首先安装各种要用到的库

apt install -y build-essential zlib1g-dev libpcre3 libpcre3-dev unzip cmake libncurses5-dev libpam0g-dev bison libboost-dev libssl-dev openssl g++ libxml2-dev libcurl3-openssl-dev libpng-dev libfreetype6-dev libfreetype6-dev

在这下载源码包并解压

https://mariadb.org/download/

进入解压出来的目录编译安装

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb -DMYSQL_DATADIR=/home/mariadb -DSYSCONFDIR=/etc -DWITHOUT_TOKUDB=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STPRAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWIYH_READLINE=1 -DWIYH_SSL=system -DVITH_ZLIB=system -DWITH_LOBWRAP=0 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

make -j2
make install

配置运行

建立组和用户

groupadd mysql
useradd -s/sbin/nologin -M -g mysql mysql

建立数据文件夹,并写配置文件

mkdir /home/mariadb
mkdir /var/log/mariadb
chown -R mysql:mysql /home/mariadb
chown -R mysql:mysql /usr/local/mariadb/

cd /usr/local/mariadb/
scripts/mysql_install_db --datadir=/home/mariadb --user=mysql

vim /home/mariadb/my.cnf

内容:

[client]
#password	= your_password
port		= 3306
socket		= /tmp/mysql.sock

[mysqld]
port		= 3306
socket		= /tmp/mysql.sock
skip-external-locking
key_buffer_size = 384M
max_allowed_packet = 1M
table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M
thread_concurrency = 8
#tmpdir		= /tmp/
#skip-networking
log-bin=mysql-bin
server-id	= 1

#master-host     =   <hostname>
#master-user     =  
#master-password =   
#master-port     =  3306

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

配置systemd:

echo "[Unit]
Description=MariaDB Server
After=network.target
 
[Service]
User=mysql
Group=mysql
PIDFile=/tmp/mariadb.pid
ExecStart=/usr/local/mariadb/bin/mysqld_safe --defaults-file=/home/mariadb/my.cnf --user=mysql --datadir=/home/mariadb --pid-file=/tmp/mariadb.pid
 
[Install]
WantedBy=multi-user.target">/usr/lib/systemd/system/mariadb.service

启动

systemctl start mariadb

配置密码

/usr/local/mariadb/bin/mysqladmin -u root password 'new-password'

连接

/usr/local/mariadb/bin/mariadb
posted @ 2019-05-07 01:30  asml  阅读(498)  评论(0编辑  收藏  举报
@.@