Ali Cloud

1. Buy Aliyun first. I bought a student computer and selected Ubuntu, 16.04 64-bit.

Set the port of your interface (usually available in app.js, set your own listen), and other ports to use. For example websocket

Configuring the Node environment is not detailed here, seeWebsite exampleStep two will do

If the node and NPM versions are displayed, the installation is successful.

Run ‘sudo apt-get update’ to update apt-get before configuring the Node environment. This is also the first command

Install the pm2

npm install pm2 -g

Pm2 is used as a daemon to keep Our Node app.js running without breaking when we exit the server.

If the pm2 -v command output indicates that the installation is successful.

Mysql installation


sudo apt-get install mysql-server
 
sudo apt install mysql-client
 
sudo apt install libmysqlclient-dev
Copy the code

Upload a project, that’s what we’re using hereWinscp tools

1. Open the tool and log in.

Configuring the Database

1. Log in to the database on the terminal

mysql -u root -p

Password: user name and password. The default value is root

2. Create a database

Create database Specifies the database name. (To use a semicolon, use the same database name as your project)

3. Use the database

Use database name;

4. Import SQL files

source /home/sportdiet.sql; (Where to save your SQL files)

5. View tables in the database

show tables;

If you can see the database table, the import is successful

6, exit database operation exit;

7. Modify the project database configuration file

In your project, modify the database configuration file and click the corresponding file in winscp to open it

Test and mount

Switch to the CD /home/sportdietAPI where app.js is located. You can first node app.js to see if there is any error output, and enter the path to obtain the requested data in the browser address bar to see if there is any data output

Pm2 start app.js –watch

Possible bugs

Solution:

ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘password’ PASSWORD EXPIRE NEVER; # Modify encryption rules

ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘password’; Update the user’s password

FLUSH PRIVILEGES; # refresh permission