一、连接云服务器
通常情况下,我们会通过ssh连接云服务器:
ssh root@(ip地址)
二、安装环境
我们安装软件使⽤⼯具:dnf
安装Node.js
- 搜索软件包
dnf search nodejs
- 查看软件包信息:
dnf info nodejs
- 安装nodejs
dnf install nodejs
- 安装n
npm install n -g
- 通过n安装最新的lts和current
n install lts
n install latest
- 通过n切换版本
n
安装MySQL
- 查找MySQL
dnf search mysql-server
- 查看MySQL
dnf info mysql-server
- 安装MySQL,这⾥加-y的意思是依赖的内容也安装
dnf install mysql-server -y
- 开启MySQL后台服务
systemctl start mysqld
- 查看MySQL服务:active (running)表示启动成功
systemctl status mysqld
- 随着系统⼀起启动
systemctl enable mysqld
-
配置MySQL
-
mysql_secure_installation -
接下来有⼀些选项,⽐如密码强度等等⼀些
-
MySQL8开始通常设置密码强度较强,选择2
-
其他的选项可以⾃⾏选择
-
-
使⽤mysql数据库
use mysql
- 查看user表中,连接权限,默认看到root是localhost
select host, user from user;
- 修改权限
update user set host = '%' where user = 'root';
- 将权限更新操作刷新到内存中,而不用下次启动时生效
flush privileges
- 可以向mysql添加用户并且设置权限
-
只允许指定ip连接
create user '新用户名'@'localhost' identified by '密码';
-
允许所有ip连接(用通配符%表示)
create user '新用户名'@'%' identified by '密码';grant select on testdatase.* to 'user1'@'localhost'; //给user1用户添加对testdatabse数据库的查权限。
-
(但是呢,阿⾥云默认有在安全组中禁⽌掉3306端的连接的,所以我们需要配置3306的安全组)