MariaDB单机版安装(linux)

1 下载linux下安装二进制包

以下以安装mariadb-10.5.8-linux-systemd-x86_64.tar.gz为例

2 安装步骤

1)解压缩安装包

tar -xvzf mariadb-10.5.8-linux-systemd-x86_64.tar.gz

建立一个软连接(方便后续操作)

ln -s /opt/mariadb-10.5.8-linux-systemd-x86_64 /opt/maridb

2)修改配置文件my.cnf
先在/opt/maridb建立一个配置文件目录、日志目录、数据目录、运行目录

cd /opt/mariadb
mkdir etc
cp /etc/my.cnf /etc/
mkdir data
mkdir log
mkdir run

修改配置文件my.cnf

[mysqld]
datadir=/opt/mariadb/data
socket=/opt/mariadb/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
port=3306
#user=appadmin 
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
log-error=/opt/mariadb/log/mariadb.log
pid-file=/opt/mariadb/run/mariadb.pid

#
# include all files from the config directory

3)初始化系统数据库

cp /script/mariadb-install-db ../    (如果不copy到上一级目录,启动脚本可能会报一个路径错误)
./mariadb-install-db --defaults-file=/opt/mariadb/etc/my.cnf --user=appadmin

4)启动数据库实例

  • 如果同一系统中存在多个MariaDB实例,可以通过mysqld_safe程序启停MariaDB服务。
    /var/lib/mysql是MariaDB服务的默认数据目录,我们可以配置指定其他数据目录。
  • 此外,还可以指定配置文件,使用配置文件启停MariaDB服务。
#利用mysqld_safe启动
ln -s /tmp/mysql.sock /opt/mariadb/mysql.sock   (如果/tmp目录下没这个文件,启动会出一个错,具体可以看错误提示)
cd /opt/mariadb/bin/
执行以下脚本:
./mysqld_safe --defaults-file=/opt/mariadb/etc/my.cnf &
或
./mysqld_safe --datadir=../data/ --socket=../mysql.sock --port=3306 --user=appadmin&

查看3306端口已经监听。

netstat -nltp | grep 3306


连接数据库
./mariadb -u appadmin -p
或
#通过本地socket方式登录
mysql -S /opt/mariadb/mysql.sock -uappadmin

停止数据库实例

#利用mysqladmin停止服务
./mysqladmin -S ../mysql.sock shutdown
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值