I'm trying to allow external access to MySQL server. First I changed my.cnf to this (part of my.cnf):
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[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 = 0.0.0.0
In /etc/hosts.allow I added:
mysqld: all
Also I added user 'root'#'%', but what I have is that:
I'm trying to connect from server to server using external host name:
root#******:~# mysql -h******.com -u root -p
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0
But using 'localhost' all is fine:
root#******:~# mysql -hlocalhost -u root -p
MySQL Server version: 5.5.43
Ubuntu 14.10 (GNU/Linux 3.16.0-23-generic x86_64)
You should run the commands after creating user-
GRANT ALL ON dbname.* TO 'root'#'%' IDENTIFIED BY 'root';
FLUSH HOSTS;
FLUSH PRIVILEGES;
if you have already run this code then there could be fire wall problem-
Related
I have installed and setup phpMyAdmin in app engine, with MySQL installed in compute engine. I am receiving this error mysqli_real_connect(): (HY000/2002): No such file or directory when logging into phpMyAdmin. I have set up vpc access connector in app.yaml, and opened port 3306 in the compute engine.
config.inc.php in phpMyAdmin:
$cfg['Servers'][$i]['host'] = '10.126.0.9:3306';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
in compute engine with MySQL installed
with config /etc/mysql/mysql.conf.d/mysqld.conf
[mysqld]
#
# * Basic Settings
#
user = mysql
# pid-file = /var/run/mysqld/mysqld.pid
# socket = /var/run/mysqld/mysqld.sock
# port = 3306
# datadir = /var/lib/mysql
# If MySQL is running as a replication slave, this should be
# changed. Ref https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_tmpdir
# tmpdir = /tmp
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 10.126.0.9
#mysqlx-bind-address = 0.0.0.0
On top of that, I have created user to login from phpMyAdmin
CREATE USER 'myadminLogin'#'*' IDENTIFIED BY 'password';
MySQL and OS variant
mysql -V
mysql Ver 8.0.30-0ubuntu0.20.04.2 for Linux on x86_64 ((Ubuntu))
sudo netstat -tulpn | grep LISTEN | grep mysql
tcp 0 0 10.126.0.9:3306 0.0.0.0:* LISTEN 32879/mysqld
tcp6 0 0 :::33060 :::* LISTEN 32879/mysqld
Port opened: 3306:
Network analysis:
Update
After the above changes, I no longer see the login panel but currently being directed straight to the page below. What is the issue?
The first thing that stands out is that there's a slight mistake in your config.inc.php; the line $cfg['Servers'][$i]['host'] = '10.126.0.9:3306'; should not include the port. There's a separate directive $cfg['Servers'][$i]['port'] if you need to override the default, which is 3306 so you won't even need that. Change your host line to $cfg['Servers'][$i]['host'] = '10.126.0.9'; and see if that changes anything.
I'm using AWS server (ubuntu) for backup my remote mysql db, using mysqldump command.
Since I changed the db password, I cannot connect anymore remotely from the machine using /etc/mysql/my.cnf configuration file.
When I'm using the command
mysql -u root -h 1.1.1.1 -p 123456
It's connects successfully, but when I'm trying to connect by using the mysql configuration file /my.cnf by typing just
mysql
I gets the error message :
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I restarted the db server (I don't need mysql service running on aws because I connected remotely)
I don't want to connect through any socket
my.cnf file content:
[client]
port = 3306
host = 1.1.1.1
user = root
password = 123456
[mysqld]
user = mysql
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
bind-address = 1.1.1.1
I don't know what have changed, except from the password, I didn't change anything neither in the db itself and in the config file, so I have no idea why it stopped working.
Add in the my.cnf the line protocol=tcp
[client]
port = 3306
host = 1.1.1.1
user = root
password = 12345
protocol = tcp
That force MySQL to use TCP and not the socket connection
I have two Instances: A and B
I am trying to connect Instance A to Instance B's mysql db.
On both instances I have added 3600 to the security group
I have edited Instance B's /etc/mysql/my.cnf and added 0.0.0.0 as the bind-address and restarted mysql
[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 = 127.0.0.1
bind-address = 0.0.0.0
#
# * Fine Tuning
#
key_buffer = 16M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 8
But when I'm on Instance A terminal and try telnet [Instance B public ip] 3306 I get
EHost '[Instance A public ip]' is not allowed to connect to this MySQL
serverConnection closed by foreign host.
Did I miss a step or did something wrong or something?
Do you have a user on Instance B Mysql with all the priveleges?
This is a normal behavior when you try to use telnet to connect to mysql.
Try something like this from Instance A
mysql -h [Instance B IP] -u [user_name] -p
You are supposed to grant the permission to IP to avoid seeing this error
mysql -u root -p
Enter password
: <enter password>
>GRANT ALL ON *.* to root#'xx.xx.xx.xx' IDENTIFIED BY 'root';
>FLUSH PRIVILEGES;
I am trying to grant remote access to a mysql database. However I think I am missing a step somewhere.
Server is a VM - Ubuntu 12.04.5 - inet addr:134.226.38.147
mysql Ver 14.14 Distrib 5.5.38, for debian-linux-gnu (x86_64) using readline 6.2
Firstly I create the database on the remote server. I then grant wildcard access to all databases and tables for the user brendan. By using '%' I should have no problem connecting from my computer in college.
mysql> CREATE DATABASE foo;
mysql> GRANT ALL ON *.* TO 'brendan'#'%' IDENTIFIED BY 'mypassword';
I then open the port using
iptables -A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT
iptables-save | tee /etc/sysconfig/iptables
From what I read the above should work, however when I try to test the connection from my desktop this is what I get
localhost:~ brendan$ mysql -u brendan -h 134.226.38.147 -p
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on '134.226.38.147' (61)
localhost:~ brendan$
or
localhost:~ brendan$ echo X | telnet -e X 134.226.38.147 3306
Telnet escape character is 'X'.
Trying 134.226.38.147...
telnet: connect to address 134.226.38.147: Connection refused
telnet: Unable to connect to remote host
localhost:~ brendan$
What am I missing?
Any help is much appreciated.
EDIT
my.cnf
I was unsure If I should comment out the bind-address = 127.0.0.1 which was already there
[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 = 127.0.0.1
# ---- You added the below line ----------
bind-address = 134.226.38.147
I then restart with
sudo service mysql restart
Open your my.cnf file:
sudo vim /etc/mysql/my.cnf
Comment out the bind-address in your my.cnf.
like so: #bind-address = 127.0.0.1
Then restart mysql server so that the changes to the my.cnf file will take affect.
sudo service mysql restart
or
sudo /etc/init.d/mysql restart
You can read more here at DigitalOcean or rtcamp.
Now, a user will be able to connect to the Mysql database server remotely as long as they have proper user credentials.
I'm having an issue connecting remotely to my MySQL server. I know my user is setup with the '%' wildcard from any host, so I should have access to the server. I can log in locally on the MySQL server with my credentials, just not remotely.
My settings in my.cnf look like this:
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld]
user = mysql
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
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 = 128.xxx.xxx.xxx
And I'm connecting with the following params (using Coda2 GUI -- but the problem doesn't seem related to Coda2):
Server: 128.xxx.xxx.xxx
Port: 3306
Username: sadmicrowave
Password: my_mysql_password
The full error message posted is:
Unable to connect to host uslonsweb003 because access was denied.
Double-check your username and password and ensure that access from your current location is permitted.
MySQL said: Access denied for user 'sadmicrowave'#'128.xxx.xxx.xxx' (using password: YES)
I can telnet to my server using IP address and 3306 so I know the server is listening on that port...
What the heck is going on?
Did you issued the flush privileges after granting access to the wildcard user?
What happens if you add an entry with user = sadmicrowave and host = [your actual ip] (don't forget to issue the flush privileges command after adding the user) ?