数据库


CentOS8上dnf安装MariaDB 10.5

<h3>1.添加mariadb的repo源</h3> <h4>1.1.获取官方repo</h4> <p>可以从Mariadb官方获取repo,<a href="https://downloads.mariadb.org/">https://downloads.mariadb.org/</a> <img src="https://www.showdoc.cc/server/api/common/visitfile/sign/c9c8f178cd4e38e27931dc69ba7167f7?showdoc=.jpg" alt="" /> 进入下一页 <img src="https://www.showdoc.cc/server/api/common/visitfile/sign/0a585b63067954ada0bdf9365d4ae47a?showdoc=.jpg" alt="" /> MariaDB官网repo源内容如下 :</p> <pre><code class="language-bash">[mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.5/centos8-amd64 module_hotfixes=1 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1</code></pre> <h4>1.2.获取国内repo</h4> <p>国内源也有很多,比如:阿里、清华等,如下: MariaDB阿里repo源,本次采用这个,内容如下:</p> <pre><code class="language-bash">[mariadb] name = MariaDB baseurl = https://mirrors.aliyun.com/mariadb/yum/10.5/centos8-amd64/ gpgkey=https://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDB gpgcheck=1</code></pre> <p>MariaDB清华repo源,内容如下:</p> <pre><code class="language-bash">[mariadb] name = MariaDB baseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.5/centos8-amd64 gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB gpgcheck=1</code></pre> <h3>2.添加国内repo</h3> <p>由于MariaDB的repo在国外,下载速度慢,可以采用国内的repo</p> <pre><code class="language-bash">vim /etc/yum.repos.d/MariaDB.repo 把repo加入成功后,内容如下: [mariadb] name = MariaDB baseurl = https://mirrors.aliyun.com/mariadb/yum/10.5/centos8-amd64/ gpgkey=https://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDB gpgcheck=1</code></pre> <h3>3.更新</h3> <pre><code class="language-bash">dnf update -y</code></pre> <h3>4.安装MariaDB</h3> <p>安装时建议禁用提供MariaDB软件包的AppStream存储库</p> <pre><code class="language-bash">dnf install galera-4 #依赖包 dnf --disablerepo=AppStream install MariaDB-server MariaDB-client #CentOS8可以安装成功 dnf install MariaDB-server MariaDB-client #CentOS7下不需禁用AppStream</code></pre> <p>说明:安装时注意官方repo和阿里repo,注意区别大小写:</p> <pre><code class="language-bash">官方repo: dnf install MariaDB-server dnf install mariadb-server dnf install mariadb-server 安装的程序包大小和包数量上也有区别。 阿里repo: dnf install mariadb-server dnf install MariaDB-client</code></pre> <h3>5.启动</h3> <pre><code class="language-bash">systemctl start mariadb.service</code></pre> <h3>6.设置随机启动</h3> <pre><code class="language-bash">systemctl enable mariadb</code></pre> <h3>7.登录</h3> <p>首次登录密码为空</p> <pre><code class="language-bash">mysql -uroot -p 回车,密码为空</code></pre> <h3>8.设置密码</h3> <pre><code class="language-bash">MariaDB [(none)]&gt;set password=password('newpasswd'); 或 MariaDB [(none)]&gt;alter user 'root'@'localhost' identified by 'newpasswd';</code></pre> <h3>9.安全设置</h3> <pre><code class="language-bash">mysql_secure_installation </code></pre>

页面列表

ITEM_HTML