mariadb remote connection fail in centos - mysql

I have visited many websites for remote connection of MariaDb.
I have executed the command as below to create user with password in sql.
GRANT ALL PRIVILEGES ON . TO 'root#(my server ip)' IDENTIFIED BY '(my password)'
And i've added one line below [mysqld] in the file of /etc/my.cnf.d
bind-address = 0.0.0.0
Then restart MariaDb service as below
sudo systemctl restart mariadb
Everything runs good.
However when i access by below command, it runs failed.
mysql -u root -p -h (my server ip)
I've turn off my firewall in my server, and turn on the port 3306 in GCP server, and it can be expected, i must fail to connect in my local machine.

Since you want to use a TCP connection, I assume that you want to connect to a remote server, not to a server running on the same machine.
Make sure that you are able to connect physically to the database server, e.g. with telnet server_ip:3306.
Determine the IP address of the computer from which you want to connect to the server (= client_ip).
Add a user on the server:
GRANT ... TO root#client_ip
If client and server are running on the same machine, the preferred way is to use a linux socket (user#localhost) which is way faster.

Related

Unable to Access MySql 8.0 Database from Remote Windows Server

I have Installed MySql 8.0 Version in a windows
server and able to connect via WorkBench/MySql shell locally.
I would like to access MySql from a remote windows server.
Here are the things I have tried.
1) Created root#% user and Grant full access to the new user.
2) Created a new user as test#'remoteserveripaddress' and Grant full access to the user.
3) Opened port 3306 on Both Remote and MySql server.
4) Added "bind_address=*" in my.ini file and restarted the MySQL80 Service.
I am running out of options.
Error: I am getting below error
Failed to connect MySql at UserName#hostipaddress:3306
SSL connection error: error:00000000:lib(0):func(0):reason(0)
No matter how many different ways I try.
Not sure what am I doing wrong ??
Try to execute below command in your terminal :
mysql -h server -P 3306 -u root -p
If you successfully connect to your database, the same thing has to happen with Mysql Workbench.
If you are unable to connect then I think 3306 port is acquired by another process.
Find which process running on 3306 port. If required, give admin privileges using sudo.
netstat -lnp | grep 3306
Kill/stop that process and restart your MySQL server. You are good to go.
Execute the below command to find my.cnf file.
mysql --help | grep cnf
You can change MySQL port to any available port in your system. But after that, make sure you restart MySQL server.

port fowarding for mysql server ubuntu remote connection

I have a ubuntu 16.04 on which I run 3 servers from virtualbox (a webserver, a home file server and a mysql server).
In this mysql server I naturally have an internal ip (192.168....) and an external one.
However when I try to connect remotely to this mysql server from mysql shell, workbench or .NET connector (eg. mysql -u root -p -h 172.241.442.12) using the external IP of this virtual machine I always get ERROR: Not connected.
My question is whether to connect I have to enable port forwarding in my router (3306), just as I would do enabling 80/8080 in a webserver to make it accessible from the internet.
I never did it before and haven't find any clear tutorial either. My main purpose is to connect to this db in a vb.net application.
Thanks!
Yes, if you intend to access it in this manner you will need to forward a port. You will also need to grant access to MySQL for a user that is allowed remote access.
GRANT ALL ON somedb.* TO `user`#`123.123.123.123` IDENTIFIED BY 'somePassword'
The IP address can be a hostname, or % to match everything.
That said, unless you really need a permanant external connection to MySQL you should not expose it like this, the better option would be to tunnel the port through SSH.
ssh -N user#dbserver -L12345:localhost:3306 &
mysql -u root -h localhost -P 12345

Can't connect to remote MySQL server on Windows

I'm trying to set up a MySQL server on Windows that will allow another computer to connect to it remotely. The client computer is getting a 'Can't connect to MySQL server' error in MySQL Workbench.
Both computers are on the same network, and the server is using a static IP address (I have forwarded ports in my router to allow external connections to the public IP address).
What I've tried (suggested by other threads):
In my.ini, setting bind-address = 0.0.0.0 / commenting out bind-address / commenting out skip-networking
Running GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'#'IP' IDENTIFIED BY 'PASSWORD';. When I run this, I get the error Using GRANT statement to modify existing user's properties other than privileges is deprecated and will be removed in a future release; however I can confirm that in Workbench, the user's privileges are all checked (under the 'Users and Privileges' screen).
In my router settings, forwarded port 3306 on the server's static IP address
Disabling the Windows Firewall on the server.
Verified that the MySQL Server Windows Service is running.
Can anyone advise?
Ref: Try connecting with mysql cli instead of work bench from the remote machine, so u can isolate that cli client u r able to access the remote DB. because the following reason might be causing connectivity issue in Workbench.
mysql cli cmd
install mysql.exe client program
from cmd prompt> mysql -hhostname -uusername -ppass dbname
Cannot connect to Database server (mysql workbench)
In MySQL Workbench (5.2.47 CE)
click Mange Server Instances (bottom right corner)
click Connection
in the Connection box select:
Local Instance ($ServerName) - root#127.0.0.1:3306 '<'Standard(TCP/IP)>
click Edit Selected...
under Parameters, Hostname change localhost or 127.0.0.1 to your NetBIOS name
click Test Connection

Need mysql remote access with my system IP

I have been using ubuntu 14.04 LTS OS and now i want to give permission of my local mysql server for my colleague system in my network. I need the answes for the following question,
How to bind my system IP address to mysql server. If i execute the command line "mysql -uroot -proot -h192.168.1.198", then received the error message below
ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.1.198' (111)
Then how to give permission to other system user to access my local mysql server.
Your MySQL service is bound to serve localhost only (interface binding). This is the default for security reasons. If you really need to access it directly from other hosts, there is a nice How to enable remote access to MySQL on Ubuntu which you could follow:
as root, open your /etc/mysql/my.cnf with your favorite editor
look for the [mysqld] section, and in there for the bind-address keyword. This usually is set to 127.0.0.1 -- change that to match your "normal" IP-address
save the file, and reload the service (e.g. using service mysql restart)
Remember you must enable your remote users to access their database(s) from remote, by setting the appropriate GRANTs -- e.g.
GRANT ALL ON mydb.* TO remoteuser#'%' IDENTIFIED BY 'SomePASSWORD';
Note the #'%', which means "from any host".
Try to telnet MySql server from that PC
telnet 192.168.1.198 3306
If that fails there are two cases:
You have not properly opened MySql Server required ports (default: 3306)
Go to my.ini (or my.cnf) and comment out bind-address and change it to 0.0.0.0 (to listen to all available interfaces) or perhaps the server's LAN IP (192.168.1.XYZ).

cant access remote mysql server need help

I have a unix server with mysql which I am trying to access from my machine. To clarify, access the mysql server. When I do I get this error.
Connecting to MySQL server 192.168.1.25...
Can't connect to MySQL server on '192.168.1.25' (10061)
Here are my credentials:
username: root
port: 3306
The server is running because I am able to remotely login onto the machine (with ip: 192.168.1.25" and then run mysql from root. What do you think is going on:
Is it a firewall issue?
Accessing as 'root' is being denied?
I am new to mysql.
1)
check the logs
you can see where the logs are by checking the my.cnf file.
mysqld.log might be the file name, but where
2)
a. see if it's a network issue.
telnet 192.168.1.25 3306
b. see if the service is at that port.
ssh to the box
# from the local host
mysql -u root
telnet 127.0.0.1 3306
ps auxw|grep mysql
you should hopefully have enough diagnostic info at this point to figure it out.
Probably because remote root login is not allowed. You can try this article on how to enable remote root:
http://benrobb.com/2007/01/15/howto-remote-root-access-to-mysql/
i have this problem and fix it by
first you must grant all to user
GRANT ALL PRIVILEGES ON databasename. TO 'user'#'%' IDENTIFIED BY 'password';
then
FLUSH PRIVILEGES;
and change the mysql config using
sudo nano /etc/mysql/my.cnf
find "bind-address" row and comment it.
save config and restart mysql using
sudo /etc/init.d/mysql restart
hope solve problem :)
The Message (10061) is do to offline severs or firewall blockage
If you get -the name of your pc - can not connect, then mysql is rejecting the connection and you will have to create a 'user' in the mysql database mysql, table user using the IP of the remote connection', and restart the database service
but for error 10061 check The Firewall in both machines.
Masters PC per say, is the one with the phpmyadmin installation
Allow Destination ip-[the remote] and port 3306 on the Master Machine
and
Allow source ip-[the masters]/with any port, and check your destination port(3306) too. destination ip can also be set on some firewalls.
And if you can, search in your firewall for logs, settings, recent activity, etc... to see what and how you are being blocked.