MySQL Access Denied For User on Other Laptop - mysql

I have created a database using MySQL version 8.0.22 (I realize it's not the newest version but the newer version didn't work on my laptop). I need to have somebody (for who I made the database for) have full access to the database from their own laptop. I created their user with a password, granted full access, and flushed privileges.
CREATE USER 'user'#'localhost' IDENTIFIED BY 'password1234!';
GRANT ALL PRIVILEGES ON fsk TO 'user'#'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
However, I still got the error:
"Access denied for user 'user#'localhost' (using password: YES)"
I have been googling this error for the past two days and have everything from making sure there aren't any duplicates that contain "%" instead of "localhost" to reinstalling the program. For even more clarification, when trying to connect on MySQL Workbench, I entered 'localhost' for the "Hostname" field (didn't use quotes around localhost), the correct username, and finally, the correct password (made sure after attempting plenty of times very slowly).
Am I missing something with trying to get this working? I really just need one user to have full access to the database from another laptop and I keep getting "Access Denied" when trying to log in as that user I have created.
Any help would be GREATLY appreciated.

Related

Can't connect to MySQL using user with password

I am setting up my local development environment using XAMPP for writing websites using Laravel.
The issue im facing is that I cannot connect to the MySQL database with any new user I create. I give one user limited privileges for only one database and cannot connect using the correct password.
I tried making an admin user with full privileges on all databases and tables, and still cannot connect with the correct password.
The returned error is always the same -
SQLSTATE[HY000] [1045] Access denied for user 'laravel'#'localhost' (using password: YES)
and
ERROR 1045 (28000): Access denied for user 'admin'#'localhost' (using password: YES)
where laravel is the username, admin is the other one etc.
This is not related to Laravel as I keep getting this error even when I try to connect from the command line (as shown in error code number 2).
The 'anonymous' user has been removed to make sure MySQL doesn't match it by mistake, I have flushed privileges and restarted services countless times.
The default root user without password can connect, but no new users that I create with passwords can.
Solved the problem by re-installing XAMPP, nothing else.

Access denied creating initial database- how do I grant the right access?

I'm making a new project on heroku, using mysql (they have an addon called JawsDB, which gives me a mysql host, username, password). (Update: I've also tried using their other mysql addon, ClearDB, and I have the exact same issue)
I can connect to the database like so (and I can 'show databases' to see what's there):
mysql -h izm96dhhnwr2ieg0.cbetxkdyhwsb.us-east-1.rds.amazonaws.com -u knu81lzn5m79u3rx -p[given_password]
Problem: When I do create database nptest, I get:
Access denied for user 'knu81lzn5m79u3rx'#%' to database 'nptest'
I've tried granting all privileges, like this:
grant all privileges on *.* to 'knu81lzn5m79u3rx'#'%' identified by '[given_password]';
but that gives me:
Access denied for user 'knu81lzn5m79u3rx'#'%' (using password: YES)
I also tried create user to make a fresh one, but of course then it's "Access denied" because I don't have create user privileges either.
What's the correct way to grant access to this user?
Ah! The answer was that the preliminary plan on jawsDB gives you one specific database (that has a cryptic name) on a shared server with other people, so you don't have permissions to make a new one. It wasn't clear in the instructions, so now I'm humming away with good old database "tbkrv66g085ulngi" :)
To further clarify on Diane's answer, the cryptic database name can be found by logging into JawsDB via a mysql client and runningshow databases or it's the last parameter of the JAWSDB_URL that can be found running heroku config.
i think if you use it in production mode it will solve the probl

Create a new user without root password

I have to create a database in a Windows Server 2008 remote machine, which already had MySql Server 5.5 and MySql Workbench 5.2 installed. Since I wasn't granted the password to the root user, I tried to create a new user.
In MySql Workbench I tried to open the Manage Security option, to no avail, since it asked for the password.
In the command prompt I tried to run mysql but it returned the following error message.
ERROR 1045 (28000): Access denied for user 'ODBC'#'localhost' (using password: NO)
Is there any way to create a new user without having prior access to the root user?
More generally, is there any workaround to create and use a database without access to root?
You don't have to be the root user, but you must have rights to create a user. You can get those rights with the grant create user statement. Apparently, you don't have those privileges, so if you need them, you should ask your administrator.
So the answer is: There is no workaround. You don't have to be root, but you must have certain privileges.
In practice, if you need an extra user, the administrator is more likely to create one for you than to give you the rights to create them yourself. But that's something he and you need to figure out yourselves. :)

How do I manually block and then unblock a specific IP/Hostname in MYSQL

First off, I did google this but sites are flooded with advice on how to deal with "host name is blocked" issues. (https://www.google.com/search?q=mysql+block+a+host). My issue is a little bit the opposite of that.
With me, I am running a MySQL database and no PHP is involved.
I need to block a certain host-name/IP address from connecting to my database, then I will unblock it. I am hoping there are 2 simple queries for this that I can execute on the MySQL database, I just can't seem to find it anywhere.
I can find the hostnames pretty easily by running the show processlist query and I know I can kill one process at a time, but so many new threads pop up that if I can just block all of them from a certain hostname, that would be ideal. Then I will unblock once I fix a few things.
You can use GRANT to give a non-privileged entry for a user connecting from a specific host, even if you have GRANTed privileges to a wildcard including that host. When authenticating, the most specific host match takes precedence.
For example, suppose you enabled a user to connect from a range of hosts on your local subnet:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'user'#'192.168.56.%' IDENTIFIED BY 'xyzzy';
Then you could grant the minimal USAGE privilege, which is a synonym for "no privileges" for that user for one specific host within that subnet:
mysql> GRANT USAGE ON *.* TO 'user'#'192.168.56.110';
Subsequent attempts to connect from that host get this error:
$ mysql -uuser -pxyzzy
ERROR 1045 (28000): Access denied for user 'user'#'192.168.56.110' (using password: YES)
The reason this gets an error is that I did this grant for the user with no password. If I try to submit a password, this doesn't match the entry in the privileges table.
Even if the user tries to connect without using a password, he finds he has no access to anything.
$ mysql -uuser
mysql> USE mydatabase;
ERROR 1044 (42000): Access denied for user 'user'#'192.168.56.110' to database 'mydatabase'
You can undo the blocking:
mysql> DELETE FROM mysql.user WHERE host='192.168.56.110' AND user='user';
mysql> FLUSH PRIVILEGES;
And then the IP range will come back into effect, and the user will be able to connect from thathost again.
You can revoke privileges as mentioned above, but this will still allow a user to make a connection to your MySQL server - albeit this will prevent that user from authenticating. If you really want to block/allow connections to your MySQL server based on IP, use iptables.
Have you tried using MySQL Workbench?
You can simply remove ROLES for a specific User/Host from there.

Mysql "access denied for user" error?

I have just added a new database and imported alot of backed up data to it because of a malfunction in the previous database.
I use php and have my own Ubuntu server.
I use phpmyadmin, and have set all privileges to the user.
I am positive the password, username and host are correct.
But I still get this "Access denied for user 'user'#'localhost' to database 'skuffen2'"
What should I do?
Do I need to set permissions somehow on the server?
Please guide me I am in deep need of help right now...
Thanks
login to mysql using root user, use mysql; select * from db where user where user_name=xxx; and check other table as well, most of the privileges settings are there, or just simply flush privileges;