赞
踩
系统版本:
[root@localhost 桌面]# nkvers
############## Kylin Linux Version #################
Release:
Kylin Linux Advanced Server release V10 (Sword)
Kernel:
4.19.90-24.4.v2101.ky10.x86_64
Build:
Kylin Linux Advanced Server
release V10 (SP2) /(Sword)-x86_64-Build09/20210524
#################################################
[root@localhost 桌面]#
如果服务器无法连接外网,并且没有预装 mariadb ,那么就需要先配置镜像源,然后才能安装 mariadb 。如果你的服务器可以连接外网,那么可以跳过这一步,直接按照第3步中的方法安装 mariadb 。
这里我把系统镜像上传到 /root 目录。
[root@localhost 桌面]# ls /root/
公共 模板 视频 图片 文档 下载 音乐 桌面 anaconda-ks.cfg initial-setup-ks.cfg Kylin-Server-10-SP2-x86-Release-Build09-20210524.iso
[root@localhost 桌面]#
将系统镜像挂载到 /mnt 目录。
[root@localhost 桌面]# mount /root/Kylin-Server-10-SP2-x86-Release-Build09-20210524.iso /mnt mount: /mnt: WARNING: source write-protected, mounted read-only. [root@localhost 桌面]# [root@localhost 桌面]# [root@localhost 桌面]# df -hT 文件系统 类型 容量 已用 可用 已用% 挂载点 devtmpfs devtmpfs 1.4G 0 1.4G 0% /dev tmpfs tmpfs 1.5G 4.0K 1.5G 1% /dev/shm tmpfs tmpfs 1.5G 9.7M 1.5G 1% /run tmpfs tmpfs 1.5G 0 1.5G 0% /sys/fs/cgroup /dev/mapper/klas-root xfs 66G 14G 52G 21% / tmpfs tmpfs 1.5G 44K 1.5G 1% /tmp /dev/sda1 xfs 1014M 214M 801M 22% /boot tmpfs tmpfs 289M 44K 289M 1% /run/user/0 /dev/loop0 iso9660 4.1G 4.1G 0 100% /mnt [root@localhost 桌面]#
我们需要创建一个 /repo 目录,并将系统镜像中的文件全部拷贝到这个目录下。
[root@localhost 桌面]# mkdir /repo [root@localhost 桌面]# cp -r /mnt/. /repo/ [root@localhost 桌面]# [root@localhost 桌面]# ls -la /repo/ 总用量 232 drwxr-xr-x 8 root root 227 5月 1 17:04 . dr-xr-xr-x. 22 root root 4096 5月 1 17:04 .. -rw-r--r-- 1 root root 53 5月 1 17:04 .discinfo drwxr-xr-x 3 root root 35 5月 1 17:04 EFI drwxr-xr-x 3 root root 104 5月 1 17:04 images drwxr-xr-x 2 root root 256 5月 1 17:04 isolinux -rw-r--r-- 1 root root 1149 5月 1 17:04 .kylin-post-actions -rw-r--r-- 1 root root 2028 5月 1 17:04 .kylin-post-actions-nochroot drwxr-xr-x 2 root root 214 5月 1 17:04 manual drwxr-xr-x 2 root root 159744 5月 1 17:04 Packages -rw-r--r-- 1 root root 81 5月 1 17:04 .productinfo drwxr-xr-x 2 root root 4096 5月 1 17:04 repodata -r--r--r-- 1 root root 2448 5月 1 17:04 TRANS.TBL -rw-r--r-- 1 root root 437 5月 1 17:04 .treeinfo [root@localhost 桌面]#
先将系统默认的仓库源配置文件备份。
[root@localhost 桌面]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]#
[root@localhost yum.repos.d]# ls
kylin_x86_64.repo
[root@localhost yum.repos.d]#
[root@localhost yum.repos.d]# mv kylin_x86_64.repo kylin_x86_64.repo.bak
[root@localhost yum.repos.d]#
[root@localhost yum.repos.d]# ls
kylin_x86_64.repo.bak
[root@localhost yum.repos.d]#
然后新建 local.repo ,在里面添加如下配置。
[root@localhost yum.repos.d]# vim local.repo
[root@localhost yum.repos.d]#
配置如下:
###Kylin Linux Advanced Server 10 - os repo###
[ks10-adv-os]
name = Kylin Linux Advanced Server 10 - Os
baseurl = file:///repo
gpgcheck = 1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-kylin
enabled = 1
[root@localhost yum.repos.d]# yum clean all
13 文件已删除
[root@localhost yum.repos.d]# yum makecache
Kylin Linux Advanced Server 10 - Os 288 MB/s | 3.7 MB 00:00
上次元数据过期检查:0:00:01 前,执行于 2023年05月01日 星期一 17时21分53秒。
元数据缓存已建立。
[root@localhost yum.repos.d]#
[root@localhost 桌面]# yum install mariadb* 上次元数据过期检查:0:16:57 前,执行于 2023年05月01日 星期一 17时21分53秒。 软件包 mariadb-connector-c-3.0.6-7.ky10.x86_64 已安装。 依赖关系解决。 ======================================================================================================================================================= Package Architecture Version Repository Size ======================================================================================================================================================= 安装: mariadb x86_64 3:10.3.9-9.p02.ky10 ks10-adv-os 6.1 M mariadb-common x86_64 3:10.3.9-9.p02.ky10 ks10-adv-os 28 k mariadb-connector-c-devel x86_64 3.0.6-7.ky10 ks10-adv-os 47 k mariadb-devel x86_64 3:10.3.9-9.p02.ky10 ks10-adv-os 1.0 M mariadb-errmessage x86_64 3:10.3.9-9.p02.ky10 ks10-adv-os 196 k mariadb-server x86_64 3:10.3.9-9.p02.ky10 ks10-adv-os 18 M 事务概要 ======================================================================================================================================================= 安装 6 软件包 总计:25 M 安装大小:136 M 确定吗?[y/N]: y 下载软件包: 运行事务检查 事务检查成功。 运行事务测试 事务测试成功。 运行事务 准备中 : 1/1 安装 : mariadb-common-3:10.3.9-9.p02.ky10.x86_64 1/6 安装 : mariadb-errmessage-3:10.3.9-9.p02.ky10.x86_64 2/6 运行脚本: mariadb-server-3:10.3.9-9.p02.ky10.x86_64 3/6 安装 : mariadb-server-3:10.3.9-9.p02.ky10.x86_64 3/6 运行脚本: mariadb-server-3:10.3.9-9.p02.ky10.x86_64 3/6 安装 : mariadb-3:10.3.9-9.p02.ky10.x86_64 4/6 安装 : mariadb-connector-c-devel-3.0.6-7.ky10.x86_64 5/6 安装 : mariadb-devel-3:10.3.9-9.p02.ky10.x86_64 6/6 运行脚本: mariadb-devel-3:10.3.9-9.p02.ky10.x86_64 6/6 /sbin/ldconfig: /usr/lib64/libLLVM-7.so 不是符号链接 验证 : mariadb-3:10.3.9-9.p02.ky10.x86_64 1/6 验证 : mariadb-common-3:10.3.9-9.p02.ky10.x86_64 2/6 验证 : mariadb-connector-c-devel-3.0.6-7.ky10.x86_64 3/6 验证 : mariadb-devel-3:10.3.9-9.p02.ky10.x86_64 4/6 验证 : mariadb-errmessage-3:10.3.9-9.p02.ky10.x86_64 5/6 验证 : mariadb-server-3:10.3.9-9.p02.ky10.x86_64 6/6 已安装: mariadb-3:10.3.9-9.p02.ky10.x86_64 mariadb-common-3:10.3.9-9.p02.ky10.x86_64 mariadb-connector-c-devel-3.0.6-7.ky10.x86_64 mariadb-devel-3:10.3.9-9.p02.ky10.x86_64 mariadb-errmessage-3:10.3.9-9.p02.ky10.x86_64 mariadb-server-3:10.3.9-9.p02.ky10.x86_64 完毕! [root@localhost 桌面]#
[root@localhost 桌面]# systemctl enable --now mariadb.service
Created symlink /etc/systemd/system/mysql.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.
[root@localhost 桌面]#
使用 mariadb 自带的 mysql_secure_installation 工具进行初始化配置。
输入 mysql_secure_installation 配置密码,过程如下:
[root@localhost 桌面]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n]
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] Y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] n
... skipping.
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] Y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
[root@localhost 桌面]# mysql -uroot -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 15 Server version: 10.3.9-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | +--------------------+ 3 rows in set (0.000 sec) MariaDB [(none)]> quit Bye
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。