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 - GPLCopyright (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
- 安装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
- 安装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