二进制安装mariadb-10.6.11
二进制安装MariaBD
1.源下载
# 官方源下载不方便这里使用清华源
wget https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-10.6.11/bintar-linux-systemd-x86_64/mariadb-10.6.11-linux-systemd-x86_64.tar.gz
2.解压创建软连接
# 解压安装包
tar -xvf mariadb-10.6.11-linux-systemd-x86_64.tar.gz -C /usr/local/
ln -vs /usr/local/mariadb-10.6.11-linux-systemd-x86_64/ /usr/local/mysql
3.创建用户 创建文件夹
# 创建组及用户
groupadd -g 1002 mysql
useradd -s /sbin/nologin -g mysql -u 1002 -M mysql
# 创建文件夹
mkdir -p /usr/local/mysql/{data,logs,tmp}
chown -R mysql.mysql /usr/local/mysql/
4.创建环境变量
# 设置环境变量
echo 'PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
. /etc/profile.d/mysql.sh
# 加入systemd管理
cp /usr/local/mysql/support-files/systemd/mysqld.service /usr/lib/systemd/system/
5.创建配置文件
[root@node2 ~]# vim /etc/my.cnf
[client]
port = 3306
default-character-set = utf8mb4
[mysqld]
basedir = /usr/local/mysql
datadir=/usr/local/mysql/data/
innodb_buffer_pool_size=128M
port=3306
symbolic-links=0
[mysqld_safe]
log-bin = mysql-bin
log-error=/usr/local/mysql/logs/mysql.log
6.初始化,安全初始化数据库
# 初始化数据库
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/ --user=mysql
# 安全初始化
mysql_secure_installation
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
haven't set the root password yet, you should just press enter here.
# 输入root密码开始初始化默认没密码 直接回车就行
Enter current password for root (enter for none):
# 输入y开始初始化
You already have your root account protected, so you can safely answer 'n'.
Switch to unix_socket authentication [Y/n] y
# 输入y开始修改root密码
You already have your root account protected, so you can safely answer 'n'.
Change the root password? [Y/n] y
# 输入y删除匿名用户
Remove anonymous users? [Y/n] y
... Success!
# 输入y禁止root远程登录
Disallow root login remotely? [Y/n] y
... Success!
# 输入y删除测试数据库
Remove test database and access to it? [Y/n] y
- Dropping test database...
# 输入y刷新数据库
Reload privilege tables now? [Y/n] y
... Success!
7.登录测试
[root@node2 ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 13
Server version: 10.6.11-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.001 sec)
参考链接
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通