ubuntu – the mysql data node does not connect to the node manager on AWS EC2

I'm trying to configure mySql Manager + Data Node + SQL Server (Server A) and another cluster of Data Nodes on (Server B). Both under Ubuntu 16.04 amd_64

Server A

/ etc / hosts also on server B

Both private ip
172.xx.xx.xx ip-172-xx-xx-xx-eu-west-1.compute.internal
172.xx.xx.xx ip-172-xx-xx-xx.eu-east-1.compute.internal

/config.ini

(ndbd default)
 NoOfReplicas=2  # Number of replicas

(ndb_mgmd)
hostname=ip-172-xx-xx-xx.eu-west-1.compute.internal <- Server A
datadir=/var/lib/mysql-cluster
NodeId=1

(ndbd)
hostname=ip-172-xx-xx-xx.eu-west-1.compute.internal <- Server A
NodeId=3
datadir=/usr/local/mysql/data

(ndbd)
hostname=ip-172-xx-xx-xx.eu-east-1.compute.internal <- Server B
NodeId=2
datadir=/usr/local/mysql/data

(mysqld)
hostname=ip-172-xx-xx-xx.eu-west-1.compute.internal <- Server A
/etc/my.cnf

(mysqld)
ndbcluster

(mysq_cluster)
ndb-connectstring = ip-172-xx-xx-xx.eu-west-1.compute.internal <- Server A

Server B

/etc/my.cnf

(mysqld)
ndbcluster

(mysql_cluster)
ndb-connectstring=172.xx.xx.xx <- Server A private ip

Server A error

running ndbd gives me this error

(ndbd) INFO     -- Angel connected to '172.xx.xx.xx:1186'
(ndbd) ERROR    -- Failed to allocate nodeid, error: 'Error: Could not alloc node id at 172.xx.xx.xx port 1186: Connection done from wrong host ip 172.xx.xx.xx.'

Server B error

running ndbd gives me this error

Unable to connect with connect string: nodeid=0,172.xx.xx.xx:1186
Retrying every 5 seconds. Attempts left: 12

ndb_mgm

-- NDB Cluster -- Management Client --
ndb_mgm> show
Connected to Management Server at: 172.xx.xx.xx:1186 <- A
Cluster Configuration
---------------------
(ndbd(NDB)) 1 node(s)
id=2 (not connected, accepting connect from 172.xx.xx.xx) <- B

(ndb_mgmd(MGM)) 1 node(s)
id=1    @172.x.x.x  (mysql-5.7.22 ndb-7.6.6)

(mysqld(API))   1 node(s)
id=3 (not connected, accepting connect from 172.xx.xx.xx) <- A

I do not know how I would connect to mysqld (API) for it to work properly after installing the server / client cluster.

In addition, I entered both instances A and B to accept all traffic between all port ranges 1000-60000, just in case I miss something, and the outbound traffic is open to everything.

I wonder what I miss, I am so tired today trying to find out what is happening with the installation.

Any help would be appreciated!

mysql – Send an email with password using PHP Mailer

I wish to send an email to the user who consults his password in case he would forget it only by entering it.

How could I check the password field corresponding to the email entered ???

PD: I do not have the PHP code yet, but I plan to send the data by e-mail in the mail.

Mysql recordings:

 |  id   |    usuario    |      correo      |   password   |

     1        lopez67       lopez@gmail.com     qwerty123
     2        xim477        xim@gmail.com         12348

HTML code:

    
Correo Electrónico:
Ingresa tu email de registro al sistema y recibirás un correo electrónico con tu contraseña nueva.

PHPMAILER code:

 isSMTP();
 $mail->CharSet = 'UTF-8';
 $mail->SMTPDebug = 0;
 $mail->Host = 'smtp.office365.com';
 $mail->Port = 587;
 $mail->SMTPSecure = 'tls';
 $mail->SMTPAuth = true;

 $mail->Username = "my@mail.com";
 $mail->Password = "Mypsw";
 $mail->setFrom('my@mail.com', 'My Page');
 $mail->Body = 'Tu Contraseña es: '.$contraseña."nn"

 if (!$mail->send()) {
echo "Error en Mensaje: " . $mail->ErrorInfo;
 } else {
echo "Mensaje Enviado";
 };
?>

mysql – Get a connection error on a MySQL 5.1 one-way replication to MySQL8.0

Try to replicate MySQL5.1 in MySQL8.0, when starting the slave on MySQL8.0, I get

[ERROR] [MY-010584] [Repl] Slave I/O for channel '': error connecting to 
master 'rep_user@XXXXXXXX.YYY:3306' 
- retry-time: 60  retries: 7, Error_code: MY-001043

The startup of the slave from version 5.7 with the 5.1 master succeeds however. In fact, 2 weeks of binlog queries synchronized smoothly. By setting another replication from 5.7 to 8.0, I can reach my goal.

I know that he is ambitious to replicate directly from 5.1 to 8.0, but I like to know what is causing the error.

SSL is not enabled on any of the servers.

Data Sync, mysql and promise

I'm new to nodejs and I'm trying to understand why I can not get the expected result from my API.

I have an application that sends an API node an array containing data to be saved in bd.
When I receive this data, I have to verify that each one is saved in my database. db.buscaPorId() . If each record is not saved, a function db.salva() record each of these new records in the bank.
At the end of this process, I would like to return all data (new and old) to my application.

The problem is getting all the records after foreach because it does not return the last saved data. Only those who were previously saved …

What I have tried is in the code below.

What would be the best way to solve this problem? I study the promises but I still do not understand how to put it into practice in my code.
Note: the code is probably full of flaws, so if someone can give me a hint to improve it, that would be cool 🙂

Road function

sincroniza(app) {
    return function (req, res) {
        const dadosApp = req.body;

        const conexao = app.persistencia.ConexaoDb();
        const db = new app.persistencia.PontoDao(conexao);

        if(dadosApp !== ""){
            console.log('recebendo dados');
            dadosApp.forEach(dado =>{
                db.buscaPorId(dado.uuid,(erro,resultado)=>{
                    if(resultado == '' || resultado == undefined || resultado.length == 0){
                        dado.sync = 1;
                        db.salva(dado,(erro,res)=>{
                            if(erro){
                                res.send('falha ao salvar os dados')
                            }
                        })
                    }
                })
            })
        }

        //não retorna os últimos dados salvos
        db.lista((erro,result)=>{                
            res.json(result);
        })

}

bd functions

function PontoDao(conn){
    this._conn = conn;

}

PontoDao.prototype.salva = function(ponto,callback){
    this._conn.query('INSERT INTO ponto SET ?', ponto, callback);
}

PontoDao.prototype.atualiza = function(ponto,callback) {
    this._conn.query('UPDATE ponto SET sync = ? where id = ?', (ponto.sync, ponto.id), callback);
}

PontoDao.prototype.lista = function(callback) {
    this._conn.query('SELECT * from ponto',callback);
}

PontoDao.prototype.buscaPorId = function (id,callback) {
    this._conn.query("select * from ponto where uuid = ?",(id),callback);
}

module.exports = function(){
    return PontoDao;
};

catch a duplication error in mysql with java

I'm trying to show a message that there is already a registered identifier, but it falls into the catch that shows:

 com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '1' for key 'idusuario' 

I want to show that there is already a registered identifier.

 try {
        conexao=ConexaoBanco.conector();
        pst=conexao.prepareStatement(sql);
        pst.setString(1,nomeusuario);
        pst.setString(2,senha);  
        try{            
            pst.setInt(3,Integer.parseInt(idusuario));
        }catch(SQLException x){
            JOptionPane.showMessageDialog(null,"ID JÁ CADASTRADA");
        }
        pst.setString(4,perfil);     
        pst.setString(5,nome);          
        pst.executeUpdate();
        return true;
    } catch (SQLException e) {
        JOptionPane.showMessageDialog(null,e);
        return false;   
    }

mysql – Query Performance Comparison: Join Vs Select Distinct From Table

I have two tables the person and city. the person table and city_id the tables are connected using city_id in person. the person the table contains around one million rows and city table have about 10000 lines.

index person: index1-: id, index2-: city_id
index city:   index1-: id

I have to select all the cities to which no person line is associated.
The city and person tables are as follows (demo data).

CITY                PERSON

id  city            id  name   city_id
-------------       ------------------
1    city-1         1   name-1   1
2    city-2         2   name-2   2
3    city-3         3   name-3   2
4    city-4         4   name-4   3
5    city-5         5   name-5   1
6    city-6         6   name-6   3
7    city-7         7   name-7   4
8    city-8         8   name-8   8

I wrote two queries to get the result:

query1: select c.id, c.city from city c left join person p on c.id = p.city_id  where p.id is null
query2: select * from city where id not in ( select distinct city_id from person)

The execution plan of the two queries is similar:

For the query 1:
mysq
for query 2:
enter the description of the image here

Then I used profiling and I ran both queries a few times to see how long they took:

query1: 0.000729 0.000737 0.000763
query2: 0.000857 0.000840 0.000852

Clearly from the above data, query1 overrides query2.

I am confused as I understand query2 should outperform query1. Because the query's nested query uses city_id which is indexed and mysql can take advantage of city_id index to get all the identifiers but query1 uses join, which will take the Cartesian product of both tables.
Is it because I used less data f. person (1000) and city (200) records.

What is missing because of the query that performs1 better than query2.

mysql – Select the count date from among several conditions for each day

I have a lot of coupons. I would like to know every day how many coupons each campaign has been received by users. But I can not write something as assigned_date for each selection line

SELECT count(id)                                                  as number_of_coupons,
       DATE_FORMAT(assigned_date, '%d-%m-%Y')                     as date,
       (SELECT COUNT(id) FROM coupon WHERE campaign_id = 1 AND assigned_date=THIS MUST BE SOMETHING) as campaign_1,
       (SELECT COUNT(id) FROM coupon WHERE campaign_id = 2 AND assigned_date=THIS MUST BE SOMETHING) as campaign_2
FROM coupon
GROUP BY DATE_FORMAT(assigned_date, '%d-%m-%Y')
order by STR_TO_DATE(date, '%d-%m-%Y') DESC

So, the result will be something like. How can I achieve this result?

+-------------------+------------+-------------+-----------+
| number of coupons |    date    |  campaign_1 | campaign2 |
+-------------------+------------+-------------+-----------+
|               156 | 12-10-2019 |        6980 |       100 |
|               177 | 11-10-2019 |        6980 |       100 |
|                44 | 10-10-2019 |        6980 |       100 |
|                94 | 09-10-2019 |        6980 |       100 |
|                93 | 08-10-2019 |        6980 |       100 |
+-------------------+------------+-------------+-----------+

database – WAMP WORDPRESS connects to MySQL but will not connect to MariaDB

WordPress on WAMP can not establish a connection to MariaDB only connects to MySQL Continue to receive: Can not select the database How to configure WordPress to connect to MariaDB?

I asked the same question in SO; https://stackoverflow.com/questions/58351486/wamp-wordpress-connects-to-mysql-but-will-not-connect-to-mariadb but DO NOT KNOW which platform is best when the Worpress and touch issue other questions.

In case you think this question should NOT be asked here, PLEASE DO NOT DOWNVOTEER, write in the comment and I will delete it.

Thank you

mysql – What is the best solution for storing data and generating graphics?

I'm working on a project that will look like a discussion forum. However, in addition to creating the subject, the user must answer a 40-question quiz. These questions will be stored and subsequently displayed in graphs with the statistical results of all the users who answered the questionnaire.

My question is: Would mysql be a good choice for this project?

Over time, as the number of responses increases, would calculating and displaying graphs become too slow?

What is the best way for me not to have speed problems in the future?

MySQL bulk INSERT .. ON DUPLICATE KEY UPDATE when specifying individual columns

I need to insert thousands of rows in mass if a table of 2 different cronjobs tasks with different datasets, I'm currently using INSERT .. ON DUPLICATE KEY UPDATE

Whereas the first value is the unique key to check duplicates,

For example, the first cron job would be executed (from data source 1):

INSERT INTO `places` () VALUES
 ('aaa', 'bbb', NULL),
 ('ccc', NULL, 'ddd')
ON DUPLICATE KEY UPDATE;

The second cron job would be launched for example (from data source 2):

INSERT INTO `places` () VALUES
 ('aaa', NULL, 'eee'),
 ('ccc', 'ddd', 'fff')
ON DUPLICATE KEY UPDATE

As you can see, the second cronjob overwrites the valid values ​​of the first cronjob with null values ​​that I do not want.
If I withdraw the null the values ​​of the data, the query would break because there would be a data incompatibility.

The only solution I can think of is to run a lot of insert / single updates, which would be slower.

If I could do a lot

INSERT INTO `places` VALUES
 (column1='aaa', column3='eee'),
 (column1='ccc', column2='ddd', column3='fff')
ON DUPLICATE KEY UPDATE

I would not have to worry about the keys, but I do not think it's possible in MySQL. Does anyone know a better way to do it?