Alibaba cloud deployment 2.mysql


Alibaba cloud deployment 2.mysql



Directly use Yum to quickly build.

wget -i -c
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server

Start stop MySQL service


[[email protected] ~]# systemctl start  mysqld.service

Use PS – EF | grep Mysql to view and find that the MySQL service has been started.

[[email protected] ~]# ps -ef | grep mysql
mysql    21709     1  6 10:58 ?        00:00:00 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/
root     21738 21649  0 10:58 pts/0    00:00:00 grep --color=auto mysql

Stop it

[[email protected] ~]# systemctl stop  mysqld.service

MySQL service stopped

[[email protected] ~]# ps -ef | grep mysql
root     21747 21649  0 10:58 pts/0    00:00:00 grep --color=auto mysql
[[email protected]oZ ~]# systemctl start  mysqld.service

Reset root password and set remote login permission

Set password free login first

vim /etc/my.cnf

Add under mysqld
Restart MySQL after saving, and then you can skip the password to log in to MySQL.

systemctl stop  mysqld.service
systemctl start  mysqld.service

First refresh

mysql>flush privileges;

Create user
MySQL > create user ‘root’ @ ‘localhost’ identified by ‘your password’;
Allow root to log in remotely
mysql>grant all privileges on .To ‘root’ @ ‘%’ identified by ‘your password’;
mysql>flush privileges;
Remove the password free setting in my.cnf and log in with a password

MySQL - U root - p 'your password'

You also need to add security group rules as before, and open port 3306 on the server firewall.
After configuration, you can connect mysql on the local remote server.


I use the sequenize package on NPM, which is based on promise and supports ES6 syntax. In addition to MySQL, it can also be used to connect to Postgres, MariaDB, SQLite, and Microsoft SQL server. (…

Combined with the development documents, we can carry out the actual development.

const Sequelize = require('sequelize');
const config = require('../config');

const logger = require('log4js').getLogger('app');

class MysqlClient {
  constructor() {
    if (!MysqlClient.instance) {
      this.client = new Sequelize(config.mysql.database, config.mysql.username, config.mysql.password, {
        port: config.mysql.port,
        dialect: 'mysql',
        pool: {
          max: 5,
          min: 0,
          idle: 10000,
        timezone: '+08:00',

      const client = this.client;
      MysqlClient.instance = client;

      .then(() => {'Connection has been established successfully.');
      .catch(err => {'Unable to connect to the database:', err);

module.exports = new MysqlClient().client;

Alibaba cloud deployment 2.mysql

Recommended Today

[tutorial] restful API using JWT authentication in laravel

This article is forwarded from the professional laravel developer community, original link:… In this article, we’ll learn how to use JWT authentication to build restful APIs in larevel. JWT stands for JSON web tokens. We will also use the API to create full-featured crud applications for user products. When using cross platform applications, the […]