当前位置:网站首页>安装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
边栏推荐
猜你喜欢

05_ Feature Engineering - dimension reduction

Ffmpeg parity field frame interlace progressive command and code processing

括号生成---2022/02/25

05_特征工程—降维

Service learning notes 01 start method and life cycle

Connect the server with springboard / fortress through xshell

QLineEdit 设置输入掩码

智能化整体图例,布线、安防、广播会议、电视、楼宇、消防、电气图的图例【转自微信公众号弱电课堂】

Semaphore PV operation of process interaction and its code implementation

Threejs uses indexeddb cache to load GLB model
随机推荐
TypeScipt基础
04_ Feature engineering feature selection
Automated testing selenium
7-1 are prime numbers
QLineEdit 设置输入掩码
【Mysql】redo log,undo log 和binlog详解(四)
R language mice package error in terms Formula (TMP, simplify = true): the model formula in extractvars is incorrect
6-7 file read / write operation
括号生成---2022/02/25
Go get downloaded package path
6-6 batch sum (*)
自动化测试-Selenium
信息安全数学基础 Chapter 3——有限域(一)
【线上问题】Timeout waiting for connection from pool 问题排查
Don't you understand the design and principle of thread pool? Break it up and crush it. I'll teach you how to design the thread pool
Service learning notes 04 other service implementation methods and alternative methods
有效的括号---2022/02/23
智能化整体图例,布线、安防、广播会议、电视、楼宇、消防、电气图的图例【转自微信公众号弱电课堂】
Sohu tout le personnel a été escroqué, quels problèmes ont été exposés?
ffmpeg硬编解码 Inter QSV