云计算-带你安装MySQL数据库并去除安全隐患
来源:SegmentFault
时间:2023-01-14 11:13:42 411浏览 收藏
你在学习数据库相关的知识吗?本文《云计算-带你安装MySQL数据库并去除安全隐患》,主要介绍的内容就涉及到MySQL、Linux、运维、云计算,如果你想提升自己的开发能力,就不要错过这篇文章,大家要知道编程理论基础和实战操作都是不可或缺的哦!

Mariabd安全配置向导
**1.安装完mariadb-server后,运行mysql_secure_installation去除安全隐患
mysql_secure_installation会执行几个设置:**
- 为root用户设置密码
- 删除匿名账号
- 取消root用户远程登录
- 删除test库和对test库的访问权限
- 刷新授权表使修改生效
[root@xuegod63 ~]# mysql_secure_installation #进入安全配置向导
**通过这几项的设置能够提高MySQL库的安全。建议生产环境中MySQL安装完成后一定要运
行一次mysql_secure_installation,详细步骤请参看下面的命令:**
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MySQL to secure it, we'll need the current password for the root user. If you've just installed MySQL, 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): #初次运行直接回车,因为root用户没有密码 OK, successfully used password, moving on… Setting the root password ensures that nobody can log into the MySQL root user without the proper authorisation. Set root password? [Y/n] Y #是否设置root用户密码,输入Y New password: 123456 #新密码123456 Re-enter new password: 123456 Password updated successfully! 。。。 Remove anonymous users? [Y/n] Y #是否删除匿名用户,生产环境建议删除,所以直接回车或 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 #是否禁止root远程登录,根据自己的需求选择 Y/n并回车,建议禁止 ... 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 #是否删除test数据库,直接回车或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密码
[root@xuegod63 ~]# mysqladmin -u root password "123456"
2. 数据库连接
连接MariaDB数据库,连接本机可以去掉 -h选项
# mysql #如MariaDB没有设置密码,并在本地上登录,而且是使用默认端口的情况 下,可以直接使用mysql命令登录。 或: # mysql -h IP -u USER -pPASS #如 MariaDB不是安装在本地时,需要使用-h选项指定 IP登录,如 MariaDB用户设置了密码时,需要使用-u选项指定用户,并使用-p选项指定密码,注意的是 在-p选项和密码之间不能有空格,否则在命令执行后需要再次输入密码,并将有空格的密码串识别为登录 的数据库。 MariaDB的超级管理员是root用户,拥有MariaDB数据库的最高权限。
3. 测试数据是否正常
[root@xuegod63 ~]# mysql -u root -p123456 MariaDB [(none)]> show databases; #没有test数据库 #执行时,所有命令以;号结尾 +-------------------------+ | Database | +-------------------------+ | information_schema | | mysql | | ucenter | +-------------------------+ 3 rows in set (0.00 sec) MariaDB [(none)]> exit #退出命令可以加分号,也可以不加分号。
4. 测试网站是否支持PHP
[root@xuegod63 ~]# cd /var/www/html/ [root@xuegod63 html]# vim index.php [root@xuegod63 html]# systemctl restart httpd #重启httpd服务。 [root@xuegod63 html]# iptables -F #清空防火墙
测试:

LAMP网站架构搭建完成
到此MySQL数据库安装成功
小伙伴想要获取学习视频+笔记资料的
请添加我们小姐姐
我们也有Windows上安装mysql教程哦!

今天关于《云计算-带你安装MySQL数据库并去除安全隐患》的内容介绍就到此结束,如果有什么疑问或者建议,可以在golang学习网公众号下多多回复交流;文中若有不正之处,也希望回复留言以告知!
声明:本文转载于:SegmentFault 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
-
499 收藏
-
244 收藏
-
235 收藏
-
157 收藏
-
101 收藏
最新阅读
更多>
-
443 收藏
-
202 收藏
-
365 收藏
-
223 收藏
-
334 收藏
-
224 收藏
课程推荐
更多>
-
- 前端进阶之JavaScript设计模式
- 设计模式是开发人员在软件开发过程中面临一般问题时的解决方案,代表了最佳的实践。本课程的主打内容包括JS常见设计模式以及具体应用场景,打造一站式知识长龙服务,适合有JS基础的同学学习。
- 立即学习 542次学习
-
- GO语言核心编程课程
- 本课程采用真实案例,全面具体可落地,从理论到实践,一步一步将GO核心编程技术、编程思想、底层实现融会贯通,使学习者贴近时代脉搏,做IT互联网时代的弄潮儿。
- 立即学习 507次学习
-
- 简单聊聊mysql8与网络通信
- 如有问题加微信:Le-studyg;在课程中,我们将首先介绍MySQL8的新特性,包括性能优化、安全增强、新数据类型等,帮助学生快速熟悉MySQL8的最新功能。接着,我们将深入解析MySQL的网络通信机制,包括协议、连接管理、数据传输等,让
- 立即学习 497次学习
-
- JavaScript正则表达式基础与实战
- 在任何一门编程语言中,正则表达式,都是一项重要的知识,它提供了高效的字符串匹配与捕获机制,可以极大的简化程序设计。
- 立即学习 487次学习
-
- 从零制作响应式网站—Grid布局
- 本系列教程将展示从零制作一个假想的网络科技公司官网,分为导航,轮播,关于我们,成功案例,服务流程,团队介绍,数据部分,公司动态,底部信息等内容区块。网站整体采用CSSGrid布局,支持响应式,有流畅过渡和展现动画。
- 立即学习 484次学习