1.1 问题

本例要求基于kali2020环境,熟悉数据库服务的部署及基本验证方法,完成下列任务:

1)在kali2020上启用mysql服务,并设置开机自启

2)完成初始安全设置,将管理密码设为1234

3)使用 mysqladmin 更改管理密码,设置为 pwd@123

4)使用 mysql 验证无密码登录被拒绝
1.2 步骤

实现此案例需要按照如下步骤进行。

步骤一:在kali2020上启用mysql服务,并设置开机自启

1)启动mariadb数据库服务

root@kali:~# systemctl  start  mariadb
root@kali:~#

2)查看mariadb服务状态,确保激活标记为running

root@kali:~# systemctl  status  mariadb
● mariadb.service - MariaDB 10.3.20 database serverLoaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)Active: active (running) since Thu 2020-03-19 01:34:38 CST; 1min 50s ago     //正在运行Docs: man:mysqld(8)https://mariadb.com/kb/en/library/systemd/Process: 2880 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCC>Process: 2881 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUC>Process: 2883 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery>Process: 2962 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SU>Process: 2964 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)Main PID: 2931 (mysqld)Status: "Taking your SQL requests now..."Tasks: 31 (limit: 2309)Memory: 73.5MCGroup: /system.slice/mariadb.service└─2931 /usr/sbin/mysqld
3月 19 01:34:37 kali systemd[1]: Starting MariaDB 10.3.20 database server...
3月 19 01:34:37 kali mysqld[2931]: 2020-03-19  1:34:37 0 [Note] /usr/sbin/mysqld (mysqld 10.3.20-MariaDB-1) starting a>
3月 19 01:34:38 kali systemd[1]: Started MariaDB 10.3.20 database server.
3月 19 01:34:38 kali /etc/mysql/debian-start[2966]: Upgrading MySQL tables if necessary.
3月 19 01:34:38 kali /etc/mysql/debian-start[2969]: /usr/bin/mysql_upgrade: the '--basedir' option is always ignored
3月 19 01:34:38 kali /etc/mysql/debian-start[2969]: Looking for 'mysql' as: /usr/bin/mysql
3月 19 01:34:38 kali /etc/mysql/debian-start[2969]: Looking for 'mysqlcheck' as: /usr/bin/mysqlcheck
3月 19 01:34:38 kali /etc/mysql/debian-start[2969]: This installation of MySQL is already upgraded to 10.3.20-MariaDB,>
3月 19 01:34:38 kali /etc/mysql/debian-start[2977]: Checking for insecure root accounts.
3月 19 01:34:38 kali /etc/mysql/debian-start[2981]: Triggering myisam-recover for all MyISAM tables and aria-recover f>
lines 1-27/27 (END)                                     //按 q 键返回命令行
root@kali:~#

3)设置以后每次开机自动启动mariadb服务

root@kali:~# systemctl  enable  mariadb                     //标记开机自启
Created symlink /etc/systemd/system/mysql.service → /lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /lib/systemd/system/mariadb.service.
root@kali:~# systemctl  is-enabled  mariadb              //检查设置结果
enabled

4)测试快速访问

默认情况下,只要maridb服务已经运行,执行mysql命令无需密码即可连接。

root@kali:~# mysql                                  //连接本机数据库系统
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 36
Server version: 10.3.20-MariaDB-1 Debian buildd-unstable
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)]>                                      //连接成功
MariaDB [(none)]> quit                                 //退出(返回命令行)
Bye
root@kali:~#

步骤二:完成初始安全设置,将管理密码设为1234

执行mysql_secure_installation命令,可以针对默认的mariadb数据库执行一系列安全初始化设置,包括设置密码、禁止匿名登录等等。

root@kali:~# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDBSERVERS 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                             //输入y表示要设置新密码
New password:                                      //输入新密码,比如1234
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]                          //删除匿名数据库用户... 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]                      //禁止root用户远程登录... 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]                 //删除test库- 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]                          //重新加载数据库权限表... 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@kali:~#

步骤三:使用 mysql 验证无密码登录会被拒绝

当数据库系统要求用户名、密码,但是mysql连接未提供,或者提供的信息不对时,就会被拒绝(Access denied)。

root@kali:~# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
root@kali:~#

步骤四:使用 mysqladmin 更改管理密码,设置为 pwd@123

实际工作中,1234这样的密码肯定是非常不安全的,特别是对于数据库系统来说。

因此一方面密码设置应该足够复杂,另一方面最好定期使用mysqladmin更换密码。

root@kali:~# mysqladmin  -uroot  -p1234  password  'pwd@123'
root@kali:~#

基于kali2020环境,熟悉数据库服务的部署及基本验证方法及访问数据库相关推荐

  1. matlab悬置非线性位移计算公式,一种基于Excel的电动车动力总成悬置工况力数据处理方法与流程...

    本发明涉及计算机辅助工程(CAE)技术领域,具体涉及一种基于Excel的电动车动力总成悬置工况力数据处理方法. 背景技术: 动力总成的28工况力与位移分析是基于GM提出的传统车28工况修改而来,其分解 ...

  2. 运维之道 | 基于 LAMP 环境部署 Discuz 论坛

    基于 LAMP 环境部署 Discuz 论坛 LAMP环境部署 一.基于VMware虚拟机部署Centos系统 [root@localhost ~]# cat /etc/redhat-release ...

  3. 基于java的宠物管理系统设计与实现(项目报告+答辩PPT+源代码+数据库+截图+部署视频)

    基于JAVA的宠物网站的设计与实现 本系统是采用Java技术来构建的一个基于Web技术的B/S结构的宠物网站,该网站建立在Spring和Struts2框架之上,前台使用JSP作为开发语言,后台使用My ...

  4. 阿里云自动java和mysql数据库_阿里云服务器之基于Linux系统部署上线JavaWeb项目和连接MySQL数据库(从购买云服务器到发布JavaWeb项目全套详细流程)...

    阿里云服务器之基于Linux系统部署上线JavaWeb项目和连接MySQL数据库(从购买云服务器到发布JavaWeb项目全套详细流程) (仅此纪念人生第一篇学习博客) 前阵子接了一个小小的JavaWe ...

  5. 基于linux7的ectd安装与部署

    基于linux7的ectd安装与部署 系统环境 iostat Linux 3.10.0-693.17.1.el7.x86_64 (swarm1) 2018年03月28日 _x86_64_ (2 CPU ...

  6. 基于java的连连看游戏系统设计与实现(项目报告+答辩PPT+源代码+数据库+截图+部署视频)

    项目说明报告 基于Java的连连看游戏设计与实现 连连看是一种消除类益智游戏,核心要求是在规定的时间内,消除游戏界面中选中的两张相同的图案,直至完全消除所有图案.这款游戏操作简单(只需单击鼠标左键操作 ...

  7. 基于jsp的农产品销售管理系统设计与实现(项目报告+答辩PPT+源代码+数据库+截图+部署视频)

    项目报告 基于WEB的农产品销售管理系统 本文论述了基于JAVA.Web的农产品销售管理系统开发的目的及意义,目的是为了农产品资源的合理利用和物资的充分交流,有些地方富余而卖不出去,有些地方却吃不上. ...

  8. 基于jsp的项目管理平台系统设计与实现(项目报告+答辩PPT+源代码+数据库+截图+部署视频)

    项目报告 基于Java EE平台项目管理系统的设计与实现 随着社会信息化的发展,很多的社会管理问题也一并出现了根本性变化,项目公司的报表及文件管理也发生了变化,以前的管理是一个分布式的信息,然后围绕中 ...

  9. 基于华为云的Django网站部署

    学习笔记,仅供参考,有错必纠 参考自:Xshell远程连接服务器:win10 开启ssh server服务 远程登录 文章目录 基于华为云的Django网站部署 远程登录华为云 Xftp+Xshell ...

最新文章

  1. 详解数组中的reduce方法
  2. JPA 2.2改进了易用性
  3. HBase解决Region Server Compact过程占用大量网络出口带宽的问题
  4. 对人工神经网络“开刀”,利用神经科学消融法检测人工神经网络
  5. window7 64 VS2015下openCV3.4.0安装
  6. 源码分析 vue-cli 中安装依赖
  7. (剑指Offer)面试题18:树的子结构
  8. Java基础--通过反射获取成员方法并使用
  9. boost::fibers::fiber用法的测试程序
  10. 模板打印:代码实现和总结
  11. css3 下边框缓缓划过_一篇文章带你了解CSS3按钮知识
  12. 第二百五十八天 how can I 坚持
  13. kancloud mysql内核_锁 · Mysql · 看云
  14. 190505每日一句
  15. JSP程序设计 第2版 pdf
  16. openCV项目实战-信用卡数字识别PyCharm版(唐宇迪)
  17. history linux 位置,Linux基础知识之history的详细说明
  18. EMMC和Nand傻傻分不清
  19. 智能窗帘控制(语音、时间、光、红外)
  20. Axure 实现问卷调查(带计时器功能)

热门文章

  1. 华为天才少年造出自动驾驶单车!图纸已开源,硬件成本一万,B站老板:重新定义「自行」车...
  2. mac导出iphone手机上的ipa包
  3. 存储备份从入门到精通
  4. 控制结构(强化):18.今夕何夕
  5. Linux通过命令行将英文改成中文
  6. tortoise git 更换邮箱和账号时,报错because commituserEmail is not oncorrect
  7. [安卓开发笔记二]android Studio通过jni调用C++代码
  8. 济南大学计算机考研资料汇总
  9. 基于JAVA模拟考试系统计算机毕业设计源码+数据库+lw文档+系统+部署
  10. 黑马程序员C++职工管理系统