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;
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 trying to connect to my local mysql database from my EC2 instance. unfortunately I wasn't able to.
This was the cmd I run from my EC2 to connect to my local Mysql database.
I was able to get my Public IP address using https://whatismyipaddress.com/
then I create a user using a user with the following cmd
mysql --host=public_ip_address --port=3306 --user=mongotop --password
These are the steps I followed to create the user and grant privileges.
CREATE USER 'mongotop'#'public_ip_address' IDENTIFIED BY 'user_password';
GRANT ALL PRIVILEGES ON instagram.* TO 'mongotop'#'public_ip_address' WITH GRANT OPTION;
FLUSH PRIVILEGES;
then I create a configuration file ~/.my.cnf and this was the file content.
[mysqld]
user = mysql
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
bind-address = 0.0.0.0
key_buffer = 16M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 8
myisam-recover = BACKUP
query_cache_limit = 1M
query_cache_size = 16M
log_error = /var/log/mysql/error.log
max_binlog_size = 100M
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
[mysql]
[isamchk]
key_buffer = 16M
I also did go ahead and turned my Mac machine firewall off.
Did I miss any step or does the configuration file in the not in the proper location or the appropriate configuration settings.
I am having problems launching MySQL on my local machine. Every time I try to launch the instance I get an:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")
For creating the required file I followed this solution changing the directory /var/lib/... to /var/run/... since it is how my configuration is set. The weird thing is that when I follow the steps described the process is launched and I can access to my database, but after a while it suddenly stops and the files (mysqld.sock and mysqld.pid) dissappear. How can this be possible? How can avoid it from happening?
The settings on my 50-server.cnf of my mariadb are:
#
# * 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
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-
I can't figure out why i cant access a remote MySQL server in ubuntu inside a VMware. I already have the codes, and it's successfully connecting to my localhost as well as insert, delete and update of data's. But when I make a new connection string with specified IP server address it show an error:
I can only access the files in that server through SSH and browser (192.168.56.xxx/phpmyadmin).
Here's my code for connection string.
Dim conn As New MySqlConnection
conn.ConnectionString = "Server=192.168.56.xxx;port=3306;User=root;password=mypassword;Database=prodDB_vb"
conn.Open()
MessageBox.Show("Connection to Database has been opened.")
cmd.Connection = conn
I already read a lot of forums about this. But dont understand what they are pointing to.
Also i executed the code:
GRANT ALL PRIVILEGES ON prodDB_vb TO 'root#*' IDENTIFIED BY 'my_password';
FLUSH PRIVILEGE;
The only thing i know is that i cannot find the my.cnf in the server files, but already change my my.ini in my localhost's bind ip address.
#bind-address="127.0.0.1"
3306 is listening
And i have this in my my.cnf
Why having this error?
Anyone please help.
Did you check to make sure that MySQL is actually listening on 3306? Run a netstat -tlpn and provide the results. If you don't see 3306 then its probably not.
In my.cnf you should verify that --skip-networking is commented out
[mysqld]
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
language = /usr/share/mysql/English
bind-address = 65.55.55.2
# skip-networking
To locate your CNF file
Edited:
For example, if your MySQL server IP is 192.162.0.3 then entire block should be look like as follows:
[mysqld]
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
language = /usr/share/mysql/English
bind-address = 192.168.0.3
# skip-networking
....
..
....
bind-address : IP address to bind to.
skip-networking : Don’t listen for TCP/IP connections at all. All interaction with mysqld must be made via Unix sockets. This option is highly recommended for systems where only local requests are allowed. Since you need to allow remote connection this line should removed from file or put it in comment state.
Then we have to Restart mysql service to take change in effect:
/etc/init.d/mysql restart