编译安装mariadb10.3

编译安装mariadb

依赖

readline-devel
zlib-devel
openssl-devel
libaio-devel

新建用户

groupadd -r mysql
useradd -g mysql -s /sbin/nologin mysql
mkdir -p /vhs/mariadb/mariadb103/
mkdir -p /vhs/mariadb/mariadb103/data
mkdir -p /vhs/mariadb/mariadb103/etc
mkdir -p /vhs/mariadb/mariadb103/tmp
sudo chmod 777 /vhs/mariadb/mariadb103/tmp
sudo chown -R mysql:mysql /vhs/mariadb/mariadb103/

下载
官网
github

wget https://downloads.mariadb.org/interstitial/mariadb-10.3.10/source/mariadb-10.3.10.tar.gz
wget https://github.com/MariaDB/server/archive/mariadb-10.0.37.tar.gz
tar xvf mariadb-10.3.10.tar.gz
cd mariadb-10.3.10/

编译

cmake \
-DCMAKE_INSTALL_PREFIX=/vhs/mariadb/mariadb103 \
-DMYSQL_DATADIR=/vhs/mariadb/mariadb103/data \
-DSYSCONFDIR=/vhs/mariadb/mariadb103/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=/vhs/mariadb/mariadb103/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
# 如果万一执行中有了错误,可以执行: rm -f CMakeCache.txt 删除编译缓存,再
make
sudo make install

配置
参考linux下用cmake编译安装mysql

cd /vhs/mariadb/mariadb103/
sudo scripts/mysql_install_db --datadir=/vhs/mariadb/mariadb103/data --user=mysql
# 一番信息自动输出完成后,执行以下代码
# 启动MariaDb,会使用3306端口
sudo support-files/mysql.server start
# 为root用户添加密码
sudo bin/mysqladmin -u root password "root"
# 输入设置的的密码,登录数据库
bin/mysql -uroot -p

# 详情
root      7739  0.0  0.0  12432  3452 pts/2    S    19:40   0:00 /bin/sh /vhs/mariadb/mariadb103/bin/mysqld_safe --datadir=/vhs/mariadb/mariadb103/data --pid-file=/vhs/mariadb/mariadb103/data/lxx-pc.pid
mysql     7816  0.1  2.1 1254468 87972 pts/2   Sl   19:40   0:00 /vhs/mariadb/mariadb103/bin/mysqld --basedir=/vhs/mariadb/mariadb103 --datadir=/vhs/mariadb/mariadb103/data --plugin-dir=/vhs/mariadb/mariadb103/lib/plugin --user=mysql --log-error=/vhs/mariadb/mariadb103/data/lxx-pc.err --pid-file=/vhs/mariadb/mariadb103/data/lxx-pc.pid
lxx       8006  0.0  0.0  11252  2252 pts/2    S+   19:42   0:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn maria

自定义配置my.cnf文件,修改占用端口,权限777

# 文件权限/vhs/mariadb/mariadb103/my.cnf
sudo chown -R mysql:mysql my.cnf
sudo chmod 644 my.cnf
# 文件内容
[mysqld]
port            = 3307

#详情
root     10140  0.0  0.0  12432  3572 pts/2    S    20:02   0:00 /bin/sh /vhs/mariadb/mariadb103/bin/mysqld_safe --datadir=/vhs/mariadb/mariadb103/data --pid-file=/vhs/mariadb/mariadb103/data/lxx-pc.pid
mysql    10223  0.3  2.0 1254168 81224 pts/2   Sl   20:02   0:00 /vhs/mariadb/mariadb103/bin/mysqld --basedir=/vhs/mariadb/mariadb103 --datadir=/vhs/mariadb/mariadb103/data --plugin-dir=/vhs/mariadb/mariadb103/lib/plugin --user=mysql --log-error=/vhs/mariadb/mariadb103/data/lxx-pc.err --pid-file=/vhs/mariadb/mariadb103/data/lxx-pc.pid --port=3307
lxx      10280  0.0  0.0  11252  2288 pts/2    S+   20:03   0:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn maria


注册到系统

cd scripts
chown -R mysql:mysql .
cd support-files
chown -R root .
# 软链或者复制,修改
cp support-files/mysql.server /usr/lib/systemd/

你可能感兴趣的:(linux,mariadb)