CentOS7系列--使用华为云安装MariaDB

举报
郁唯xiaolin 发表于 2021/05/22 09:34:31 2021/05/22
【摘要】 本文主要介绍华为云MariaDB源的安装以及mariadb的安装

一、安装华为MariaDB源

#  添加MariaDB的repo源文件
 cat > /etc/yum.repos.d/mariadb.repo  <<EOF
[Mariadb]
name=Mariadb Official Repository - \$basearch
baseurl=https://repo.huaweicloud.com/mariadb/yum/10.5/centos7-amd64/
enabled=1
gpgcheck=1
gpgkey=https://repo.huaweicloud.com/mariadb/yum/RPM-GPG-KEY-MariaDB
EOF
​
# 更新缓存
yum makecache fast


二、安装MariaDB

#  查看可安装的MariaDB版本
 yum list |grep -i mariadb
​
# 安装MariaDB
yum install -y MariaDB-server MariaDB-common MariaDB-devel MariaDB-client  MariaDB-compat
​
# 设置开机启动
systemctl enable mariadb
​
# 启动
systemctl start  mariadb


这个时候会发现启动的时候报错,如下:

 mysql]# journalctl -xe
Apr 24 08:38:01 hw-1-8 mariadbd[14000]: 2021-04-24  8:38:01 0 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exis
Apr 24 08:38:01 hw-1-8 mariadbd[14000]: 2021-04-24  8:38:01 0 [Note] Server socket created on IP: '::'.
Apr 24 08:38:01 hw-1-8 mariadbd[14000]: 2021-04-24  8:38:01 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.db' does
Apr 24 08:38:01 hw-1-8 mariadbd[14000]: 2021-04-24  8:38:01 0 [ERROR] Aborting
Apr 24 08:38:01 hw-1-8 systemd[1]: mariadb.service: main process exited, code=exited, status=1/FAILURE
Apr 24 08:38:01 hw-1-8 systemd[1]: Failed to start MariaDB 10.5.9 database server.
-- Subject: Unit mariadb.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit mariadb.service has failed.
-- 
-- The result is failed.
Apr 24 08:38:01 hw-1-8 systemd[1]: Unit mariadb.service entered failed state.
Apr 24 08:38:01 hw-1-8 systemd[1]: mariadb.service failed.
Apr 24 08:38:02 hw-1-8 polkitd[769]: Unregistered Authentication Agent for unix-process:13980:331605 (system bus name :1.69, object path /org/
Apr 24 08:38:02 hw-1-8 sshd[14016]: Did not receive identification string from 192.168.0.10 port 48802
Apr 24 08:38:11 hw-1-8 polkitd[769]: Registered Authentication Agent for unix-process:14022:332606 (system bus name :1.70 [/usr/bin/pkttyagent
Apr 24 08:38:11 hw-1-8 systemd[1]: Starting MariaDB 10.5.9 database server...
-- Subject: Unit mariadb.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit mariadb.service has begun starting up.
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [Note] /usr/sbin/mariadbd (mysqld 10.5.9-MariaDB) starting as process 14041 ...
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [Warning] Could not increase number of max_open_files to more than 16384 (reques
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [Note] InnoDB: The first innodb_system data file 'ibdata1' did not exist. A new 
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [Note] InnoDB: Uses event mutexes
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [Note] InnoDB: Compressed tables use zlib 1.2.7
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [Note] InnoDB: Number of pools: 1
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [Note] InnoDB: Using Linux native AIO
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 13
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [Note] InnoDB: Completed initialization of buffer pool
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread p
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [Note] InnoDB: Setting file './ibdata1' size to 12 MB. Physically writing the fi
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [Note] InnoDB: File './ibdata1' size is now 12 MB.
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [Note] InnoDB: Setting log file ./ib_logfile101 size to 100663296 bytes
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [Note] InnoDB: New log file created, LSN=10317
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [Note] InnoDB: Doublewrite buffer not found: creating new
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [Note] InnoDB: Doublewrite buffer created
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [Note] InnoDB: 128 rollback segments are active.
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [Note] InnoDB: Creating foreign key constraint system tables.
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [Note] InnoDB: Creating tablespace and datafile system tables.
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [Note] InnoDB: Creating sys_virtual system tables.
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [Note] InnoDB: Creating shared tablespace for temporary tables
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the fil
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [Note] InnoDB: 10.5.9 started; log sequence number 0; transaction id 7
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [Note] Plugin 'FEEDBACK' is disabled.
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [ERROR] Could not open mysql.plugin table: "Table 'mysql.plugin' doesn't exist".
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exis
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [Note] Server socket created on IP: '::'.
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.db' does
Apr 24 08:38:11 hw-1-8 mariadbd[14041]: 2021-04-24  8:38:11 0 [ERROR] Aborting
Apr 24 08:38:12 hw-1-8 systemd[1]: mariadb.service: main process exited, code=exited, status=1/FAILURE
Apr 24 08:38:12 hw-1-8 systemd[1]: Failed to start MariaDB 10.5.9 database server.
-- Subject: Unit mariadb.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit mariadb.service has failed.
-- 
-- The result is failed.
Apr 24 08:38:12 hw-1-8 systemd[1]: Unit mariadb.service entered failed state.
Apr 24 08:38:12 hw-1-8 systemd[1]: mariadb.service failed.
Apr 24 08:38:12 hw-1-8 polkitd[769]: Unregistered Authentication Agent for unix-process:14022:332606 (system bus name :1.70, object path /org/

主要是不能找到一些tables,解决方法如下:

 mariadb-install-db --user=mysql 

命令执行完成,在此执行启动MariaDB 即可正常启动,如有其他报错,请继续使用“journalctl -xe”命令查看启动日志,进行排查。


三、登录MariaDB并修改密码

登录MariaDB,密码为空;

mysql -uroot -p

自行修改密码,修改命令如下:

mysqladmin -u root password Dear@123456! -p vvlJb:iSx4?6

当然,也可以登录之后,使用alter命令进行修改:

alter user root@localhost identified by 'Dear@123456!';

至此MariaDB安装完成。

【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。