I am running mysql in my localhost under the port number 3306. I want to access mysql database remotely. my system has the ip address and i want to use this instead of localhost. Can you please tell me how can i achieve this one.
Have you written some code for it for accessing remote database.
Is there any error??
If you need to access your database remotely then you need to do following
.
Mysql :-
mysql> GRANT ALL ON *.* to root#'localhost' IDENTIFIED BY 'your-root-password';
mysql> FLUSH PRIVILEGES;
This will grant to all users to access database remotely.
Related
I am not so into DB and I have the following problem.
I have installed a MySql 5.7.17 on a remote Ubuntu 16.04 server and I have to connect to this server from a client installed on my laptop.
So The first thing that I have done is that I have changed the bind-address directive values (into the /etc/mysql/mysql.conf.d/mysqld.cnf file) from:
Bind-address=127.0.0.1
to:
bind-address = 0.0.0.0
to allow also external connection.
The problem is that when I try to connect from my client (installed on my laptop) I obtain this error:
Host 'XXX.YYY.ZZ.JJ' is not allowed to connect to this MySQL server
(where **XXX.YYY.ZZ.JJ* is my laptop IP address).
From what I have understood I also have to give to the mysql user w the db permissions to connect from any host and not just from localhost.
I think that it should be something related to the grant: https://dev.mysql.com/doc/refman/5.5/en/grant.html
What exactly have I to do? I think that I have to access to MySql from my server shell (via SSH) and then perform a query that grant some privileges to the root user (the MySql user) to allow to access from outside.
But I don't know what exactly I have to do. How can I allow this external connection for the roo user?
As you mentioned, you need to login to mysql server with root access and then run following command on mysql prompt
GRANT ALL PRIVILEGES ON your_db_name.* TO 'your_db_user_name'#'%' IDENTIFIED BY 'newpassword';
you can also specify a specific IP instead of %
GRANT ALL PRIVILEGES ON your_db_name.* TO 'your_db_user_name'#'your_IP_here' IDENTIFIED BY 'newpassword';
you can also specify a for all databases
GRANT ALL PRIVILEGES ON *.* TO 'your_db_user_name'#'your_IP_here' IDENTIFIED BY 'newpassword';
I'm in the process of setting up a MySQL server. I set up the server as localhost on port 3306. However I want to be able to access this server over the network. The server has a static IP address. How can I change it from localhost to the static IP address?
I already did this suggestion I found online, and it didn't work:
mysql> GRANT ALL ON *.* to root#'localhost' IDENTIFIED BY 'your-root-password';
mysql> FLUSH PRIVILEGES;
When I try to access it from the server or another PC, I get this error:
Failed to Connect to MySQL at XXXXXX:3306 with user root
HOST 'XXXXXXX' is not allowed to connect to this MySQL server
Thank You.
In addition to the GRANT statement you've already listed above, you also need this one to connect from somewhere other than localhost
GRANT ALL ON *.* to root#'%' IDENTIFIED BY 'your-root-password';
In MySQL land user#somehost is, in practice, a different user than user#some-other-host.
I need to connect a desktop application to a MySQL server. The website connect to the database 'localhost'. What would the the full path of the localhost be?
Using CentOS 6.5/apache/zpanel
The answer is probably so obvious that nobody has ever asked it before. But I rally can't figure it out. Here is the screenshot of what I have:
It's the IP address of the server which is running mysql (the same of the webserver, if you're connecting to it as localhost)
But many hosting companies disable remote MySQL by default, you may need to ask them to enabled it, or to whitelist the IP you are connecting from.
You have to grant access to the user you are using to connect from remote, on your case the root user so:
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%'
IDENTIFIED BY 'password' WITH GRANT OPTION;
After this run this other command to refresh the new privileges
FLUSH PRIVILEGES;
The '%' is the option that you allow root to connect from anywhere. You can specify also an IP address.
I've a CentOS 5 Plesk server.
I have an updated version of phpMyAdmin in a public folder and if I try to login with my admin details (the root user of the entire MySQL server) everything works fine.
If I try to login with the same user using MySQL Workbench it says:
Failed to Connecto to MySQL at <myip>:3306 with user admin
Access denied for user
'admin'#'<myisphost>.fastwebnet.it' (using password: YES)
I've tried other users and they works if I use the old authentication protocol. So I've tried with this option but the error is the same.
Connecting to MySQL from SSH terminal everything works fine, looks like the problem is only with Workbench...
Any help?
First variant:
Looks like your admin acount has been limited to access only from localhost.
Login to MySQL using mysql command from ssh (using your root credentials) and run this command:
GRANT ALL PRIVILEGES ON *.* TO 'admin'#'<myisphost>.fastwebnet.it' WITH GRANT OPTION;
This will allow you to connect from your host (<myisphost>.fastwebnet.it).
To check your access privileges:
SHOW GRANTS;
If you'll have something like this:
GRANT ALL PRIVILEGES ON *.* TO 'admin'#'localhost' IDENTIFIED BY PASSWORD '...'
than you have access only from localhost (machine where MySQL server is running on).
also you can check privileges using this command:
select user,host from mysql.user;
Second variant:
Second one variant is to use ssh-tunnel.
In MySQL Workbench when creating new connection select
connection method as "Standart TCP/IP over SSH" option.
Fill in your SSH/MySQL credintials. Please note to use your MySQL access options as for localhost.
Something like this:
In my case, I just closed all the current tabs in Workbench and logged in again.
A client wants access from there ip address to a specific mysql table for their CRM program. I am developing the website part and collect data with a form.
Which steps should i make to grant access to a particular mysql table from one ip address and how can i test it?
GRANT ALL PRIVILEGES ON mydatabase.* to jsmith#'69.234.27.102' IDENTIFIED BY 'jimspassword';
can i replace * with the specific table? And how do i test this from my pc?
regards,
Grant privileges:
GRANT ALL PRIVILEGES ON mydatabase.mytable to yourtestuser#'your_ip_address' IDENTIFIED BY 'yourpassword';
Remember to:
FLUSH PRIVILEGES;
after that.
Make MySQL listening for network connections:
In my.cnf:
[mysqld]
port = 3306
Check with:
netstat -lnp
Make sure firewall does not block your connections
iptables-save
Check if everything is OK on network level from your PC with:
telnet mysqlbox_ip 3306
Make sure if there is a user defined in MySQL:
mysql> \u mysql
mysql> select * from user;
Make sure there are table privileges defined:
mysql> select * from tables_priv;