Warning: mysql_connect(): Access denied for user - mysql

How do I make the MySQL give the user access and not deny?
how do i add the command too add permissions?
This is the full error
Warning: mysql_connect(): Access denied for user
Database error: Link-ID == false, connect failed
MySQL Error: 0 ()
Session halted.

Have you allowed access to the MySQL server for the login/server combination you provide?
grant all permissions on *.* 'bf_cards_user'#'My Server IP'
identified by 'bbeqvfyAwPWECvWs';
flush privileges;
or
Either your username, password or database name is wrong.
The error message is deliberately vague in order that unauthorised system-crackers are not helped to find out what they need to change; although I guess you know your username and password.
Refer here http://www.simfatic.com/forms/troubleshoot/mysql-connect-failed.html

Related

I don't have permission to enter in mysql console with root user

Well, I'm using Ubuntu 20.04 and I have installed MySQL some months ago. Actually MySQL version is 8.0.30.
I'm trying to get in the mysql console, but it gives me that neither root nor my personal user have permissions on MySQL.
What I've already tried:
skip-grant-tables => One of the solutions was putting this option in one of the MySQL configuration files, and then alter the root password. but when I try to change the root password, it gives me that I'm using the skip-grant-tables option. After trying this, and of course, using flush privileges and restarting the service after changing it, I get:
ERROR 1396 (HY000): Operation ALTER USER failed for 'root'#'localhost'
alter user => I tried many commands with alter user like:
alter user 'root'#'localhost' identified by 'My_password';
alter user 'root'#'localhost' identified with native_mysql_password by 'My_password';
set password for 'root'#'localhost' = PASSWORD('My_password');
But all theses commands give the error ERROR 1396 (HY000): Operation ALTER USER failed for 'root'#'localhost'.
Put the right authentication_string => Yes, I had checked this column to the root user, and it still giving me the same thing:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
No success at all. The last one even gives me a syntax error. But all this attempts gave me some information:
debian.conf => I did a cat in this file, and I found out that root user is not in there, even if it's in the Users table inside mysql database. But I can access mysql console with debian-sys-maint, using the password given in the file.
Permissions => I doesn't have any permissions with root.
root password => I have set the authentication_string to the root user inside users table to a very strong password, and even using it, I does not have permissions to enter mysql console.
Password validation => I have changed the global variables of password validation so I can change my password to a weak one. But when I restarted the MySQL service, it went back to the default configurations. It bothers me, but I can get along with it.
So what I'm looking for is: how can I give permissions to my root user access MySQL console? Should I recreate root user? Or is there another way to fix this?
EDIT1: PASSWORD function does not work for some reason.
EDIT2: I'm not able to create a root user. It gives me an error saying that I don't have permission to do so. It looks like mysql is not recognizing 'root' as a user. When I try "GRANT ALL" to 'root', it says that I don't have permission to create it, but it is already in the users table.

ERROR 1045 (28000): Access denied for user 'admin'#'localhost' (using password: YES)

I'm trying to log in to mysql via a bash script or to be more specific, I want to check if the passed parameters for the mysql user are thes of an admin user.
For this reason it has to be possible to log in to mysql via a one line command e.g.
mysql -u $dbadmin -p$dbadminpass
To test why I didn't work, I tried it myself on the command line an I'm getting this Error:
ERROR 1045 (28000): Access denied for user 'admin'#'localhost' (using password: YES)
I created the use on #localost and gave all privileges. All my reasarch had no reasults so far.
I checked for any typos
You can try this:
GRANT ALL PRIVILEGES ON *.* TO 'admin'#'%';
FLUSH PRIVILEGES;
or try to connect to 127.0.0.1 not to localhost
This is not a problem with MySQL installation or set-up.
Each account name consists of both a user and host name like 'user_name'#'host_name', even when the host name is not specified. From the MySQL Reference Manual: https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_usage
MySQL account names consist of a user name and a host name. This enables creation of accounts for users with the same name who can connect from different hosts.
This also allows MySQL to grant different levels of permissions depending on which host they use to connect.
When updating grants for an account where MySQL doesn't recognize the host portion, it will return an error code 1133 unless if it has a password to identify this account.
Also, MySQL will allow an account name to be specified only by it's user name, but in this case it is treated as 'user_name'#'%'.

MySQL connection with DBVisualizer

I've created a user (1caap) in mysql root account and given read only privileges for this user to one of my database. Now my client(1caapuser) is unable to access this database. I've established the connection using Workbench. He's getting the following error when he's trying to access this database using DBVisualizer:
An error occurred while establishing the connection:
Type: java.sql.SQLException Error Code: 1045 SQL State: 28000
Message:
Access denied for user '1caapuser'#'x.x.x.x' (using password: YES)
Please help me out if i'd missed any settings at the earliest.
To resolve this issue you have to grant all privileges on database with identified by the password
Command to run:
GRANT ALL PRIVILEGES ON yourDBname.* TO username#'%' IDENTIFIED BY 'password';
Check the following for more details about the error you get:
http://dev.mysql.com/doc/refman/5.1/en/access-denied.html
https://dev.mysql.com/doc/refman/8.0/en/error-access-denied.html
You must most likely grant proper access for the user at the given IP address/host name. Such as:
grant on . to ''#'';
Check the users guide which specific privileges and what target objects to grant. The important clause above is that you need to specify 'user'#'ip-address'.
Again, check the users guide as there may be a collection of reasons for the error you get.

Mysql Connecion to visual Basic

I am trying to setup the connection to a Mysql database. However I am getting a user error saying that:
WindowsApplication1.vshost.exe Error: 0 : Access denied for user 'Root'#'myiphere' (using password: YES)
A first chance exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll
I have used this....
GRANT ALL PRIVILEGES ON permissionsex.* TO root#'%' IDENTIFIED BY 'password';
But the error is still there.
In your error message I can see you're using the username Root but you granted rights to root. Mind the lower-case versus upper-case r.

MySQL access denied 1045 error

I'm getting a very strange error, I've created a user 'testuser' with the following credentials:
CREATE USER 'testuser'#'%' IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON *.* TO 'testuser'#'%';
FLUSH PRIVILEGES;
I have also modified my /etc/mysql/my.cnf not to bind to any single address. (Which afaik should accept connections from anywhere?) And restarted mysql.
And I can connect locally no problem.
I am running inside a virtual box on ubunutu.
Trying to connect from my windows machine, gives me MySQL error number 1045 Access denied for user 'testuser'#'192.168.0.22'.
I'm confident that it's not a networking problem as changing the host or port gives a different error "Cannot connect to the specified instance"
Logging in as root and looking at the users table - all looks as expected. (Single row, '%' for host and all permissions set.)
I've been banging my head against the wall all afternoon... can anyone suggest any other possible causes for this error?
Thanks for any help.
Run the GRANT statement with the IDENTIFIED BY:
GRANT ALL PRIVILEGES ON *.* TO 'testuser'#'%' IDENTIFIED BY '123456';