MariaDB: root access from network means also from SSH? - mariadb

During the securing of MariaDB it asks me the following question:
Disallow root login remotely? [Y/n]
Normally, root should only be allowed to connect from 'localhost'.
This ensures that someone cannot guess at the root password from the
network.
Because I'm working on a headless server (Ubuntu Server) without any screen nor keyboard, my only way to reach the o.s. is via SSH.
Disabling the remote root login will prevent me to access from SSH as well? I guess yes, and I kept the remote login enabled.

It's the default admin account of MariaDB, has same name with system root account, but there's no direct relationship between them. System user bob can also use command mysql -uroot -p to connect MariaDB with admin privilege.
login remotely means connecting to MariaDB remotely using port 3306. if remote login is enabled for root and MariaDB bind a public IP, anyone can try to connect to your DB by mysql -uroot -hIP. then a security incident happened if weak password used.

Disallow root login remotely? [Y/n]
That's from MariaDB perspective, NOT the SSH.
When you are login via SSH and then login to MariaDB via mysql cli to localhost server, MariaDB assume that you login "locally".
As like many other RDBMS, MariaDB allow to login remotely, in your case without SSH, to any remote server via TCP/IP. This kind of login to MariaDB is the meaning about above question.
Example:
You are now at Host A (IP: 192.168.0.10). The MariaDB server at Host B (IP: 192.168.0.11).
If you are accessing the MariaDB server via mysql client cli and execute:
mysql -h192.168.0.11 -uroot -p
That's called "root login remotely"

Related

SharePoint on Prem not working behing Nginx Proxy Manager

I have both a sharepoint 2016 on prem server and a docker container running nginx proxy manager. Both are VMs on the same network running on vmware vsphere. I have the proxy host for sharepoint configured to point the subdomain to the SP server host. When I am attempting a log in via the domain URL, I keep getting asked my log in credentials ( I Log in with my username and password and it refreshes the screen and prompts for my user and password again). Is there something I'm missing in either my NPM or SharePoint setting?

How to launch PhpMyAdmin or MySQL Workbench for an AWS Ec2 WordPress instance?

I launched a WordPress instance in EC2 in AWS. Now I can access WordPress Dashboard. But how to access database? If I install WordPress in my PC I can easily access it via a local-host link. From AWS how can I access the same? Also, is there any possibility to connect the MySQL database via MySQL Workbench?
Thanks
Venkat
Venkata, you are able to access WordPress hosted on EC2 because the http port and https port is open in the firewall, check your inbound settings in security group.
You can access your MySQL Database hosted in same EC2 instance (in this specific case) if you can open the port for access, in inbound settings. Make sure you have a MySQL user created and you have user name and password for the user.
First On EC2 instance you have to configure complete LAMP stack and than you have to open the port from security groups from AWS console admin.
After installing LAMP stack and opening port you have to place adminer.php file on the /var/www/html directory or the directory where you installed the wordpress.
after that you can access the database and the wordpress

What is the configuration for setting up MySQL workbench with a AWS Bitnami instance?

I am some issue with connecting the pipes between MySQL Workbench and my Bitnami Wordpress instance on AWS (using ssh). I have read and attempted the docs several times, I don't know what is going on.
I have successfully ssh-ed via the command line using ssh -i my_key_file bitnami#IP-Address.
However, I cannot get it to work for MySQL Workbench.
Field Value
SSH Hostname IP-Address
SSH Username bitnami
SSH Key File <path-to-key-file>
MySQL Hostname 127.0.0.1
MySQL Server Port 3306
MySQL username root
The path to key-file is correct as it works for other AWS instances. And the SSH hostname and SSH username get my access via the terminal - so I would assume these are fine?
When I test the connection, I am prompted for a password. Everywhere online suggests that this password is the admin password used the Wordpress account (accessible via the system logs). I have this password. However, this doesn't get me in.
The attempted connection returns the error: Failed to Connect to MySQL at 127.0.0.1:3306 through SSH tunnel at bitnami#IP-Address with user root
Any help would be appreciated
I have read and attempted the docs several times, I don't know what is going on.
I guess you are referring to this documentation
Could you try to reset the password for the root user as described in the guide below?
https://docs.bitnami.com/aws/components/mysql/#how-to-reset-the-mysql-root-password
Once you have restarted it and you have chosen a new one, use this new password on the Workbench.

Google analytics code fires twice on transaction page of my website. [duplicate]

I am getting error:
"Lost connection to MySQL server at 'reading initial communication packet, system error: 0"
while I am going to connect my db.
If I am using localhost everything is working fine.
But when I am using my live IP address like below, it's getting error:
mysql_connect("202.131.xxx.106:xxxx", "xxxx", "xxxxx") or die(mysql_error());
Someone here suggests that it might be a firewall problem:
I have just had this problem and found it was my firewall. I use PCTools Firewall Plus and it wasn't allowing full access to MySQL. Once I changed that it was fine.
Could that be it?
Also, someone here suggests that it might be because the MySQL server is bound to the loop-back IP (127.0.0.1 / localhost) which effectively cuts you off from connecting from "outside".
If this is the case, you need to upload the script to the webserver (which is probably also running the MySQL server) and keep your server host as 'localhost'
Open mysql configuration file named my.cnf and try to find "bind-address", here replace the setting (127.0.0.1 OR localhost) with your live server ip (the ip you are using in mysql_connect function)
This will solve the problem definitely.
Allow remote connect to MySQL.
Edit file:
>sudo nano /etc/mysql/my.cnf
Comment line:
#bind-address = 127.0.0.1
Restart MySQL:
>sudo service mysql restart
Create user for remote connection.
>mysql -uroot -p
CREATE USER 'developer'#'localhost' IDENTIFIED BY 'dev_password';
CREATE USER 'developer'#'%' IDENTIFIED BY 'dev_password';
GRANT ALL ON *.* TO 'developer'#'localhost';
GRANT ALL ON *.* TO 'developer'#'%';
In my case I need to connect remotely from Windows to VirtualBox machine with Ubuntu. So I need to allow port 3306 in iptables:
>iptables -A INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT
Had this problem when setting up a new slave server. Found it was the slave server IP address was missing from the master server /etc/hosts.allow file. Added the IP address and it let me connect to the master server.
Note that I use hosts.allow and hosts.deny to control access.
I had this problem and it ended up being the prior sys admin changed the port MySQL was running on. MySQL Workbench was trying to connect to the default 3306 but the server was running on 20300.
The error means that it didn't receive a response from the port it expected to find the server on. The causes range from contacting the wrong machine (For one of a number of reasons) to the server not being on the expected port.
Check which port your server is bound to in /etc/mysql/my.cnf. Does that correspond to what is in your connect statement. If they match then try connecting with mysql from the server itself and from the command line of the machine where you are running the client. If it works form one place and not another then you may have a firewall / router configuration issue.
One more reason...
I ran into an Ubuntu server where everything was customized and could not connect because of that same error.
This setting was inside /etc/ssh/sshd_config
PermitTunnel no
After turning into
PermitTunnel yes
I was able to connect remotely to my MySQL DB
The problem on my case was MySQL being bind only to the lo on linux.
in order to solve the problem i have edited the my.cnf (found at /etc/mysql/my.cnf) removing the line bind-address=127.0.0.1
this allows mysql to bind to any network interface
I just set up mysql on a windows box. I got the OP's error when trying to connect with the Navicat MySql client on the same box. I had to specify 127.0.0.1 as the host, and that got it.
localhost, or the servers actual ip address both did not work.
This error occurred to me while trying to connect to the Google Cloud SQL using MySQL Workbench 6.3.
After a little research I found that my IP address has been changed by the internet provider and he was not allowed in the Cloud SQL.
I authorized it and went back to work.
I faced the same problem. I checked and tried to set AllowTcpForwarding Yes but it was missing in my sshd_config so no help.I didn't change sshd_config or my.cnf. Make sure the ssh hostname is NOT the same with the mysql hostname(use localhost).
In workbench, choose + to add new connection and set the following:
connection method: standard TCP/IP over SSH
SSH Hostname: 192.168.0.50:22 (replace remote SSH server IP and port(optional))
SSH Username: sshuser
You can set password or add at the prompt
MYSQL Hostname: localhost or 127.0.0.1
MYSQL Server port:3306
You can set password or add at the prompt
Test connection. It should be successful then hit OK.Viola!
I ran into this exact same error when connecting from MySQL workbench. Here's how I fixed it. My /etc/my.cnf configuration file had the bind-address value set to the server's IP address. This had to be done to setup replication. Anyway, I solved it by doing two things:
create a user that can be used to connect from the bind address in the my.cnf file
e.g.
CREATE USER 'username'#'bind-address' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON schemaname.* TO 'username'#'bind-address';
FLUSH PRIVILEGES;
change the MySQL hostname value in the connection details in MySQL workbench to match the bind-address
The problem for me was that DNS queries were blocked by the FW within the subnet. The solution was to disable DNS lookups within MySQL.
The problem was quite stupid for me.
I used to get the same issue on AWS EC2 Ubuntu machine (MariaDB is installed locally for the time being), so I tried to make SSH tunneling, and had the same issue. So I tried to ssh tunnel over terminal:
ssh -L13306:127.0.0.1:3306 root#ip.address -i my/private/key.pem
And it told me this:
Please login as the user "ubuntu" rather than the user "root".
I changed ssh user from root to ubuntu, just like my ssh config, and it connected just fine.
So check your SSH connecting user.
I oversaw this, so this too half an hour of my time, so I hope this will be useful for you.
For me the config file was found "/etc/mysql/mysql.conf.d/mysqld.cnf" commenting out bind address did the trick.
As we can see here:
Instead of skip-networking the default is now to listen only on
localhost which is more compatible and is not less secure.
I am trying to connect my db docker container on Ubuntu 18.04, same problem.
First check your device by run nmcli dev to check if device docker0 is connected.
If it is not connected, try to restart docker service:
sudo service docker restart
I tried make a telnet over remote server on port 3306.
The error message is clear
Host 'x.x.x.x' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'Connection closed by foreign host.
As root at server mysqladmin flush-hosts worked at all!
I had the same error when using localhost. I restarted the MySQL service and it worked fine.
in my case, I had ALL: ALL in hosts.deny. Changing this to ALL: PARANOID solved my problem when connecting over ssh
Ran into this same issue, Bind Address back and forth to no avail. Solution for me was flushing privileges.
mysql> FLUSH PRIVILEGES;
Firewalld blocks the IP address. so to give access, use these commands:
firewall-cmd --permanent --zone=trusted --add-source=YOUR_IP/32
firewall-cmd --permanent --zone=trusted --add-port=3306/tcp
firewall-cmd --reload
For me setting bind-address = 0.0.0.0 in mysql/my.cnf worked. It basically listens to all addresses (but still one port) then.
And don't forget restart your server: systemctl restart mysql
I just had the same problem, but in my case I solved it with
service mysqld start
In my case it was the university wifi blocking port 3306. I was able to connect by using a mobile hotspot.
Change to a mobile hotspot or another network, and if it works there, then you know that original network is blocking port 3306. If you get the same error on more than 1 network, then you know it's specific to your machine.
I had port 3306 in Docker container but in Dockerfile it was 33060. I edited the port in Docker container to 33060
Must have been added to the Dockerfile
ENV MYSQL_ROOT_HOST 172.17.0.1
I have done below 3 steps then working for me.
bind-address = "YOUR MACHINE IP" in my.cnf file at /etc/my.cnf
Restart service by command : service mysql restart
GRANT ALL PRIVILEGES ON yourDB.* TO 'username'#'YOUR_APPLICATION_IP' IDENTIFIED BY 'YOUR_PASSWORD' WITH GRANT OPTION;
I had the same issue installing MySQL docker image then trying to connect from WSL2 MySQL client.
As it was stated in the accepted answer that it should be a firewall issue, in my case this error was caused due to not allowing docker for windows to communicate to private network.
I changed the settings on "Firewall & network protection", "allow an app through firewall", "change settings" (need administrator rights) and allowed "Docker desktop backend" to connect to private network.
I had the same error on my Mac with a local MySQL installation. The problem was that the number files that MySQL was opening was too high for MacOS.
To see if you have the same problem you can run this command and look for File Descriptor errors:
tail -200 /usr/local/var/mysql/$(whoami).err | grep "Warning"
I added this line to my.cnf file and the problem was fixed:
table_open_cache = 200
Had the same problem, what worked for me was:
Go to Windows Firewall where you allow applications.
mysql probably won't be in the list, so you need to add it, its path is typically C:/Program Files (x86)/MySQL/bin/mysql
Mark both private and public networks, apply.
When connecting to Mysql remotely, I got the error.
I had this warning in /var/log/mysqld.log:
[Warning] IP address 'X.X.X.X' could not be resolved: Temporary failure in name resolution
I just added this line to /etc/hosts file:
X.X.X.X some_name
Problem solved! Not using skip-name-resolve caused some errors in my local app when connecting to MySQL.

Kamailio not connects to remote database

I have Kamailio on ubuntu at 10.10.145.189 and mysql on centos at 10.10.118.91.
While installing kamailio, the command
/usr/local/sbin/kamdbctl create
worked and all databases created on 10.10.118.91 without any issue.
But when i try commands like
kamctl db show subscriber
it responds with error as follows.
ERROR 1045 (28000): Access denied for user 'kamailioro'#'ip-10-10-145-189.ec2.internal' (using password: YES)
10-10-145-189.ec2.internal was its hostname.
Solved it by creating database users kamailio and kamailioro with host any.
With the default configuration of kamctctlrc, /usr/local/sbin/kamdbctl create will create the user kamailio in the mysql db with localhost and the IP of the mysql server as the Host. After that when you use the command kamctl it tries to access the mysql db with kamailio#"IP_of_kamailio_server" and hence the access is denied.
Try changing in the kamctctlrc file
DBACCESSHOST=IP_of_kamailio_server to access the DB from the kamailio server
or
DBACCESSHOST=% to access the DB from any host for the user kamilio
and then create the schema in the DB /usr/local/sbin/kamdbctl create

Resources