Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Nr-mysql cannot connect to MySQL Database


#1

I thought I successfully setup myrelic integration with MySQL. But when I checked Infrastructure > Third-party services I noticed it said nothing was installed.

So i then ran this
/var/db/newrelic-infra/newrelic-integrations/bin/nr-mysql status
and got this error
[FATAL] can’t continue: Error 1045: Access denied for user ‘’@‘namedsever’ (using password: NO)

The username is empty and its not localhost but when I checked the mysql-config.yml file. I’m sure I’ve set it up correctly.
integration_name: com.newrelic.mysql

instances:

  • name: mysql-server
    command: status
    arguments:
    hostname: localhost
    port: 3306
    username: newrelic
    password: XXX
    # New users should leave this property as true, to identify the
    # monitored entities as remote. Setting this property to false (the
    # default value) is deprecated and will be removed soon, disallowing
    # entities that are identified as local.
    # Please check the documentation to get more information about local
    # versus remote entities:
    # https://github.com/newrelic/infra-integrations-sdk/blob/master/docs/entity-definit
    ion.md
    remote_monitoring: true
    extended_innodb_metrics: 1
    extended_myisam_metrics: 1
    env: production
    role: write-replica

#2

Hey, I came across your post and it helped me significantly. I didn’t know how to get the status and your post helped me check it and I believe I figured out the issue. My issue turned out to be that the module was trying to authenticate from my server’s external interface IP address rather than from localhost. In the plugin setup instructions it shows that you should set up ‘newrelic@localhost’, but I believe the

remote_monitoring: true

directive winds up making it send it’s request from the server’s external interface instead of the loopback adapter (localhost or 127.0.0.1). I’m guessing that if you set up your MySQL user as ‘newrelic@namedsever’ instead of ‘newrelic@localhost’ with the same grants, that it should connect and run properly.

I’ve got my host setting up this user now on my DB server and will let you know if it works for me.


#3

I tried commenting out remote_monitoring: true
But got the same error message.

I then created a new user
CREATE USER ‘newrelic’@’%’ IDENTIFIED BY ‘Pass’;
and granted it replication privileges.

Uncommented out remote_monitoring: true
But still seeing same error message.

/var/db/newrelic-infra/newrelic-integrations/bin/nr-mysql status [FATAL] can’t continue: Error 1045: Access denied for user ‘’@‘servername’ (using password: NO)
panic: Error 1045: Access denied for user ‘’@‘servername’ (using password: NO)

goroutine 1 [running]:
github.com/newrelic/nri-mysql/vendor/github.com/newrelic/infra-integrations-sdk/log.Fatal(0x781b80, 0xc4200d0000)
/data/jenkins/infra-integrations-nri-mysql-release-linux-package-17/go/src/github.com/newrelic/nri-mysql/vendor/github.com/newrelic/infra-integrations-sdk/log/log.go:107 +0xd5
main.fatalIfErr(0x781b80, 0xc4200d0000)
/data/jenkins/infra-integrations-nri-mysql-release-linux-package-17/go/src/github.com/newrelic/nri-mysql/src/mysql.go:133 +0x44
main.main()
/data/jenkins/infra-integrations-nri-mysql-release-linux-package-17/go/src/github.com/newrelic/nri-mysql/src/mysql.go:96 +0x26d

So I suspected that it may not be reading the file from the location here:
/etc/newrelic-infra/integrations.d/mysql-config.yml
and created another copy here
/var/db/newrelic-infra/integrations.d/mysql-config.yml

I checked the file permissions
-rw-r–r-- 1 root root 854 Nov 18 11:01 mysql-config.yml
So shouldn’t be any issues there.

Restarted newrelic agent but still seeing same error message.

When I run this
/var/db/newrelic-infra/newrelic-integrations/bin/nr-mysql -hostname localhost -username newrelic -password PASS -port 3306 -remote_monitoring false
I’am able to login as newrelic and it outputs a lot of metric information.


#4

Ya, I also realized that we were seeing that error when running from the command line was failing because we weren’t passing any variables. Changing the host in the config didn’t help me either. I wound up adding the following lines to my newrelic-infra.yml to enable logging:

#
## Option : verbose
## Value : Enable (1) only if needed for troubleshooting.
## Default: 0
##
verbose: 0
#
##
## Option : log_file
## Value : Full path and file name when you want to log to a location
## different than the default (for example, with troubleshooting).
## Default: Typical default location for standard log files
##
log_file: /etc/newrelic-infra/infra.log

It wound up returning the following:

stderr="[FATAL] can’t continue: Error 1045: Access denied for user ‘newrelic’@’::1’ (using password: YES)

“::1” is the ipV6 localhost address. So it seems to be passing the ip address instead of the hostname in it’s connection request. I did verify that if I try to connect to mysql server at the host address “::1” with the credentials I have set up, I do get an access denied. I’ve just made the request to my host to add the user @’::1’ to see if that makes a difference.

My mysql server is only listening on ipV6. I did try changing the host in the configuration file to 127.0.0.1 but got a connection error. Using the external interface ip also generated the same error. Hope some of the above helps you too.


#5

Just to report back, after adding the user @’::1’ My integration started working and is now reporting in the dashboard. I had remote_monitoring set to true. I would assume that setting ‘user’@’%’ would also do the trick, so I’m not sure why yours is still failing. I will say after running nr-mysql with the ‘–help’ flag, the ‘-status’ flag does not seem to be an option, so what the command line was reporting was just a failed attempt to connect because no parameters were passed. I’d say add the logging to your newrelic agent config and see what that returns. That should give more information as to where the issue lies. Looks like you can also set verbose to 1 to get additional info. 0 was enough for my purposes.


#6

Thanks did not know about that log param, so i’ve added that and now my log files shows.
time=“2019-11-19T09:14:47Z” level=error msg=“Couldn’t load integration config file” component=PluginRegistry configFile=/etc/newrelic-infra/integrations.d/mysql-config.yml

I ran this
ls -ltr /etc/newrelic-infra/integrations.d/mysql-config.yml
-rw-r–r-- 1 root root 855 Nov 19 09:13 /etc/newrelic-infra/integrations.d/mysql-config.yml

And see that that the file does exist there, and that newrelic should be able to read it. So i’m unsure why i’m seeing that error message.

This is my mysql config file:
integration_name: com.newrelic.mysql

instances:

  • name: mysql-server
    command: status
    arguments:
    hostname: localhost
    port: 3306
    username: newrelic
    password: test
    # New users should leave this property as true, to identify the
    # monitored entities as remote. Setting this property to false (the
    # default value) is deprecated and will be removed soon, disallowing
    # entities that are identified as local.
    # Please check the documentation to get more information about local
    # versus remote entities:
    # https://github.com/newrelic/infra-integrations-sdk/blob/master/docs/entity-definition.md
    remote_monitoring: true
    labels:
    env: production
    role: write-replica
    extended_metrics: true
    extended_innodb_metrics: true

#7

Are you running on CentOS? Is it possible selinux is blocking the read on that file for the service?


#8

There is something wrong with these params
extended_metrics: true
extended_innodb_metrics: true

I tried changing “true” to “1” and restarted newrelic, but still got that error. But when I completely remove those 2 entries, it works?

But reading the documentation, I should be able to just simply add them.


#9

Hey @sh11 - I see you also have a Support ticket open for this (ticket ID: #378156) - Let us know what solution you can come to in that ticket. :smiley:


#10

So it turns out the parameters:
extended_metrics: true
extended_innodb_metrics: true

They had to be moved just above where “arguments:” was.

name: mysql-server
command: status
extended_metrics: 1
extended_innodb_metrics: 1
arguments:
hostname: localhost
port: 3306
etc . . .

After doing that and restarting newrelic, its working fine now.


#11

Ah, yes, on my config file I did not have those arguments enabled. I also noticed that the indents are a little different in my file so I didn’t catch it in the file you posted, but it looks like if they’re placed under the ‘labels:’ tag in that file it’s expecting those to be labels and ‘extended_metrics’ and ‘extended_innodb_metrics’ are arguments, not labels. So that does make sense. Glad you found your issue too.