Page 2 of 3
Re: Remote MySQL Connection
Posted: Fri Jan 30, 2015 1:03 pm
by bdgoecke
You need to use the "root" user.
(As from the example page, under Step 5, login as the root user)
==>brian.
Re: Remote MySQL Connection
Posted: Fri Jan 30, 2015 1:34 pm
by cchilderhose
I tried to log in as Root to MySQL but get this -
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
So why is that and how do I get around it?
Re: Remote MySQL Connection
Posted: Fri Jan 30, 2015 1:44 pm
by lmiltchev
If you are setting up mysql root password for the first time, you could run:
Code: Select all
mysqladmin -u root password NEWPASSWORD
If you want to change/update your password, you could run:
Code: Select all
mysqladmin -u root -p'oldpassword' password newpass
where you substitute "newpass" with your new password.
If you don't know the old mysql root password, you can reset it by following the steps, outlined here:
http://www.cyberciti.biz/tips/recover-m ... sword.html
Hope this helps.
Re: Remote MySQL Connection
Posted: Fri Jan 30, 2015 2:16 pm
by cchilderhose
The reset article worked great and I got the root user password reset in MySQL.
Now I ran the commands for remote access in the original article and they were accepted. Now I still get the first message I posted about.
See attached.
NagiosConnectionError.png
Re: Remote MySQL Connection
Posted: Fri Jan 30, 2015 2:47 pm
by lmiltchev
I would recommend reviewing the following document:
http://assets.nagios.com/downloads/nagi ... Server.pdf
It shows how to grant permissions to mysql user, how to allow a remote access to mysql, and how to test the connection. Hope this helps.
Re: Remote MySQL Connection
Posted: Fri Jan 30, 2015 2:48 pm
by scottwilkerson
You will also need to add permissions for your new user to connect from a remote IP like
Code: Select all
mysql -u USERNAME -p'PASSWORD' -h <YOUR_IP_ADDRES>
mysql -u USERNAME -p'PASSWORD' -h <YOUR_IP_ADDRESS>
And add a firewall rule
Code: Select all
/sbin/iptables -I INPUT -i eth0 -s <YOUR_IP_ADDRESS> -p tcp --destination-port 3306 -j ACCEPT
service iptables save
Re: Remote MySQL Connection
Posted: Fri Jan 30, 2015 3:58 pm
by bdgoecke
The first set of instruction, were for a new database that would only be accessed from remote host.
Rather than update the user in the mysql.user table, you should be adding new access (rows in that table) for that remote access from an IP address.
You should change those entries in mysql.user back to 'localhost' (or your processes will be locked out when you PRIVILEGES get FLUSHed or mysql gets restarted.)
To add new access use the "GRANT" command (change the {database}, {user}, {ip}, and {password} approprately)
Code: Select all
GRANT all privileges on {database}.* to '{user}'@'{ip}'
identified by '{password}'
with grant option;
Note: the password above can be different than any other password for {user}, but it will be the password you will need to use to login from the remote system.
You will need to run that for each User/IP/Database combination you want to give remote access.
for example to give access for the nagiosql user from 10.0.0.43 with the password of "asuperstrongpasswordofyourchoicehere" use
Code: Select all
grant all privileges on nagiosql.* to 'nagiosql'@'10.0.0.43'
identified by 'asuperstrongpasswordofyourchoicehere'
with grant option;
Then for all the changes to the privileges to take effect you need to,
==>brian.
Re: Remote MySQL Connection
Posted: Fri Jan 30, 2015 8:21 pm
by Box293
This document might have some helpful information as well:
http://exchange.nagios.org/directory/Do ... es/details
Re: Remote MySQL Connection
Posted: Mon Feb 02, 2015 10:57 am
by tmcdonald
Wow, 4 answers from 4 Nagios employees!
cchilderhose, please let us know if we have resolved your issue.
Re: Remote MySQL Connection
Posted: Mon Feb 02, 2015 2:51 pm
by cchilderhose
This document helped tremendously. I followed the section required to create a user and open firewall. I can now access MySQL remotely. Thanks.