1.Mariadb 安装
1.1 创建MariaDB.repo文件编辑写入mariadb yum存储库链接
1 | Here is your custom MariaDB YUM repository entry for CentOS. Copy and paste it into a file under /etc/yum.repos.d/ (we suggest naming the file MariaDB.repo or something similar). |
这是CentOS的自定义MariaDB YUM存储库链接。将下面这段复制并粘贴到/etc/yum.repos.d/下的文件中(我们建议命名文件MariaDB.repo或类似的命名文件)。
1 | # MariaDB 10.4 CentOS repository list - created 2019-09-03 00:58 UTC |
2 | # http://downloads.mariadb.org/mariadb/repositories/ |
3 | [mariadb] |
4 | name = MariaDB |
5 | baseurl = http://yum.mariadb.org/10.4/centos7-amd64 |
6 | gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB |
7 | gpgcheck=1 |
1.2 文件编辑完成后,安装MariaDB
安装MariaDB服务器和客户端软件包
1 | yum install MariaDB-server MariaDB-client |
yum安装过程中,可能会提示您导入MariaDB GPG密钥:
1 | 从 https://yum.mariadb.org/RPM-GPG-KEY-MariaDB 检索密钥 |
2 | 导入 GPG key 0x1BB943DB: |
3 | 用户ID : "MariaDB Package Signing Key <package-signing-key@mariadb.org>" |
4 | 指纹 : 1993 69e5 404b d5fc 7d2f e43b cbcb 082a 1bb9 43db |
5 | 来自 : https://yum.mariadb.org/RPM-GPG-KEY-MariaDB |
6 | 是否继续?[y/N]:y |
7 | |
8 | 输入y,按enter即可 |
1.3 安装完成后,启动MariaDB
1.3.1 启动mariadb
1 | systemctl start mariadb |
1.3.2 设置开机自启动
1 | systemctl enable mariadb |
1.3.3 查看mariadb状态
1 | systemctl status mariadb |
1.4 最后一步是运行mysql_secure_installation脚本,该脚本将执行几个与安全相关的任务
1 | mysql_secure_installation |
该脚本将提示您设置root用户密码,删除匿名用户,限制root用户对本地计算机的访问,以及删除测试数据库。
所有步骤都会详细解释,建议回答Y(是)所有问题。
1.5 连接mariadb数据库
1 | mysql -u root -p |
其他
1.常见问题错误
1.1 yum源异常
1.1.1 错误样式
1 | Loaded plugins: fastestmirror |
2 | Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was |
3 | 14: curl#56 - "Recv failure: Connection reset by peer" |
4 | |
5 | One of the configured repositories failed (Unknown), |
6 | and yum doesn't have enough cached data to continue. At this point the only |
7 | safe thing yum can do is fail. There are a few ways to work "fix" this: |
8 | 1. Contact the upstream for the repository and get them to fix the problem. |
9 | 2. Reconfigure the baseurl/etc. for the repository, to point to a working |
10 | upstream. This is most often useful if you are using a newer |
11 | distribution release than is supported by the repository (and the |
12 | packages for the previous distribution release still work). |
13 | 3. Disable the repository, so yum won't use it by default. Yum will then |
14 | just ignore the repository until you permanently enable it again or use |
15 | --enablerepo for temporary usage: |
16 | yum-config-manager --disable <repoid> |
17 | 4. Configure the failing repository to be skipped, if it is unavailable. |
18 | Note that yum will try to contact the repo. when it runs most commands, |
19 | so will have to try and fail each time (and thus. yum will be be much |
20 | slower). If it is a very temporary problem though, this is often a nice |
21 | compromise: |
22 | yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true |
23 | Cannot find a valid baseurl for repo: base/7/x86_64 |
1.1.2 解决方法
1 | 第一步:进入这个文件vi /etc/resolv.conf |
2 | 第二步:修改DNS服务器系统(nameserver 114.114.114.114(这是国内的dns服务器系统,还是比较好用的。谷歌的可以使用8.8.8.8)) |
3 | 第三步:重启配置文件(systemctl restart network) |