Article directory
1. After purchasing the Alibaba Cloud host, log in to the Alibaba Cloud management console, and reset the instance password and remote login password in the cloud server ECS instance.
2. Open the network and security group in the cloud server ECS instance, and set port opening rules.
3. iTerm remote login ssh command: $ ssh [email protected]
press Enter, enter the password to log in.
4. Install node.js
yum install -y nodejs
npm replace Taobao source
# 查看源
npm get registry
# 设置淘宝源
npm config set registry http://registry.npm.taobao.org/
yarn config set registry http://registry.npm.taobao.org/
# 还原
npm config set registry https://registry.npmjs.org/
installation tool
npm i yarn -g
yarn
yarn global add nodemon
yarn global add pm2
Use of pm2
https://blog.csdn.net/qq_36850813/article/details/98967807
pm2 start app.js --name web-match
pm2 list
pm2 stop all
pm2 start 0 # pm2 start [id]
pm2 logs 0 # 显示日志
pm2 delete 0 # pm2 delete [id] 删除应用
install mysql
1. Check whether centos7 has installed mysql, and uninstall it.
$ yum list installed mysql*
2. Go to the official website to find the yum source and install it
https://dev.mysql.com/downloads/
$ wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
$ sudo yum install mysql80-community-release-el7-3.noarch.rpm
3. Check whether the installation is successful
$ sudo yum repolist all|grep mysql
Reference: https://blog.csdn.net/yanchao963852741/article/details/105297519/
yum -y install mysql-community-server
报错
未找到匹配的参数: mysql-community-server
错误:没有任何匹配
4. Disable the default mysql module before installing mysql
sudo yum module disable mysql
5. Execute the installation
yum install mysql-community-server
6. Restart the mysql service after the installation is successful
sudo service mysqld restart // 重启mysql服务
sudo service mysqld status // 查看mysql状态
sudo systemctl enable mysqld // 配置开机启动
log in to mysql
Reference: https://www.jb51.net/article/168465.htm
1. Try to log in to mysql without a password
mysql -u root
2. There is a password after installation. Root generates a default password in the /var/log/mysqld.log file, find out the password
grep 'temporary password' /var/log/mysqld.log
jF8rUfIe9p=t
3. Enter the default password to log in to mysql and change the password
mysql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED BY '此处填入你的密码';
4. Add remote users
# 语法
$ create user 'username'@'%' identified by 'password';
# 真实
$ create user 'web'@'%' identified by '此处填入你的密码';
# 给用户赋予权限
$ GRANT ALL PRIVILEGES ON *.* TO 'web'@'%';
Reference: https://blog.csdn.net/anthony1314/article/details/100612544
grant all privileges on . to report error
5. After creating a new user, 1130, "Host 'xxxx' is not allowed to connect to this MySQL server" error occurs when connecting with navicat
https://blog.csdn.net/zd147896325/article/details/82427107
# 切换数据库看用户表
use mysql;
select host,user,plugin from user;
# 刷新权限
flush privileges;
Reconnect after refreshing the permissions, and the connection will be successful
Insufficient permission to create database
1044 - Access denied for user ‘web’@‘%’ to database ‘test’
Reference https://www.cnblogs.com/ahu-lichang/p/6702921.html
Node uses mysql to report an error.
// MYSQL: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol
// Reason: The client that logs in to the database is not compatible with mysql8.0, and mysql8.0 password authentication adopts a new password format
// Solution: Enter in the mysql terminal of the system The following command:
// password is your database account password, root and localhost are also
// ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'
Execute the above statement and report an error
ERROR 1396 (HY000): Operation ALTER USER failed for ‘web’@‘localhost’
http://www.geekjc.com/post/5cbe76ce066d3d3ce5c12fd0
use mysql;
select user,host,plugin from user;
# 注意我的 web,host是'%'
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123';
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123';
View mysql listening port method
netstat -ntlp|grep mysql
node.js http-server build local server
yarn global add http-server
hs <path> -a 127.0.0.1 -p 8090
# 如:当前目录启动
hs ./ -a 127.0.0.1 -p 8090
git save password
git config --global credential.helper store
# 输入一次密码以后会记住密码
The port is occupied, and multiple nodes are started
# 查看node进程
ps -ef|grep node
# 关闭进程 8987
sudo kill 8987
Note: In linux, because the system defaults to non-root users, 1024 and ports smaller than it cannot be used, and sudo permissions are required
Start a local debug production configuration
export NODE_ENV='production'&& node app.js # 注意&&前不能有空格
sudo pm2 command does not exist
sudo ln -s /usr/local/bin/pm2 /usr/bin/pm2
turn off firewall
firewall-cmd --query-port=80/tcp --zone=public #查询80端口是否开启,自行修改端口号
firewall-cmd --zone=public --add-port=80/tcp --permanent #添加80端口,如需添加其他端口,自行修改端口号
修改完成后需要重启服务器才能生效
systemctl status firewalld # 查看防火墙状态
systemctl stop firewalld
reference site
https://www.cnblogs.com/starof/p/4680083.html
https://www.jianshu.com/p/a04bd6348fa3
https://www.jb51.net/article/168465.htm