您当前的位置:首页 > 知乎文章

干货教程:如何在服务器上安装Mysql8.0

时间:2022-02-28 10:48:24  知乎原文链接  作者:网盾科技

一、准备

打开后台查到自己机器的远程信息

使用xshell连接

连接到 ecs,然后移除 默认的 mariadb数据库:

yum remove mariadb-libs.x86_641

这里显示没有默认包,有的会有,反正保险起见,执行一遍

二、下载安装包

然后 创建目录mysql,小编一般软件放在 /usr/local 下,
cd 到/usr/local 下mkdir mysql 然后进入目录,下载 mysql8.0安装包

cd /usr/localmkdir mysqlcd mysqlwget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm1234

三、本地安装

# 注意下图红框内(安装包名称)一致yum localinstall mysql80-community-release-el7-3.noarch.rpm12


会出现这种选项,输入 y即可

安装 mysql-community-server

#先运行yum module disable mysql#然后再运行yum install mysql-community-server 
1234

凡是遇到 上图 Is this ok [y/N]:都填y

出现下图这种的即表示安装成功:

四、登陆验证

# 然后启动mysql服务service mysqld start 
# 查看状态service mysqld status1234

如下图所示,表示启动成功

# 查看初始密码cat /var/log/mysqld.log | grep password12
# 使用上面的初始密码登录mysqlmysql -u root -p12

五、配置MySQL的安全性

# 需要先退出mysql进入系统环境 exit;# mysql安全配置命令mysql_secure_installation# i 重置root账号密码Enter password for user root: #输入上一步获取的root用户初始密码The 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration of the plugin.
Using existing password for root.
Estimated strength of the password: 100 
Change the password for root ? (Press y|Y for Yes, any other key for No) : Y #是否更改root用户密码,输入YNew password: #输入新密码,长度为8至30个字符,必须同时包含大小写英文字母、数字和特殊符号。特殊符号可以是()` ~!@#$%^&*-+=|{}[]:;‘<>,.?/Re-enter new password: #再次输入新密码Estimated strength of the password: 100 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y#  后面一直输y即可,指导all done 自动退出#ii 输入Y删除匿名用户账号By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL 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? (Press y|Y for Yes, any other key for No) : Y  #是否删除匿名用户,输入YSuccess.# iii 输入Y禁止root账号远程登录Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y #禁止root远程登录,输入YSuccess.# iv 输入Y删除test库以及对test库的访问权限Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y #是否删除test库和对它的访问权限,输入Y- Dropping test database...
Success.# v 输入Y重新加载授权表Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y #是否重新加载授权表,输入YSuccess.
All done!12345678910111213141516171819202122232425262728293031323334353637

六、关于服务器

为什么初学者需要一台云服务器?
重点无非这一个词:实践。

细数一下初学者拥有一台云服务器的好处

  • 学习操作系统、熟悉环境
  • 部署自己的应用
而云服务器可以给你这样的条件,可以从几个小页面做起,可以部署自己的博客(能用自己的域名访问博客,似乎比使用第三方平台逼格要高那么一点),然后再学习一下试试微信公众号的服务开发?做一个简易的机器人小秘书等等。再往后可以找几个小伙伴合作开发软件,后台部署在云主机上提供服务等。学技术本身就是属于一件较为枯燥的事情,如果能有这些乐趣给自己反馈,相信能获得继续走下去的动力。
或者写几个多线程爬虫,抓取一些你感兴趣的东西,比如全校学生的学生证照片?再或者其他的一些资源(自己发挥想象)?在云主机上跑个几天几夜,自己则可以溜了玩去了。
比如大数据分布式的Hadoop,spark环境等等,身为沪漂不可能每年搬家带着一大堆机器吧,云服务器就很好的解决了这个问题,而且就像前面说的云服务器玩崩了,直接一键重装就完事儿了
上一篇      下一篇    删除文章    编辑文章
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表
推荐资讯
相关文章
    无相关信息
栏目更新
栏目热门