当前位置:网站首页>安装mariadb 10.5.7(tar包安装)
安装mariadb 10.5.7(tar包安装)
2022-06-11 17:41:00 【雅冰石】
一 下载
Mariadb下载地址:http://downloads.mariadb.org
勾选
可以选择下载历史版本数据库。
二 安装
chattr -ia /etc/passwd
chattr -ia /etc/group
chattr -ia /etc/shadow
chattr -ia /etc/gshadow
groupadd mysql
useradd -g mysql mysql
passwd mysql
cd /opt/
tar -xvf mariadb-10.5.7-linux-systemd-x86_64.tar.gz -C /usr/local/
cd /usr/local/
mv mariadb-10.5.7-linux-systemd-x86_64 mysql
cd mysql
#安装
./scripts/mysql_install_db --user=mysql

chown -R mysql:mysql /usr/local/mysql
#设置PATH变量
vi /root/.bash_profile
在PATH这行末尾添加:
:/usr/local/mysql/bin
#使变量生效
source /root/.bash_profile
三 修改配置文件
cd /etc
mv my.cnf my.cnf.backup
vi my.cnf,添加:
[mysqld]
local_infile=off
event_scheduler = 1
innodb_buffer_pool_size=500m
server_id=1
#log-basename=master
log_bin=master-bin
log_slave_updates=ON
port=3306
log_error=/usr/local/mysql/error.log
slow_query_log=1
long_query_time=2
binlog_format=ROW
innodb_flush_log_at_trx_commit=1
sync_binlog=1
character_set_server=utf8mb4
collation_server=utf8mb4_bin
max_allowed_packet=64M
max_connections=2000
max_connect_errors=1024
#tx_isolation=REPEATABLE-READ
skip-name-resolve=ON
expire_logs_days=30
log_bin_trust_function_creators=1
lower_case_table_names=1
innodb_log_file_size=512M
innodb_file_per_table=ON
slave-parallel-threads=32
slave_parallel_mode=optimistic
rpl_semi_sync_slave_enabled=ON
rpl_semi_sync_master_enabled=ON
rpl_semi_sync_master_wait_point=AFTER_SYNC
[client]
default-character-set=utf8/*
innodb_buffer_pool_size可以根据自己服务器内存大小调大些,如果服务器上只部署了mariadb的话,建议设置为服务器内存的60%.
*/
四 启动数据库
#设置以systemctl方式启动数据库
cp /usr/local/mysql/support-files/systemd/mariadb.service /usr/lib/systemd/system/mariadb.service
请注意,默认情况下/usr/目录由systemd进行写保护,因此当按照上面的说明将数据目录放在/usr/local/mysql/data中时,还需要使该目录可写。您可以通过添加额外的服务包含文件来执行此操作:
mkdir /etc/systemd/system/mariadb.service.d/
cat > /etc/systemd/system/mariadb.service.d/datadir.conf <<EOF
[Service]
ReadWriteDirectories=/usr/local/mysql
EOF
/*
我起初按官网配置的是ReadWritePaths=/usr/local/mysql/data,启动mariadb报错:
/etc/systemd/system/mariadb.service.d/datadir.conf:2] Unknown lvalue 'ReadWritePaths' in section 'Service'
[ERROR] mariadbd: File '/usr/local/mariadb-10.5.7-linux-systemd-x86_64/data/aria_log_control' not found (Errcode: 30 "Read-only file system")
可能是操作系统版本不一样吧,我的是centos 7.6
*/
#启动数据库
systemctl daemon-reload
systemctl start mariadb
systemctl enable mariadb
五 登录数据库
#登录mysql,默认密码为空

/*
如果数据库启动成功了,登录却报错:
[[email protected] my.cnf.d]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[[email protected] etc]# which mysql
/usr/bin/mysql
发现/usr/bin下有个mysql文件:
ll /usr/bin/mysql
如果有的话,删除这个文件,再新打开个窗口就能连上数据库了。
*/
六 账号管理
#修改账号密码
alter user [email protected]'localhost' identified by '自定义密码';
#删除空密码账号
delete from mysql.user where password='';
#删除密码不合法的账号
delete from mysql.user where password='invalid';
#创建root远程账号
grant all privileges on *.* to 'root'@'%' identified by '自定义密码';
flush privileges;
--本篇文章参考了Installing MariaDB Binary Tarballs - MariaDB Knowledge Base
边栏推荐
- Ffmpeg parity field frame interlace progressive command and code processing
- Leetcode force deduction question
- 活动 | Authing 首次渠道合作活动圆满落幕
- ArrayList collection, object array
- 6-7 file read / write operation
- 开源项目那么多,这次带你了解个版本的区别,明白alpha版、beta版、rc版是什么意思
- [MySQL] detailed explanation of redo log, undo log and binlog (4)
- tidb-ddl的速度的调整
- Service学习笔记03- 前台服务实战
- Vscode configures eslint to automatically format an error "auto fix is enabled by default. use the single string form“
猜你喜欢

Merge two ordered linked lists ---2022/02/24

05_特征工程—降维

Threejs uses indexeddb cache to load GLB model

合并K个升序链表---2022/02/26

Sohu tout le personnel a été escroqué, quels problèmes ont été exposés?

搜狐全員遭詐騙,暴露哪些問題?

Activity | authing's first channel cooperation activity came to a successful conclusion

How does Sister Feng change to ice?

threejs利用indexeddb缓存加载glb模型

sql server中关于FORCESCAN的使用以及注意项
随机推荐
Mathematical foundations of information security Chapter 3 - finite fields (I)
搜狐全員遭詐騙,暴露哪些問題?
[solution] codeforces round 798 (Div. 2)
6-2 reverse output of multiple integers recursion
What problems are exposed when all Sohu employees are cheated?
自动化测试-Selenium
Summary of clustering methods
7-1 are prime numbers
Semaphore PV operation of process interaction and its code implementation
Why is the UDP stream set to 1316 bytes
TestPattern error
信息安全数学基础 Chapter 3——有限域(一)
Tidb GC related problems
tidb-ddl的速度的调整
6-3 reading articles (*)
括号生成---2022/02/25
TypeScipt基础
[MySQL] detailed explanation of redo log, undo log and binlog (4)
ArrayList collection, object array
ffmpeg奇偶场帧Interlace progressive命令和代码处理