End of my tether, hours of variations...
I am trying to access installed MySQL running on an EC2 instances. Lots of searching (this seemed closest to my issues Connect to mysql on Amazon EC2 from a remote server), and I'm obviously missing something silly or mis-understanding.
EC2 Ubuntu, mysqld running fine, local web/app server working fine all connecting. I can mysql from local. I need external access to this dev machine as using iron.io which needs to reach the database from external.
I have
- ec2 security gruops all configured allowing 0.0.0.0
- I can ssh/http reach the server no problem
- configured mysqld
- bind address=0.0.0.0 (have tried variations below)
- granted access for my non-root user (myuser) from % e.g. GRANT ALL ON . to myuser@'%' IDENTIFIED BY 'password'; FLUSH PRIVILEGES;
- ensured my ubuntu instance iptables are not configured e.g. i'm only using ec2 security group to protect the instance)
I have tried
- ssh into the server
- telnet to the public ip on the mysqld port 3306 to make sure its listening - see notes below
- remove bind address in /etc/mysql/my.cnf
- checking it is not a sock v port error: always connecting via port (locally checked e.g. mysql -h - localhost -u root -p --port=3306)
- bind address 0.0.0.0
- bind address EC2 local ip e.g. 172.
- bind address EC2 external ip e.g. 51.x
- mysql user grant privileges on %
- mysql user grant privileges on my personal external ip
- create another user, and only grant priviledgs to a specific database GRANT ALL PRIVILEGES ON mydb.* TO 'myuser2'@'%' IDENTIFIED BY 'password';
- repeated for %, my personal external ip
- adding root@'%' to the list and tried that user (based on this suggestion: Can't Connect to MySQL instance Remotely that is running on EC2 Instance (Not RDS))
(Always restarting server after)
Nothing works, the test always
$ mysql --host=54.x.x.x --port=3306 --user=myuser -p Enter password: ERROR 1045 (28000): Access denied for user 'myuser'@'54.x.x.x' (using password: YES)
I have noticed however that
- SELECT * from information_schema.user_privileges; has myser with IS_GRANTABLE set to N: but I don't think this is a limiting factor (Why is GRANT not working in MySQL?)
netstat -a shows a different port & a socket listening!?
The listening port in the netstat below is not 3306 BUT i've telneted externally to that port and it shows mysql IS listening
Can anyone suggest any step I've missed?
Extracts of db priviledges, my.cnf below
# user_privileges
# e.g. SELECT * from information_schema.user_privileges;
+--------------------------------+---------------+-------------------------+--------------+
| GRANTEE | TABLE_CATALOG | PRIVILEGE_TYPE | q1 |
+--------------------------------+---------------+-------------------------+--------------+
| 'root'@'localhost' | def | SELECT | YES |
...
| 'myuser'@'%' | def | SELECT | NO |
| 'myuser'@'%' | def | INSERT | NO |
| 'myuser'@'%' | def | UPDATE | NO |
#
]$ netstat -a | grep 'mysql'
tcp 0 0 *:mysql *:* LISTEN
unix 2 [ ACC ] STREAM LISTENING 61212 /var/run/mysqld/mysqld.sock
$ telnet 54.x.x.x 3306
Trying 54.x.x.x...
Connected to ec2-54-x-x-x.us-west-2.compute.amazonaws.com.
Escape character is '^]'.
[
5.5.44-0ubuntu0.14.04.1+c<>d^+W?1*!e\{wdp&hZmysql_native_password
# my.cnf
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
#skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address = localhost
# donts seem to work
bind-address = 0.0.0.0
# does not work
# ec2 external ip
#bind-address = 54.x.x.x
# ec2 internal ip
#bind-address = 172.x.x.x