aws linux 2 安装mysql+node.js+nginx

1.安装mysql

1.在 Amazon Linux 2 上安装mysql8

sudo curl -L https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm -o /tmp/mysql80-community-release-el7-3.noarch.rpm
sudo rpm -ivh /tmp/mysql80-community-release-el7-3.noarch.rpm
sudo rpm --import https://mysql.com/downloads/MySQL-Release-8.asc
sudo yum install mysql-server

2.如果错误,这个错误表示导入的 GPG key 不受信任,您需要使用 --force 选项来强制安装软件包:

sudo yum install mysql-server --nogpgcheck

3.是否安装成功

mysql -V

4.启动 MySQL 服务并设置为在系统启动时自动运行:

sudo systemctl start mysqld
sudo systemctl enable mysqld

5.生成一个初始密码,该密码在安装 MySQL 时自动生成。为了获取临时密码,运行以下命令:

 sudo grep 'temporary password' /var/log/mysqld.log

[root@ip-172-31-31-129 ec2-user]# sudo grep 'temporary password' /var/log/mysqld.log
2023-05-21T05:46:43.221560Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 1i7Y%QUVeg,C

我的密码

1i7Y%QUVeg,C

6.提示输入密码时使用找到的临时密码,修改密码

sudo mysql_secure_installation

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.

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.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.

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.


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.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done!
[root@ip-172-31-31-129 ec2-user]#

7.登录mysql

mysql -uroot -p

[root@ip-172-31-31-129 ec2-user]# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@ip-172-31-31-129 ec2-user]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.33 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

8.设置mysql可以远程登录

 use mysql;

9. 授权 root 用户设置远程访问:

update user set host='%' where user ='root';

10.然后使用下面命令使修改生效:

flush privileges;

2.安装nginx

  1. 安装Nginx。在连接到实例后,执行以下命令以安装Nginx:

sudo su

sudo yum update -y
sudo amazon-linux-extras install nginx1 -y

2.启动Nginx服务。安装完成后,执行以下命令启动Nginx服务

sudo systemctl start nginx

3.配置Nginx自启动。执行以下命令使Nginx在系统启动时自动启动

sudo systemctl enable nginx

3.        安装node.js

  1. 安装Node.js。在连接到实例后,执行以下命令以安装Node.js:
curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash -
sudo yum install -y nodejs

2.验证安装。安装完成后,执行以下命令验证Node.js是否成功安装:

node -v
npm -v

【aws linux 2 安装mysql+node.js+nginx教程】 https://www.bilibili.com/video/BV1pT41147id/?share_source=copy_web&vd_source=d8becf47c23a9f587399241170e015e6

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

暗逆骇客

你的打赏是我的最大助力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值