Error trying to connect via ODBC to Mysql

Asked

Viewed 858 times

2

I’m trying to make a connection via ODBC with the Mysql Database to access data in Excel, but after performing all necessary settings the following error window is shown to me:

inserir a descrição da imagem aqui

So I set up the connector:

inserir a descrição da imagem aqui

If you have any idea what might be causing such an error, or what you would need to change in the configuration

  • In the first picture it is indicated that the user Reports does not have access. Already checked if it exists in the bank?

  • @Smael Yes, the user Reports exists in the bank

  • Have you done the GRANT ALL PRIVILEGES?

  • @But I didn’t, what would that be? How can I execute it?

  • Although the Reports user is created, it is necessary to grant you the permissions necessary for remote access. I’ll post an answer with this command.

  • @Bacco Why duplicate if my question does not involve PHP but ODBC?

  • 1

    Because ODBC is irrelevant to the question, so is PHP in the other. The problem is only of Mysql. If you try to access directly (without ODBC) you will have the same problem. Note that including, the answers are the same in both cases. You need to authorize your user in Mysql, either with the GRANT command, or with some utility like Mysql Workbech, or Mysql Database Administrator.

Show 2 more comments

1 answer

6


Access the Server as root

mysql -u root -p -h localhost

And grant the privilege to the user

GRANT ALL PRIVILEGES ON *.* TO 'reports'@'localhost' IDENTIFIED BY 'sua senha';
FLUSH PRIVILEGES;

Syntax GRANT

Best practices

Try not to grant ALL privileges in all banks, root already has this function. Specify what this user may have access to. Example:

GRANT INSERT, SELECT, UPDATE ON <seu_banco>.* TO 'reports'@'localhost' IDENTIFIED BY 'sua_senha';
  • Where can I grant such a privilege? I have at my workstation the Mysql Workbench installed to access the bank but such error also occurs when I try to access the bank from here, so where can I perform such command?

  • Are you using Windows or Linux OS? Were you able to log in as root? I put in the answer the path by command prompt. It is necessary to log in as root pq it CAN run the GRANT command.

  • I am using Windows, but even having administrator privilege when running the command at the prompt it returns to me that the GRANT command is not recognized as an internal command

  • @R.Santos Can you run a simple select? Or a command like SHOW GRANTS FOR reports?

  • I am unable to connect to the Bank, I will ask the network team to check the issue of release of access, I give you back when I have an answer

Browser other questions tagged

You are not signed in. Login or sign up in order to post.