Click here to Skip to main content
15,905,148 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey, I have made a project. It is based on MySQL. This project is working fine when i run it on my Laptop But, when i put this on a another laptop It gives me a error [Authentication to host 'localhost' for user 'root' using method
'mysql_native_password' failed with message:Access denied for user 'root'@'localhost'(using password:YES)]. This Is my codes for the following button
Imports MySQL.Data.MySqlClient
Public Class Form1
    Dim MysqlConn As MySqlConnection
    Dim COMMAND As MySqlCommand
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        MysqlConn = New MySqlConnection
        MysqlConn.ConnectionString = "server=localhost;userid=root;password=MB9RS-PJZB6;database=database"
            MessageBox.Show("connection successful")
        Catch ex As MySqlException
        End Try
    End Sub

I cant access the database from the other laptop But I can access it from my laptop. Please help me out in this. Thanks in advance.

1 solution

localhost refers to same PC which your application running, if your database server is located in some other PC or server, you need to change localhost to ip address or the server name of the database server
Share this answer
JoshuaDsouza19 26-Oct-14 3:42am    
So what should i change can you guide me from the above code which i have posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900