RockyLinux安装MariaDB


一、Mariadb 二进制包安装

OS: Rocky Linux 9.1

Database: mariadb-10.11.6-linux-systemd-x86_64.tar

1.0 解压缩
tar zxf mariadb-10.11.6-linux-systemd-x86_64.tar
1.1 创建软链接
ln -sf /usr/local/mariadb-10.11.6-linux-systemd-x86_64/ /usr/local/mysql
1.2 创建MySQL用户组
groupadd mysql
useradd -r -g mysql -s /sbin/nologin mysql
1.3 创建数据目录、日志目录,配置文件目录
mkdir /usr/local/mysql/data
mkdir /usr/local/mysql/etc
mkdir /usr/local/mysql/log
chown -R mysql:mysql /usr/local/mysql/
1.4 编辑MySQL配置文件
[client]
port=3306
socket=/tmp/mysql.sock
[mysqld]
port=3306
user = mysql
socket=/tmp/mysql.sock
tmpdir = /tmp
key_buffer_size=256M
max_allowed_packet=128M
open_files_limit = 60000
explicit_defaults_for_timestamp
server-id = 1
character-set-server = utf8 
federated
max_connections = 1000  
group_concat_max_len = 102400   
max_connect_errors = 100000
table_open_cache = 4096
event_scheduler = ON
skip-name-resolve
lower_case_table_names = 1  
interactive_timeout = 86400
wait_timeout = 86400
sync_binlog=0
back_log=100
default-storage-engine = InnoDB
log_slave_updates = 1
binlog_cache_size = 32M
max_heap_table_size = 256M
read_rnd_buffer_size = 64M
sort_buffer_size = 256M
join_buffer_size = 512M
thread_cache_size = 300
log_bin_trust_function_creators = 1 
read_buffer_size = 32M
read_rnd_buffer_size = 128M
bulk_insert_buffer_size = 512M
sql_mode='NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_ZERO_DATE,NO_ZERO_IN_DATE,NO_AUTO_CREATE_USER,ERROR_FOR_DIVISION_BY_ZERO'
transaction_isolation = READ-COMMITTED  
tmp_table_size = 512M
log-bin=mysql-bin
binlog_format=mixed
expire_logs_days = 15
slow_query_log = 1
slow_query_log_file = /usr/local/mysql/log/slow.log
long_query_time = 5
innodb_buffer_pool_size = 512M
innodb_thread_concurrency = 16
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 32M
innodb_log_file_size = 1024M
innodb_log_files_in_group = 4
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120

[mysqldump]
quick
max_allowed_packet = 64M

[client]
password="my password"

[mysqladmin]
force

[mysql]
no-auto-rehash

[myisamchk]
key_buffer = 16M
sort_buffer_size = 16M
read_buffer = 8M
write_buffer = 8M

[mysqlhotcopy]
interactive-timeout

[mysqld_safe]
open-files-limit = 65535    
log-error=/usr/local/mysql/log/mysqld.log
pid-file=/usr/local/mysql/etc/mysqld.pid
1.5 初始化数据库
cd /usr/local/mysql
./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

#初始化报错
error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory

# 解决方法:
find / -name 'libncurses*'
cd /usr/lib64
ln -sf libncurses.so.6.2 libncurses.so.5
ln -sf libtinfo.so.6.2 libtinfo.so.5

输出结果:

Installing MariaDB/MySQL system tables in '/usr/local/mysql/data' ...
OK

To start mariadbd at boot time you have to copy
support-files/mariadb.service to the right place for your system


Two all-privilege accounts were created.
One is root@localhost, it has no password, but you need to
be system 'root' user to connect. Use, for example, sudo mysql
The second is mysql@localhost, it has no password either, but
you need to be the system 'mysql' user to connect.
After connecting you can set the password, if you would need to be
able to connect as any of these users with a password and without sudo

See the MariaDB Knowledgebase at https://mariadb.com/kb

You can start the MariaDB daemon with:
cd '/usr/local/mysql' ; /usr/local/mysql/bin/mariadb-safe --datadir='/usr/local/mysql/data'

You can test the MariaDB daemon with mysql-test-run.pl
cd '/usr/local/mysql/mysql-test' ; perl mariadb-test-run.pl

Please report any problems at https://mariadb.org/jira

The latest information about MariaDB is available at https://mariadb.org/.

Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/
1.6 配置环境变量
vim /etc/profile.d/mysql.sh
export PATH=$PATH:/usr/local/mysql/bin
source /etc/profile.d/mysql.sh
1.7 配置开机启动 使用systemd管理mysql服务
[root@dxm system]# cp /usr/local/mysql/support-files/systemd/mysqld.service /usr/lib/systemd/system/
[Unit]
Description=MariaDB 10.11.6 database server
Documentation=man:mariadbd(8)
Documentation=https://mariadb.com/kb/en/library/systemd/
After=network.target
[Install]
WantedBy=multi-user.target
[Service]
Type=notify
PrivateNetwork=false
User=mysql
Group=mysql
CapabilityBoundingSet=CAP_IPC_LOCK CAP_DAC_OVERRIDE CAP_AUDIT_WRITE
PrivateDevices=false
ProtectSystem=full
ReadWritePaths=-/usr/local/mysql/data
ProtectHome=true
PermissionsStartOnly=true
ExecStartPre=/bin/sh -c "systemctl unset-environment _WSREP_START_POSITION"
ExecStartPre=/bin/sh -c "[ ! -e /usr/local/mysql/bin/galera_recovery ] && VAR= || \
 VAR=`cd /usr/local/mysql/bin/..; /usr/local/mysql/bin/galera_recovery`; [ $? -eq 0 ] \
 && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1"
ExecStart=/usr/local/mysql/bin/mariadbd $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION
ExecStartPost=/bin/sh -c "systemctl unset-environment _WSREP_START_POSITION"
KillSignal=SIGTERM
SendSIGKILL=no
Restart=on-abort
RestartSec=5s
UMask=007
PrivateTmp=false
TimeoutStartSec=900
TimeoutStopSec=900
LimitNOFILE=32768
systemctl daemon-reload
systemctl enable mysqld
systemctl start mysqld
systemctl status mysqld
1.8 登录MySQL 密码为空
mysql
1.9 修改密码
#修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Aa123456' PASSWORD EXPIRE NEVER;

#刷新授权表
flush privileges;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

空城旧梦S

你的鼓励是我最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值