Root account wont work in MySQL - mysql

I am logged in as root in my MySQL database. I try to run the following commands:
mysql> GRANT ALL ON *.* TO 'root'#'%'
-> IDENTIFIED BY '[password]'
-> WITH GRANT OPTION;
ERROR 1045 (28000): Access denied for user 'root'#'%' (using password: YES)
mysql>
I get the following error:
ERROR 1045 (28000): Access denied for user 'root'#'%' (using password: YES)
Im assuming my root user isnt set up correctly. Any ideas?
Edit
mysql> show grants for root
-> ;
+-----------------------------------------------------------------------------------------------------+
| Grants for root#% |
+-----------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'root'#'%' IDENTIFIED BY PASSWORD '*738393F115A47ACE272D98F4719B8491A2B8296F' |
| GRANT ALL PRIVILEGES ON `sometable`.* TO 'root'#'%' WITH GRANT OPTION |
| GRANT ALL PRIVILEGES ON `Test`.* TO 'root'#'%' WITH GRANT OPTION |
+-----------------------------------------------------------------------------------------------------+
3 rows in set (0.00 sec)

You might be logged into the database with an account named root, but the account you are in as does not have the correct privileges.
mysql> select user();
And follow that up with a:
mysql> select * from mysql.user\G
Look for the user and host columns to match exactly as the output. Look for grant_priv and it needs to say Y. More than likely there is additional root accounts without the grant_priv.
mysql> select * from mysql.user\G
*************************** 1. row ***************************
Host: localhost
User: root
Password: xxxxxxxxxxxxxxx
Select_priv: Y
Insert_priv: Y
Update_priv: Y
Delete_priv: Y
Create_priv: Y
Drop_priv: Y
Reload_priv: Y
Shutdown_priv: Y
Process_priv: Y
File_priv: Y
Grant_priv: Y
References_priv: Y
Index_priv: Y
Alter_priv: Y
Show_db_priv: Y
Super_priv: Y
Create_tmp_table_priv: Y
Lock_tables_priv: Y
Execute_priv: Y
Repl_slave_priv: Y
Repl_client_priv: Y
Create_view_priv: Y
Show_view_priv: Y
Create_routine_priv: Y
Alter_routine_priv: Y
Create_user_priv: Y
Event_priv: Y
Trigger_priv: Y
ssl_type:
ssl_cipher:
x509_issuer:
x509_subject:
max_questions: 0
max_updates: 0
max_connections: 0
max_user_connections: 0

When I enter the select * from mysql.user\G command, I get : ERROR 1142 (42000): SELECT command denied to user 'root'#'localhost' for table 'user' ERROR: No query specified
This means you're not logged in as 'root'#'%'. You're logged in as 'root'#'localhost', which are two different users. If you run SELECT USER(); as mentioned above, it will likely show you 'root'#'localhost'.
If you are logged in as 'root'#'localhost', you are logging in via local socket. Logging in through a TCP connection will get you access as 'root'#'%', which will then give you access to change grants based on the output you listed initially. To do so, login with:
mysql -u $user -p $pass -h 127.0.0.1

Related

I've tried any way. SUPER PRIVILEGE CANNOT BE GRANTED I tried set log_bin_trust_function_creators

I tried
mysql> SHOW GLOBAL VARIABLES LIKE 'log_bin_trust_function_creators';
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| log_bin_trust_function_creators | ON |
+---------------------------------+-------+
1 row in set (0.00 sec)
You can see that it is well set up.
Then it restarted the RDS.
The database has been refreshed several times.
In addition, the following can be identified:
mysql> SELECT * FROM mysql.user WHERE User='new_root' and Host='%'\G
*************************** 1. row ***************************
Host: %
User: new_root
Select_priv: Y
Insert_priv: Y
Update_priv: Y
Delete_priv: Y
Create_priv: Y
Drop_priv: Y
Reload_priv: Y
Shutdown_priv: N
Process_priv: Y
File_priv: N
Grant_priv: Y
References_priv: Y
Index_priv: Y
Alter_priv: Y
Show_db_priv: Y
Super_priv: N
Create_tmp_table_priv: Y
Lock_tables_priv: Y
Execute_priv: Y
Repl_slave_priv: Y
Repl_client_priv: Y
Create_view_priv: Y
Show_view_priv: Y
Create_routine_priv: Y
Alter_routine_priv: Y
Create_user_priv: Y
Event_priv: Y
Trigger_priv: Y
Create_tablespace_priv: N
ssl_type:
ssl_cipher:
x509_issuer:
x509_subject:
max_questions: 0
max_updates: 0
max_connections: 0
max_user_connections: 0
plugin: mysql_native_password
authentication_string: *5EDA56336D7A85D9D6FC7EEBFE91E063ACD5A87E
password_expired: N
password_last_changed: 2020-03-12 06:25:00
password_lifetime: NULL
account_locked: N
1 row in set (0.00 sec)
mysql> GRANT ALL privileges ON *.* TO 'new_root'#'%' IDENTIFIED BY 'password';
ERROR 1045 (28000): Access denied for user 'new_root'#'%' (using password: YES)
mysql> UPDATE mysql.user SET Super_Priv='Y' WHERE user='new_root' AND host='%';
ERROR 1644 (45000): SUPER PRIVILEGE CANNOT BE GRANTED
mysql> SET GLOBAL time_zone = 'Asia/Seoul';
ERROR 1227 (42000): Access denied; you need (at least one of) the SUPER privilege(s) for this operation
I finally tried to change global time.
Only hopeless emotions soar.
What's piled up on the stream had a lot of relevant information, but I don't know if my search is poor or unusual.
I stayed awake for five hours to change this global time.
Can you help me? I'm very, very tired.
My mysql version is...
mysql> SELECT VERSION();
+------------+
| VERSION() |
+------------+
| 5.7.26-log |
+------------+
1 row in set (0.00 sec)
I solved.
If you use RDS, it doesn't seem like you have full authority like localhost.
I solved the problem by changing the time_zone in the parameter group, instead of the original attempt of using SET GLOBAL time_zone = 'Asia/Seoul'.

Cannot remotely connect to mysql server in a container

I've set up standard mysql container with one user. Container resides on my server. I try to connect to this server from my laptop. Connection works via MySql-workbench. But connection via this command:
mysql -u user -h <my-server-ip> -p
gives me following error:
ERROR 1045 (28000): Access denied for user 'user'#'<my_laptops_ip>' (using password: YES)
I've manually connected to this container, connected to mysql via root, and created new account like so:
CREATE USER prodigy#'%' identified BY "passwd";
CREATE USER prodigy#'<my_laptops_ip>' IDENTIFIED BY "passwd";
GRANT ALL PRIVILEGES ON *.* TO 'prodigy'#'%';
GRANT ALL PRIVILEGES ON *.* TO 'prodigy'#'%';
Sadly still the same error when trying to connect.
I've made sure i type correct password.
Where can I go from here to find answer?
mysql.user table for user i'm trying to connect:
Select_priv: Y
Insert_priv: Y
Update_priv: Y
Delete_priv: Y
Create_priv: Y
Drop_priv: Y
Reload_priv: Y
Shutdown_priv: Y
Process_priv: Y
File_priv: Y
Grant_priv: N
References_priv: Y
Index_priv: Y
Alter_priv: Y
Show_db_priv: Y
Super_priv: Y
Create_tmp_table_priv: Y
Lock_tables_priv: Y
Execute_priv: Y
Repl_slave_priv: Y
Repl_client_priv: Y
Create_view_priv: Y
Show_view_priv: Y
Create_routine_priv: Y
Alter_routine_priv: Y
Create_user_priv: Y
Event_priv: Y
Trigger_priv: Y
Create_tablespace_priv: Y
ssl_type:
ssl_cipher:
x509_issuer:
x509_subject:
max_questions: 0
max_updates: 0
max_connections: 0
max_user_connections: 100
plugin: caching_sha2_password
ofsHs4*.U2TDbbZEoghVM2ots1dgBYPr5mCsv2mTBXNDwwaEJxA.
password_expired: N
password_last_changed: 2019-08-09 16:24:06
password_lifetime: NULL
account_locked: N
Create_role_priv: Y
Drop_role_priv: Y
Password_reuse_history: NULL
Password_reuse_time: NULL
Password_require_current: NULL
User_attributes: NULL
You are talking about 'user'#'my_laptops_ip' connection? But you creating a 'prodigy' user.

Xampp/ Lampp Mysql Terminal acces ERROR 1045 (28000)

install on Ubuntu 16.04 LTE Xampp (lampp) all good It Works:
# ~ $ Sudo / opt / lampp / lampp status
Version: XAMPP for Linux 5.6.20-0
Apache is running.
MySQL is running.
ProFTPD is running.
But when I want to enter the TERMINAL has mysql:
#:~$ mysql -u root
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
#~$ sudo mysql -u root
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
#~$ sudo mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
I have not defined a password, I entered as password: password
Can you help me ?
Try: mysql -u root -p
It will ask password next line
The default root password is blank (i.e. empty) not root. So you can just log in as:
mysql -u root
You should obviously change your root password after installation
mysqladmin -u root password [newpassword]
i do that:
sudo /etc/init.d/mysql stop
sudo mysqld_safe --skip-grant-tables &
mysql -uroot
use mysql;
mysql> select * from user \G
*************************** 1. row ***************************
Host: localhost
User: admin
Select_priv: Y
Insert_priv: Y
Update_priv: Y
Delete_priv: Y
Create_priv: Y
Drop_priv: Y
Reload_priv: Y
Shutdown_priv: Y
Process_priv: Y
File_priv: Y
Grant_priv: Y
References_priv: Y
Index_priv: Y
Alter_priv: Y
Show_db_priv: Y
Super_priv: Y
Create_tmp_table_priv: Y
Lock_tables_priv: Y
Execute_priv: Y
Repl_slave_priv: Y
Repl_client_priv: Y
Create_view_priv: Y
Show_view_priv: Y
Create_routine_priv: Y
Alter_routine_priv: Y
Create_user_priv: Y
Event_priv: Y
Trigger_priv: Y
Create_tablespace_priv: Y
ssl_type:
ssl_cipher:
x509_issuer:
x509_subject:
max_questions: 0
max_updates: 0
max_connections: 0
max_user_connections: 0
plugin: auth_socket
authentication_string:
password_expired: N
password_last_changed: 2016-04-27 20:49:21
password_lifetime: NULL
account_locked: N
*************************** 2. row ***************************
Host: localhost
User: mysql.sys
Select_priv: N
Insert_priv: N
Update_priv: N
Delete_priv: N
Create_priv: N
Drop_priv: N
Reload_priv: N
Shutdown_priv: N
Process_priv: N
File_priv: N
Grant_priv: N
References_priv: N
Index_priv: N
Alter_priv: N
Show_db_priv: N
Super_priv: N
Create_tmp_table_priv: N
Lock_tables_priv: N
Execute_priv: N
Repl_slave_priv: N
Repl_client_priv: N
Create_view_priv: N
Show_view_priv: N
Create_routine_priv: N
Alter_routine_priv: N
Create_user_priv: N
Event_priv: N
Trigger_priv: N
Create_tablespace_priv: N
ssl_type:
ssl_cipher:
x509_issuer:
x509_subject:
max_questions: 0
max_updates: 0
max_connections: 0
max_user_connections: 0
plugin: mysql_native_password
authentication_string: *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE
password_expired: N
password_last_changed: 2016-09-14 09:06:40
password_lifetime: NULL
account_locked: Y
*************************** 3. row ***************************
Host: localhost
User: debian-sys-maint
Select_priv: Y
Insert_priv: Y
Update_priv: Y
Delete_priv: Y
Create_priv: Y
Drop_priv: Y
Reload_priv: Y
Shutdown_priv: Y
Process_priv: Y
File_priv: Y
Grant_priv: Y
References_priv: Y
Index_priv: Y
Alter_priv: Y
Show_db_priv: Y
Super_priv: Y
Create_tmp_table_priv: Y
Lock_tables_priv: Y
Execute_priv: Y
Repl_slave_priv: Y
Repl_client_priv: Y
Create_view_priv: Y
Show_view_priv: Y
Create_routine_priv: Y
Alter_routine_priv: Y
Create_user_priv: Y
Event_priv: Y
Trigger_priv: Y
Create_tablespace_priv: Y
ssl_type:
ssl_cipher:
x509_issuer:
x509_subject:
max_questions: 0
max_updates: 0
max_connections: 0
max_user_connections: 0
plugin: mysql_native_password
authentication_string: *5AE72AD4B851F8C8C59B1A81B9441D6F274D066B
password_expired: N
password_last_changed: 2016-04-27 00:23:17
password_lifetime: NULL
account_locked: N
*************************** 4. row ***************************
Host: localhost
User: phpmyadmin
Select_priv: N
Insert_priv: N
Update_priv: N
Delete_priv: N
Create_priv: N
Drop_priv: N
Reload_priv: N
Shutdown_priv: N
Process_priv: N
File_priv: N
Grant_priv: N
References_priv: N
Index_priv: N
Alter_priv: N
Show_db_priv: N
Super_priv: N
Create_tmp_table_priv: N
Lock_tables_priv: N
Execute_priv: N
Repl_slave_priv: N
Repl_client_priv: N
Create_view_priv: N
Show_view_priv: N
Create_routine_priv: N
Alter_routine_priv: N
Create_user_priv: N
Event_priv: N
Trigger_priv: N
Create_tablespace_priv: N
ssl_type:
ssl_cipher:
x509_issuer:
x509_subject:
max_questions: 0
max_updates: 0
max_connections: 0
max_user_connections: 0
plugin: mysql_native_password
authentication_string:
password_expired: N
password_last_changed: 2016-04-27 18:11:46
password_lifetime: NULL
account_locked: N
4 rows in set (0,00 sec)
if I want to do this :
mysql> update user set password=PASSWORD("newpw") where User='root';
ERROR 1054 (42S22): Unknown column 'password' in 'field list'
mysql> flush privileges;
Query OK, 0 rows affected (0,00 sec)
the instructions I found on a forum :
sudo /etc/init.d/mysql stop
sudo mysqld_safe --skip-grant-tables &
mysql -uroot
use mysql;
update user set password=PASSWORD("newpw") where User='root';
flush privileges;
quit
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
https://ubuntuforums.org/showthread.php?t=2325339
OR I can for example delete the mysql totally, then I reinstall the terminal? and after uplode my database.sql
My MySQL also had the same starting problem, it doesn't let me logging. So I used:
mysqladmin.exe -u root password <newpassword>
Than it worked!
So I went to the file config.inc.php and changed to the new password, I've just set, and restarted my xampp panel.
So I used the command:
mysql -u root -p
And typed my new password and worked!

Grant user access denied in mysql

i have connected to server with my workbench , and see all databases on it , but i cant see its tables.
could not be fetched
hence i have logged in mysql server by root user and create a new user in user table in mysql database , after granting access to this user i get following error :
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
how can solve this problem?
this is my root user informations :
Host: 127.0.0.1
User: root
Password:
Select_priv: Y
Insert_priv: Y
Update_priv: Y
Delete_priv: Y
Create_priv: Y
Drop_priv: Y
Reload_priv: Y
Shutdown_priv: Y
Process_priv: Y
File_priv: Y
Grant_priv: Y
References_priv: Y
Index_priv: Y
Alter_priv: Y
Show_db_priv: Y
Super_priv: Y
Create_tmp_table_priv: Y
Lock_tables_priv: Y
Execute_priv: Y
Repl_slave_priv: Y
Repl_client_priv: Y
Create_view_priv: Y
Show_view_priv: Y
Create_routine_priv: Y
Alter_routine_priv: Y
Create_user_priv: Y
Event_priv: Y
Trigger_priv: Y
ssl_type:
ssl_cipher:
x509_issuer:
x509_subject:
max_questions: 0
max_updates: 0
max_connections: 0
max_user_connections: 0
You will need to grant that user to perform actions , Please use below query :
GRANT INSERT, SELECT, DELETE, UPDATE ON database.* TO 'user'#'localhost' IDENTIFIED BY 'password';
Most Of the time this error occurs due to connection problem where either user name or password went wrong in the connection object and we starts assuming that we don`t have enough privileges, so first of all please make sure that your connection objects has valid user name and password

On Mac command-line, how to execute a SQL statement in file foo.sql and export result in tab separated form into another file?

On Mac command-line,
$ sql -u foo -pbar db -B -e "SELECT * FROM t" > output.txt
requires entering the command inline.
How to execute a SQL statement in file foo.sql and still export result in tab separated form into another file?
EDIT
When I do
mysql -h localhost -u foo -pbar db -B -e "SELECT * FROM t WHERE x='{}' LIMIT 2 INTO OUTFILE '../o.tsv';"
I got error
ERROR 1045 (28000) at line 1: Access denied for user 'foo'#'localhost' (using password: YES)
But strangely,
mysql -h localhost -u foo -pbar db
gives me mysql command prompt fine. Does using OUTFILE require user foo having a special previlege?
mysql> SELECT * FROM user WHERE User='foo'\G
*************************** 1. row ***************************
Host: localhost
User: foo
Password: *A5DB2D927D6DF94DA5E1CE4B2AEAAB4D8304EA
Select_priv: N
Insert_priv: N
Update_priv: N
Delete_priv: N
Create_priv: N
Drop_priv: N
Reload_priv: N
Shutdown_priv: N
Process_priv: N
File_priv: N
Grant_priv: N
References_priv: N
Index_priv: N
Alter_priv: N
Show_db_priv: N
Super_priv: N
Create_tmp_table_priv: N
Lock_tables_priv: N
Execute_priv: N
Repl_slave_priv: N
Repl_client_priv: N
Create_view_priv: N
Show_view_priv: N
Create_routine_priv: N
Alter_routine_priv: N
Create_user_priv: N
ssl_type:
ssl_cipher:
x509_issuer:
x509_subject:
max_questions: 0
max_updates: 0
max_connections: 0
max_user_connections: 0
1 row in set (0.01 sec)
Does:
sql -u foo -pbar db -B -e `cat foo.sql` > output.txt
work?
After setting File_priv to true, it works.
Use SELECT [text of query] INTO OUTFILE [filename]. Here's the documentation. If the format isn't exactly what you want, see the load data infile syntax for formatting commands you can specify after the filename.