how to import mysql database in wavemaker - mysql

While importing I am getting an error
Connection failed: SQLException: Access denied for user 'root'#'localhost' (using password: YES)
What could be the possible solution for this?

Here are my notes on the subject. I had the same issue and saved these notes for future use. There are two methods that I know of for creating users and setting permissions-- I hope they are helpful.
mysql> select password('12345');
+-------------------------+
| password('123456') |
+-------------------------+
| 2ff898e158cd0311 |
+-------------------------+
1 row in set (0.00 sec)
mysql> create user test identified by password '2ff898e158cd0311';
A) Expects #password to be a hash string 1 value:
GRANT ALL PRIVILEGES
ON `mydb` . * TO 'username'#'localhost' IDENTIFIED
BY
PASSWORD '#password';
Note the use of the PASSWORD keyword!
B) Expects #password to be a clear-text string value:
GRANT ALL PRIVILEGES
ON `mydb` . * TO 'username'#'localhost' IDENTIFIED
BY '#password';

Related

MySQL + Django / ERROR 1045 and CommandError

I configured MySQL as follows:
CREATE DATABASE IF NOT EXISTS foodb;
CREATE USER IF NOT EXISTS 'foo'#'localhost';
ALTER USER 'foo'#'localhost' IDENTIFIED BY 'qux';
GRANT ALL ON foodb.* to 'foo'#'localhost';
SHOW GRANTS FOR 'foo'#'localhost';
FLUSH PRIVILEGES;
SELECT user, host, authentication_string FROM mysql.user ORDER BY user, host;
When I run
python manage.py dbshell
I get the following error:
ERROR 1045 (28000): Access denied for user 'foo'#'localhost' (using password: YES)
CommandError: "mysql --user=foo --host=localhost foodb" returned non-zero exit status 1.
Also, this query
SHOW GRANTS for 'foo'#'localhost';
returns
+--------------------------------------------------------------+
| Grants for foo#localhost |
+--------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'foo'#'localhost' |
| GRANT ALL PRIVILEGES ON `foodb`.* TO 'foo'#'localhost' |
+--------------------------------------------------------------+
2 rows in set (0.00 sec)
Finally, switching user to root and the root account password works just fine. So I think the issue must be with the user permissions on MySQL itself.
What additional permissions does 'foo'#'localhost' need for this to work?

Privileges for CREATE table on MySQL, given all privileges

This is the user privileges:
GRANT USAGE ON *.* TO 'LMMXT'#'localhost' IDENTIFIED BY PASSWORD '*...'
GRANT ALL PRIVILEGES ON `LMMXT`.`*` TO 'LMMXT'#'localhost'
I can LOGIN with the user, USE Database, but always when I want CREATE TABLE:
# mysql -u LMMXT -p -h localhost
mysql> use LMMXT
Database changed
mysql> create table test;
ERROR 1142 (42000): CREATE command denied to user 'LMMXT'#'localhost' for table 'test'
And:
mysql> SELECT USER(),CURRENT_USER();
+---------------------+---------------------+
| USER() | CURRENT_USER() |
+---------------------+---------------------+
| LMMXT#localhost | LMMXT#localhost |
+---------------------+---------------------+
1 row in set (0.00 sec)
So, also I've tried with:
mysql> FLUSH PRIVILEGES;
User is set for host access from 'localhost' and '%'
I've seen other solutions on StackOverflow, but none works.
Thanks in advance
Try changing your grant statement to
GRANT ALL PRIVILEGES ON LMMXT.* TO 'LMMXT'#'localhost'
I'm not sure if the ` characters around the statement are causing a problem

ERROR 1396 (HY000): Operation DROP USER failed for 'user'#'localhost'

I have created a user in mysql. Now i want to delete the user ? How to do that? I am getting this error :
ERROR 1396 (HY000): Operation DROP USER failed for 'user'#'localhost'
I am using this command :
DROP USER 'user'#'localhost';
Its an amazon machine.
Thanks
It was because i created the user using command :
CREATE USER 'user'#'%' IDENTIFIED BY 'passwd';
and i was deleting it using :
drop user 'user'#'localhost';
and i should have used this command :
drop user 'user'#'%';
It is likely that the user you are trying to drop does not exist. You can confirm (or not) whether this is the case by running:
select user,host
from mysql.user
where user = '<your-user>';
If the user does exist then try running:
flush privileges;
drop user 'user'#'localhost';
Another thing to check is to make sure you are logged in as root user
If all else fails then you can manually remove the user like this:
delete from mysql.user
where user='<your-user>'
and host = 'localhost';
flush privileges;
How to solve problem like this:
mysql> drop user 'q10'#'localhost';
ERROR 1396 (HY000): Operation DROP USER failed for 'q10'#'localhost'
First:you should check what host of your user,such as:
mysql> select host,user from user;
+-----------+------+
| host | user |
+-----------+------+
| % | q10 |
| localhost | root |
| localhost | sy |
| localhost | tom |
+-----------+------+
if I drop user 'q10',the command is :
mysql> drop user 'q10'#'%';
Query OK, 0 rows affected (0.00 sec)
And if I drop user 'tom',the command as follow:
mysql> drop user 'tom'#'localhost';
Query OK, 0 rows affected (0.00 sec)
Try using 'user'#'localhost' without quotes:
DROP USER user#localhost;
It should work that way in MySQL 8. I also had that problem.
delete from mysql.user where user='user_name' and host = 'localhost';
flush privileges;
Working for me...

Creating a user without deleting, updating and altering privileges in MySQL

I have to provide direct access to my database to some users for auditing purposes, and should add a restriction to avoid that these new users don't have deleting, updating and altering privileges.
Just create a user and grant only SELECT privilege.
CREATE USER user_name#host_name identified by 'password';
GRANT SELECT ON db_name.* TO user_name#host_name;
To check what privileges a user has use
SHOW GRANTS FOR user_name#host_name;
and make sure that a user only has GRANT USAGE and GRANT SELECT ON db_name.*
Lets say I have my_db database with test table in it and I want to create a user with a name user1 who will be allowed to connect only from local host and will be able to read data from all tables in this database but won't be able to insert, change, and delete data.
mysql> create user user1#localhost identified by 'password';
Query OK, 0 rows affected (0.00 sec)
mysql> show grants for user1#localhost;
+--------------------------------------------------------------------------------------------------------------+
| Grants for user1#localhost |
+--------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'user1'#'localhost' IDENTIFIED BY PASSWORD '*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19' |
+--------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> grant select on my_db.* to user1#localhost;
Query OK, 0 rows affected (0.00 sec)
mysql> show grants for user1#localhost;
+--------------------------------------------------------------------------------------------------------------+
| Grants for user1#localhost |
+--------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'user1'#'localhost' IDENTIFIED BY PASSWORD '*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19' |
| GRANT SELECT ON `my_db`.* TO 'user1'#'localhost' |
+--------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
Now lets see what our user1 can and can't do
$ mysql -uuser1 -p
mysql> use mysql
ERROR 1044 (42000): Access denied for user 'user1'#'localhost' to database 'mysql'
mysql> use test
ERROR 1044 (42000): Access denied for user 'user1'#'localhost' to database 'test'
mysql> use my_db
Database changed
As you can see our user1 can only connect to my_db database.
Now let see what that user can do with data in table test (the only table in that database)
mysql> select * from test;
+------+
| id |
+------+
| 1 |
| 2 |
+------+
2 rows in set (0.00 sec)
mysql> insert into test values (3);
ERROR 1142 (42000): INSERT command denied to user 'user1'#'localhost' for table 'test'
mysql> delete from test where id = 1;
ERROR 1142 (42000): DELETE command denied to user 'user1'#'localhost' for table 'test'
mysql> update test set id = 10 where id = 1;
ERROR 1142 (42000): UPDATE command denied to user 'user1'#'localhost' for table 'test'
Again as you can the user can only select from the table.

MySQL: Grant Privileges followed by Flush Privileges has not effect, no error (logged in as root)

I and a teammember are stumped because commands to grant privileges to a remote user are failing, but with no error. The new user was successfully added to mysql.user using CREATE USER, but GRANT PRIVILEGES followed by FLUSH PRIVILEGES isn't affecting the grants table. Both these commands are supposed to say 'Query OK. 0 rows affected,' which they do. But then SHOW GRANTS doesn't show the new privileges, nor can we log in with that username from the specified remote ip. Can anyone explain the following behavior?
mysql> SELECT CURRENT_USER(); ///I'm definitely in as root user
+----------------+
| CURRENT_USER() |
+----------------+
| root#localhost |
+----------------+
1 row in set (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'myNewUser'#'remoteIP'; //grant to existing user
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> SHOW GRANTS;
| Grants for root#localhost
| GRANT ALL PRIVILEGES ON *.* TO 'root'#'localhost' IDENTIFIED BY PASSWORD '*////TakenOut///' WITH GRANT OPTION |
| GRANT PROXY ON ''#'' TO 'root'#'localhost' WITH GRANT OPTION
2 rows in set (0.00 sec)
I would expect a 3rd row with privileges for 'myNewUser'.
The SHOW GRANTS statement shows the grants for the current user. In your case, for root#localhost. So you shouldn't be expecting to see a third row with privileges for myNewUser.
Rather, query the mysql.user table...
SELECT * FROM mysql.user WHERE User = 'myNewUser'
I would verify that the password is set for 'myNewUser'#'remoteip'. (MySQL identifies a "user" by the combination of the username and the host. The user 'myNewUser'#'thisip' is a different user than 'myNewUser'#'thatip'.)
Also, we have this setting in our MySQL my.cnf files:
# Disable DNS Lookup (use IP addresses only)
skip-name-resolve
So we use IP addresses, rather than hostnames. (This avoids the connect problems that occur when DNS can't do a DNS reverse lookup from the IP address to get a hostname.)
http://dev.mysql.com/doc/refman/5.1/en/host-cache.html
Bottom line is that MySQL does a "reverse lookup" of an IP address to get a hostname. If it can't get a hostname for a given IP address, connections from the IP address will fail.