Error Unable to connect to any of the specified MySQL hosts

0

Good morning everyone, I have this problem when I try to connect to a computer where I install XAMPP to host a database server MYSQL locally and also a database for a clock checker, through PHPMYADMIN if I can access the database, tables and records, but I need to develop an interface where the payroll manager can filter the check records, entering the database server remotely by means of the address IP of the team, then I leave the code I'm using.

MySqlConnection cadenaconexion;

        /*Abrir conexión con la BD*/
        public Conexion()
        {
            try
            {
                //conectado = false;
                cadenaconexion = new MySqlConnection ("Server=1.1.1.1;Database=relojchecador;Uid=root;Pwd=password,Port=3306");
                cadenaconexion.Open();
                //conectado = true;
                MessageBox.Show("Se realizo la conexión con exito");
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }

Thanks again for your valuable help and being able to establish the connection correctly.

    
asked by Alberto Arenas 24.05.2017 в 17:32
source

1 answer

1

The problem is probably trying to access as root from outside localhost . This for security reasons is not allowed by default. To solve it you have two options, create a new user and access with the ( recommended ) or enable external root access, for which I translate from a Stack Overflow response :

It takes 2 steps:

a) Give privileges. As root executes:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password';

b) bind to all addresses:

The easiest way is to comment on the following line in my.cnf :

#bind-address = 127.0.0.1 

and restart the mysql service

service mysql restart
    
answered by 24.05.2017 / 17:59
source