When I type show grants for user in mysql
Then the sytem showed:
| GRANT USAGE ON *.* TO ''#'%' IDENTIFIED BY PASSWORD '*1E80DD016234830553A761E48526725559582391' |
| GRANT ALL PRIVILEGES ON `mydatabase`.`mytable` TO 'user'#'%'
So I typed
grant all privileges on *.* to 'user'#'%' identified by 'passwd';
Then the systemed showed
GRANT ALL PRIVILEGES ON *.* TO 'user'#'%' IDENTIFIED BY PASSWORD '*EC75E3374932E7506AB7858A3B026E93FB8ED3DF'
GRANT ALL PRIVILEGES ON `mydatabase`.`mytable` TO 'user'#'%'
Why I set the password for user but there are two phenomenom:
the hash code changed but my passwd secret didn't show in the table.
mysql -u user it can log in to the server but mysql -u user -p then showed access denied?
Related
Normally, I use host "localhost". But now I wish to allow MySQL Workbench to access. Workbench is located on a Windows PC with IP 10.x.x.x, and MySql is located on 10.y.y.y. I've tried the following to no avail. How is this accomplished?
CREATE USER 'myUserName'#'10.%' IDENTIFIED BY 'myPassword';
GRANT ALL PRIVILEGES ON * . * TO 'myUserName'#'10.%';
This is what phpMyAdmin displays when exporting the users:
# Privileges for `myUserName`#`10%`
GRANT ALL PRIVILEGES ON *.* TO 'myUserName'#'10%' IDENTIFIED BY PASSWORD '*xxx';
# Privileges for `myUserName`#`10.%`
GRANT ALL PRIVILEGES ON *.* TO 'myUserName'#'10.%' IDENTIFIED BY PASSWORD '*xxx';
# Privileges for `myUserName`#`localhost`
GRANT ALL PRIVILEGES ON *.* TO 'myUserName'#'localhost' IDENTIFIED BY PASSWORD '*xxx' WITH GRANT OPTION;
Is it possible to give grant to user by another user? I've created user with full privileges:
CRETAE USER test#localhost IDENTIFIED BY 'test';
GRANT ALL ON *.* TO test#localhost;
GRANT CREATE USER ON *.* TO test#localhost;
FLUSH PRIVILEGES;
But when I tried to give privileges to another user using user 'test' It is written "Access denied to user test#localhost for table 'x'"
Updated: I found the way by edditing Grant_priv mysql.user is there any syntax for that?
The syntax is WITH GRANT OPTION.
CREATE USER test#localhost IDENTIFIED BY 'test';
GRANT ALL ON *.* TO test#localhost WITH GRANT OPTION;
...
I have created user and grant all permissions, but still not able to connect to the sql using it. Could someone kindly help resolving this?
Steps followed
mysql --user=root mysql;
CREATE USER 'db_user'#'%' IDENTIFIED BY 'password';
CREATE USER 'db_user'#'localhost' IDENTIFIED BY 'password';
CREATE USER 'db_user'#'hostname' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'db_user'#'%' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'db_user'#'localhost' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'db_user'#'hostname' WITH GRANT OPTION;
When I try to connect like
mysql -u db_user -ppassword -h 'hostname'
I get this error
ERROR 1045 (28000): Access denied for user 'db_user'#'hostname' (using password: YES)
MariaDB [(none)]> show grants for db_user#'hostname';
GRANT ALL PRIVILEGES ON *.* TO 'db_user'#'hostname' IDENTIFIED BY PASSWORD '*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19' WITH GRANT OPTION
1 row in set (0.00 sec)
What is it missing that it is not letting to connect?
Can you confirm again that the hostname is the hostname of the local host?
Can you try these.
DROP USER 'db_user'#'localhost';
DROP USER 'db_user'#'%';
DROP USER 'db_user'#'hostname';
GRANT ALL PRIVILEGES ON *.* TO 'db_user'#'localhost' IDENTIFIED BY PASSWORD '*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'db_user'#'%' IDENTIFIED BY PASSWORD '*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'db_user'#'hostname' IDENTIFIED BY PASSWORD '*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19' WITH GRANT OPTION;
mysql -u db_user -ppassword -h `hostname`
I type the commands below:
mysql –u root -p
Grant all privileges on *.* to root#”%” identified by “rootpassword” with grant option;
Grant all privileges on mysitedb.* to root#localhost;
then the server crashed:
Could not establish database connection. Please check the username,
password and hostname in the config file, and if necessary set up the
appropriate MySQL user and privileges.
change the grand statement in to below one, then solved:
mysql –u root -p
Grant all privileges on *.* to root#”%” identified by “rootpassword” with grant option;
Grant all privileges on mysitedb.* to root#localhost identified by “rootpassword” with grant option;
After executing the following mysql statement to create database and giving privileges to user can't access mysql
create database my_db;
GRANT ALL PRIVILEGES ON my_db.* TO 'user'#'%' IDENTIFIED BY 'mypasswd';
GRANT SELECT ON my_db.* TO 'user'#'%' IDENTIFIED BY 'mypasswd';
FLUSH PRIVILEGES;
mysql -u user -p mypasswd drops me
Access denied for user 'user'#'localhost'
You need to give privileges separately for user to connect from localhost. % will not work.
`GRANT ALL PRIVILEGES ON my_db.* TO 'user'#'localhost' IDENTIFIED BY 'mypasswd';
GRANT SELECT ON my_db.* TO 'user'#'localhost' IDENTIFIED BY 'mypasswd';`
There is no space between -p and your password.
As you granted rights only for the database my_db, add the db also to connect directly to it.
mysql -u user -pmypasswd my_db
I tried this:
GRANT ALL ON my_db.* TO 'user'#'%' IDENTIFIED BY 'mypasswd';
FLUSH PRIVILEGES;
And afterwards
./mysql -uuser -pmypasswd
worked ok for me.
If it doesn't, try with localhost:
GRANT ALL ON my_db.* TO 'user'#'localhost' IDENTIFIED BY 'mypasswd';
FLUSH PRIVILEGES;