# ELK MetricBeat - Monitor remote mysqlDB

**URL:** <https://discuss.elastic.co/t/elk-metricbeat-monitor-remote-mysqldb/282717>\
**Category:** Beats\
**Tags:** beats-module, metricbeat\
**Created:** [August 28, 2021, 4:48am UTC](https://discuss.elastic.co/t/elk-metricbeat-monitor-remote-mysqldb/282717 "2021-08-28T04:48:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashwin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ashwin/32/93833_2.png) [@ashwin](https://discuss.elastic.co/u/ashwin)\
**Post date:** [August 28, 2021, 4:48am UTC](https://discuss.elastic.co/t/elk-metricbeat-monitor-remote-mysqldb/282717/1 "2021-08-28T04:48:12Z")

</div>

I have installed ELK stack (With metricbeat) on ServerA and want to monitor mysql on ServerB. I added db host details on ServerA mysql.yml metribeat module file (/etc/metricbeat/modules.d/mysql.yml)

```auto
    - module: mysql
  metricsets:
    - status
    - performance
  period: 10s

  hosts: ["tcp(ServerB:3306)/"]

  username: mysql

  password:password

```

After I start the metricbeat instead of connecting to ServerB it tries to connect to localhost(ServerA) mysql.

below is the error

> Error fetching data for metricset mysql.status: Error 1045: Access denied for user 'mysql'@'ServerA...sing password: YES)

Can someone help me with this?

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [August 28, 2021, 5:54pm UTC](https://discuss.elastic.co/t/elk-metricbeat-monitor-remote-mysqldb/282717/2 "2021-08-28T17:54:26Z")

</div>

This is not a issue with metricbeat, it is correctly trying to connect to ServerB, the error you are seeing is the response from MySQL saying that he user `mysql` was denied, you will probably need to check your grants.

This is a MySQL issue, so you will need to grant access for the mysql user to connect from the serverA. I'ts been a long time since I've used MySQL, but if I remember correctly you will need something like this:

```auto
GRANT ALL PRIVILEGES ON *.* TO 'mysql'@'serverA' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;

```

---

<div class="post-metadata">

**Author:** ![ashwin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ashwin/32/93833_2.png) [@ashwin](https://discuss.elastic.co/u/ashwin)\
**Post date:** [August 28, 2021, 6:40pm UTC](https://discuss.elastic.co/t/elk-metricbeat-monitor-remote-mysqldb/282717/3 "2021-08-28T18:40:12Z")

</div>

Hi Leo,  
Thanks for looking into this?  
User has full access to mysql. If you look at the error its connecting to ServerA (Access denied for user 'mysql'@'ServerA) it should be mysql@ServerB?

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [August 28, 2021, 10:23pm UTC](https://discuss.elastic.co/t/elk-metricbeat-monitor-remote-mysqldb/282717/4 "2021-08-28T22:23:35Z")

</div>

No, as I said, the problem is in the permission for the user `mysql`, it is not in metricbeat.

The message `Access denied for user 'mysql'@'ServerA' usingsing password: YES` is sent by your MySQL server.

It says that the user `mysql` does not have grants to access the database when connecting **from** ServerA. The first part is the username and the second part is the name of the host from where the connection is comming, in your case it is ServerA, where your metricbeat is running.

When you create a user in mysql you need to specify the hosts from where this user will be allowed to connect to the server. The user can have full access when connecting to mysql from ServerB, but could be denied from any other host.

You need to grant access from other hosts. Take a look at the [mysql documentation](https://dev.mysql.com/doc/refman/8.0/en/create-user.html#create-user-overview) about creating users, the host name is parte of the identification of the user.

---

<div class="post-metadata">

**Author:** ![ashwin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ashwin/32/93833_2.png) [@ashwin](https://discuss.elastic.co/u/ashwin)\
**Post date:** [August 30, 2021, 2:05pm UTC](https://discuss.elastic.co/t/elk-metricbeat-monitor-remote-mysqldb/282717/5 "2021-08-30T14:05:24Z")

</div>

Hi Leo,  
Thank you for the detail explanation.  
It was a access issue and now I'm able to connect.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 27, 2021, 4:05pm UTC](https://discuss.elastic.co/t/elk-metricbeat-monitor-remote-mysqldb/282717/6 "2021-09-27T16:05:59Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
