1.安装mariadb
1.安装mariadb
[root@dsrw ~]# dnf install -y mariadb mariadb-server
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
AppStream 33 kB/s | 3.2 kB 00:00
-BaseOS 2.7 MB/s | 2.7 kB 00:00
依赖关系解决。
================================================================================
软件包 架构 版本 仓库 大小
================================================================================
Installing:
mariadb x86_64 3:10.3.11-1.module+el8+2765+cfa4f87b AppStream 6.2 M
mariadb-server x86_64 3:10.3.11-1.module+el8+2765+cfa4f87b AppStream 16 M
安装依赖关系:
mariadb-common x86_64 3:10.3.11-1.module+el8+2765+cfa4f87b AppStream 62 k
mariadb-connector-c
x86_64 3.0.7-1.el8 AppStream 148 k
mariadb-connector-c-config
noarch 3.0.7-1.el8 AppStream 13 k
mariadb-errmsg x86_64 3:10.3.11-1.module+el8+2765+cfa4f87b AppStream 232 k
perl-DBD-MySQL x86_64 4.046-2.module+el8+2515+0650e81c AppStream 156 k
安装弱的依赖:
mariadb-backup x86_64 3:10.3.11-1.module+el8+2765+cfa4f87b AppStream 6.2 M
mariadb-gssapi-server
x86_64 3:10.3.11-1.module+el8+2765+cfa4f87b AppStream 49 k
mariadb-server-utils
x86_64 3:10.3.11-1.module+el8+2765+cfa4f87b AppStream 1.6 M
Enabling module streams:
mariadb 10.3
perl-DBD-MySQL 4.046
事务概要
================================================================================
安装 10 软件包
总计:31 M
安装大小:162 M
下载软件包:
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
运行脚本 : mariadb-connector-c-3.0.7-1.el8.x86_64 1/1
准备中 : 1/1
Installing : mariadb-connector-c-config-3.0.7-1.el8.noarch 1/10
Installing : mariadb-common-3:10.3.11-1.module+el8+2765+cfa4f87b.x86 2/10
Installing : mariadb-connector-c-3.0.7-1.el8.x86_64 3/10
Installing : perl-DBD-MySQL-4.046-2.module+el8+2515+0650e81c.x86_64 4/10
Installing : mariadb-errmsg-3:10.3.11-1.module+el8+2765+cfa4f87b.x86 5/10
Installing : mariadb-backup-3:10.3.11-1.module+el8+2765+cfa4f87b.x86 6/10
Installing : mariadb-gssapi-server-3:10.3.11-1.module+el8+2765+cfa4f 7/10
Installing : mariadb-server-utils-3:10.3.11-1.module+el8+2765+cfa4f8 8/10
运行脚本 : mariadb-server-3:10.3.11-1.module+el8+2765+cfa4f87b.x86 9/10
Installing : mariadb-server-3:10.3.11-1.module+el8+2765+cfa4f87b.x86 9/10
运行脚本 : mariadb-server-3:10.3.11-1.module+el8+2765+cfa4f87b.x86 9/10
Installing : mariadb-3:10.3.11-1.module+el8+2765+cfa4f87b.x86_64 10/10
运行脚本 : mariadb-3:10.3.11-1.module+el8+2765+cfa4f87b.x86_64 10/10
验证 : mariadb-3:10.3.11-1.module+el8+2765+cfa4f87b.x86_64 1/10
验证 : mariadb-backup-3:10.3.11-1.module+el8+2765+cfa4f87b.x86 2/10
验证 : mariadb-common-3:10.3.11-1.module+el8+2765+cfa4f87b.x86 3/10
验证 : mariadb-connector-c-3.0.7-1.el8.x86_64 4/10
验证 : mariadb-connector-c-config-3.0.7-1.el8.noarch 5/10
验证 : mariadb-errmsg-3:10.3.11-1.module+el8+2765+cfa4f87b.x86 6/10
验证 : mariadb-gssapi-server-3:10.3.11-1.module+el8+2765+cfa4f 7/10
验证 : mariadb-server-3:10.3.11-1.module+el8+2765+cfa4f87b.x86 8/10
验证 : mariadb-server-utils-3:10.3.11-1.module+el8+2765+cfa4f8 9/10
验证 : perl-DBD-MySQL-4.046-2.module+el8+2515+0650e81c.x86_64 10/10
Installed products updated.
已安装:
mariadb-3:10.3.11-1.module+el8+2765+cfa4f87b.x86_64
mariadb-server-3:10.3.11-1.module+el8+2765+cfa4f87b.x86_64
mariadb-backup-3:10.3.11-1.module+el8+2765+cfa4f87b.x86_64
mariadb-gssapi-server-3:10.3.11-1.module+el8+2765+cfa4f87b.x86_64
mariadb-server-utils-3:10.3.11-1.module+el8+2765+cfa4f87b.x86_64
mariadb-common-3:10.3.11-1.module+el8+2765+cfa4f87b.x86_64
mariadb-connector-c-3.0.7-1.el8.x86_64
mariadb-connector-c-config-3.0.7-1.el8.noarch
mariadb-errmsg-3:10.3.11-1.module+el8+2765+cfa4f87b.x86_64
perl-DBD-MySQL-4.046-2.module+el8+2515+0650e81c.x86_64
完毕!
2.重启服务并加入启动项
[root@dsrw ~]# systemctl start mariadb
[root@dsrw ~]# systemctl enable mariadb
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.
3.先对数据库程序进行初始化操作。
1)设置root管理员在数据库中的密码值(注意,该密码并非root管理员在系统中的密码,这里的密码值默认应该为空,可直接按回车键)。
2)设置root管理员在数据库中的专有密码。
3)删除匿名用户,并使用root管理员从远程登录数据库,以确保数据库上运行的业务的安全性。
4)删除默认的测试数据库,取消测试数据库的一系列访问权限。
5)刷新授权列表,让初始化的设定立即生效。
[root@dsrw ~]# 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] y
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] y
... Success!
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!
4.修改防火墙策略
[root@dsrw ~]# firewall-cmd --permanent --add-service=mysql
success
[root@dsrw ~]# firewall-cmd --reload
success
5.登录数据库,命令格式:mysql -u 用户名 -p 密码
[root@dsrw ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 16
Server version: 10.3.11-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)]> help
General information about MariaDB can be found at
MariaDB Foundation
List of all MySQL commands:
Note that all text commands must be first on line and end with ';'
? (\?) Synonym for `help'.
clear (\c) Clear the current input statement.
connect (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter.
edit (\e) Edit command with $EDITOR.
ego (\G) Send command to mysql server, display result vertically.
exit (\q) Exit mysql. Same as quit.
go (\g) Send command to mysql server.
help (\h) Display this help.
nopager (\n) Disable pager, print to stdout.
notee (\t) Don't write into outfile.
pager (\P) Set PAGER [to_pager]. Print the query results via PAGER.
print (\p) Print current command.
prompt (\R) Change your mysql prompt.
quit (\q) Quit mysql.
rehash (\#) Rebuild completion hash.
source (\.) Execute an SQL script file. Takes a file name as an argument.
status (\s) Get status information from the server.
system (\!) Execute a system shell command.
tee (\T) Set outfile [to_outfile]. Append everything into given outfile.
use (\u) Use another database. Takes database name as argument.
charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.
warnings (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.
For server side help, type 'help contents'
MariaDB [(none)]> SHOW databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.000 sec)
MariaDB [(none)]> SET password=PASSWORD('dsrw.com');
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]> exit
Bye
[root@dsrw ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 17
Server version: 10.3.11-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.
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
请登录后查看评论内容