Can't connect as admin with MySQL Workbench - mysql

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.

Related

How to set MySql grant to allow external connection to MySql?

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';

Can't login to MySQL Server externally

I have an Ubuntu 16.04 server running on Microsoft Azure, and I have a MySQL Server running on that. I have 2 users, root and MattyAB (Me), which I created with this command:
GRANT CREATE ON *.* To 'MattyAB'#'localhost' IDENTIFIED BY '********';
GRANT ALL PRIVILEGES ON * . * TO 'MattyAB'#'localhost';
Where * is my password. I then try to connect to the server with my personal computer, but it doesn't work.
What am I doing wrong?
Do I need to change this #'localhost' to something else?
So I have ran into this problem with other things that I have done.
So you basically just need to run the following command after identifying what port your mySql runs on.
In Your Ubuntu Terminal. Run This
EXPOSE <PORT NO>
Try sudo expose if this does not work.
What have you done? You gave grants to access all databases and tables *.* at your server to the account
'MattyAB'#'localhost'.
Localhost obviously is not an extern account. As far as I know you have to use the '%' operator instead of 'localhost', or just the IP from which you want to log on to your mysql server.
You need something like this: GRANT CREATE ON *.* TO 'MattyAB'#'%' IDENTIFIED BY '******'; I am not sure with the single quotes around the %. In case of error try both types of syntax.
Furthermore you can take a look at MYSQL Grant Syntax.
With SHOW GRANTS FOR MattyAB you can check your grants configuration.

Mysql connection from other computer to xampp server? Error 1045

There is much information about this error but seems nothing works.
So I try to access to xampp mysql-server using the user root from local network.
mysql -uroot -p -h 192.168.100.48 --port=3306 (connecting from other local computer to xampp server)
But even I put right password (which I use for root) it not work. It works only if I log in using same computer where the server is running. I can use other user which I have specified but not root user. Why?
So how to fix this problem and getting it working?
Does the root user have the correct permissions?
Check the first duplicate link below for full answer - credit to Michael Berkowski:
GRANT ALL PRIVILEGES ON *.* TO 'root'#'192.168.1.%'
IDENTIFIED BY 'some_characters'
WITH GRANT OPTION;
FLUSH PRIVILEGES;
Have you tried search SO first? There are quite a few questions like this.
Possible duplicates:
How to grant remote access permissions to mysql server for user?
Remote MySql connection from other server

Access denied for user 'user'#'host' (using password: YES)

I have a created user in my MySQL database:
CREATE USER 'user'#'host' IDENTIFIED BY 'password';
I have granted that user full privileges:
GRANT ALL ON *.* to 'user'#'host';
Echoing the grant:
GRANT ALL PRIVILEGES ON *.* TO 'user'#'host' IDENTIFIED BY PASSWORD '*03FFC888F82E921D8CA360925A8F443CF326DE89'
I can connect from MySQL workbench using this login credential w/o any issues and execute queries. And it's running on the same machine the web application is running on. MySQL instance is running on another computer in the same local network.
However, when I try to use the same credentials from my web application running in Tomcat7 under Eclipse I receive the error. Please advise.
Note: As of last night, the web application was able to connect just fine. With nothing changing (that I am aware of - I am only one working on this), this morning I could not connect.
RESOLVED:
I added the user with grants using the IP address for the host for the local machine.
I am not sure what changed on the server, but now I am able to connect again.
Would someone possibly be able to explain this change, and with it why I am now required to use the IP address when previously the local host name was sufficient?
Make sure you are using the appropriate hostname, and you're accessing from that host, the user can't connect from another host.
To give permission you must put the password unencrypted.
Example
GRANT ALL PRIVILEGES ON test. * TO 'root' # 'localhost'
IDENTIFIED BY 'goodsecret';
Also must be the same password when you create the user.
Here How adding users to MySQL
Note: For more information on GRANT here is the documentation.
Hope this helps

Accessing MySQL with Toad via SSH

I'm giving Toad a try for use with my MySQL db, but I cannot seem to connect (Linux-based server with MySQL database) remotely using Toad. After entering the right credentials for both SSH login and the database login, I still get this:
'Access denied for user 'wlaprise'#'166.203.5.139' (using password: YES)'
I can however successfully login remotely using SSH and MYSQL commands directly from the command line using the same host and credentials, so I believe the credentials and firewall settings are not the problem. The username is the same for both SSH and the db (not the smartest, I know), so I even tried reversing the password entries in case I had the credentials switched. No difference.
I looked through Toad's 'Connection Properties' to see if it was encrypting my credentials somehow which could explain the 'Access denied' error, but didn't see anything.
This has to be basic, but I don't see what I'm missing? Ideas? Thanks.
When you are using shell command line , then you are connecting from localhost,
thus effective permissions are 'wlaprise'#'localhost'
What you can do is to grant permissions to same user, but from different location/IP:
GRANT ALL PRIVILEGES ON *.* TO 'wlaprise'#'166.203.5.139'
IDENTIFIED BY PASSWORD 'mypassword';
or
GRANT ALL PRIVILEGES ON *.* TO 'wlaprise'#'%'
IDENTIFIED BY PASSWORD 'mypassword';