AWS中怎么安装Mysql

发布时间:2021-06-21 15:21:52 作者:Leah
来源:亿速云 阅读:629

AWS中怎么安装Mysql,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。

第一步: 切换到root账户

sudo -s

更换时区为东八区(北京时间)

mv /etc/localtime /etc/localtime.bak 
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

第二步: 需要更新一下yum(因为亚马逊的yum版本经常都是晚于潮流)

yum update

第三步: 安装mysql

yum install -y mysql57-server

如果提示 Unable to find a match: mysql57-server则需要去mysql官网获取下安装包

//下载
sudo rpm -ivh https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
//安装
sudo yum install mysql-server

第四步: 启动mysql

service mysqld start
#设置开机自启动
chkconfig mysqld on

第五步: 做一些基础配置

mysql_secure_installation

下面的内容会比较多,其实就几个

[root@ip-172-31-35-183 ec2-user]# mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

#询问你是否启用密码校验
Press y|Y for Yes, any other key for No: y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file

#询问你要使用什么强度的密码,输入0就可以使用任意密码,还有 1和2可选自己看上两行的强度要求
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0
Please set the password for root here.
#输入你的密码
New password: 
#再次数据你的密码
Re-enter new password: 
#这行是评价你设定密码的强度,可以忽略
Estimated strength of the password: 50 
#上一行评价了你的密码强度,如果你觉得不够,你可以输入n重新设置密码,如果对自己的密码满意就输入y,确认使用新密码
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : 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.
#询问你是否删除所有匿名用户,直接选y即可,不需要多想(要多想也随意)
Remove anonymous users? (Press y|Y for Yes, any other key for No) : 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.
#问你是否要禁用root账户的远程连接,如果禁用了你就只能玩单机操作了,所以选择 n
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n

 ... skipping.
By default, MySQL 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.

#问你要不要删除所有测试数据,数据库新装会有一些默认的测试数据,删不删没影响,y和n随意
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : 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.
#问你要不要更新配置(屁话,设置这么辛苦肯定马上更新使用了) y
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done!

第六步: 使用刚设置的密码登入数据库,修改远程ip权限

mysql -u root -p

设置用户 root 可以在任意 IP 下被访问:

grant all privileges on *.* to root@"%" identified by "你的密码";

设置用户 root 可以在本地被访问:

grant all privileges on *.* to root@"localhost" identified by "你的密码";

设置完访问权限后,需要刷新一下

flush privileges

至此结束

关于AWS中怎么安装Mysql问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注亿速云行业资讯频道了解更多相关知识。

推荐阅读:
  1. 使用DMS迁移AWS RDS MySQL到Azure Dat
  2. AWS 认证攻略

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

mysql aws

上一篇:python中如何自动结束mysql慢查询会话

下一篇:Redis中慢查询操作的示例分析

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》