We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,344 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

error connecting to databaseAccess denied for use 'root'@'localhost(using p

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
using System.Windows.Forms;
using DPUruNet;
using System.Drawing.Imaging;
using System.Drawing;
namespace UareUBiometrics
{
    class HelperFunctions
    {
        private static Fmd[] fmds;
        private static Fmd[] allDBFmds;
        public static Fmd[] GetAllFmds
        {
            get { return allDBFmds; }
        } 
        private static string[] allUserNames;
        public static string[] GetAllUserNames
        {
            get { return allUserNames; }
        }
        private static int[] allfingerIDs;
        public static int[] GetallfingerIDs
        {
            get { return allfingerIDs; }
        }
        public static MySqlDataReader ConnectDBnExecuteSelectScript(string Script)
        {
            string connectionString = "server=localhost;User Id=root;database=customerInfo;Password=";
            MySqlDataReader dataReader = null;
            MySqlConnection conn = new MySqlConnection(connectionString);
            try
            {
                conn.Open();
                MySqlCommand sqlCommand = new MySqlCommand(Script, conn);
                dataReader = sqlCommand.ExecuteReader(CommandBehavior.CloseConnection);
            }
            catch (MySqlException ex)
            {
                MessageBox.Show("Error opening connection" + ex.Message);
            }
            return dataReader;
        }
5
Contributors
6
Replies
2 Days
Discussion Span
5 Months Ago
Last Updated
7
Views
shhh
Light Poster
36 posts since Jul 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

Are you sure the user root, without a password, has access to your database?

pritaeas
Posting Prodigy
Moderator
9,309 posts since Jul 2006
Reputation Points: 1,178
Solved Threads: 1,465
Skill Endorsements: 86

pritaeas - yes i also that ,but when i use that in vb .it comes with an error

kyle.santelices.31
Newbie Poster
3 posts since Dec 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

pritaeas - can you please help us thank you so much

kyle.santelices.31
Newbie Poster
3 posts since Dec 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

I don't use MySQL but based on this , the connection string looks wrong. It looks more like a SQL Server connection string.

TnTinMN
Practically a Master Poster
640 posts since Jun 2012
Reputation Points: 418
Solved Threads: 148
Skill Endorsements: 13

This should really be moved to the C# forum.

TnTinMN
Practically a Master Poster
640 posts since Jun 2012
Reputation Points: 418
Solved Threads: 148
Skill Endorsements: 13

Does the root account exist in your local host MySQL server?
Does the root account exist without a password?

for 1 & 2 try to login to mysql with the username as root and empty string '' as password

If you could login with the given credentials
Try giving a password to the root account granting permissions in the MySQL command prompt

I hope the GRANT statement goes like this

GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY somepassword

replace somepassword with your password

and change the connection string

string connectionString = "server=localhost;User Id=root;database=customerInfo;Password=somepassword;
samsylvestertty
Junior Poster in Training
75 posts since Oct 2010
Reputation Points: 22
Solved Threads: 4
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0740 seconds using 2.76MB