Command for user in mysql

- Show user:
SELECT user FROM mysql.user;
or
SELECT user,host FROM mysql.user;
or
SELECT user,host,password FROM mysql.user;
or
SELECT host,user,authentication_string FROM mysql.user; 
 
- Show permission: 
SHOW GRANTS FOR 'root'@'localhost';
or 
SHOW GRANTS FOR CURRENT_USER;
or 
SHOW GRANTS FOR CURRENT_USER(); 

- Create user:
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
FLUSH PRIVILEGES;
 
- Show tables crash:
show table status where comment like '%crash%';
 
 Mysql User native password:

Here's the solution: (from the mysql command-line client)

# If you don't have a 127.0.0.1 equivalent user:  

CREATE USER 'root'@'127.0.0.1' IDENTIFIED WITH mysql_native_password BY 'password';  

# If you already have the user, reset its password:  

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';  

# Redo your grants on the 127.0.0.1 user:  

GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1'

FLUSH PRIVILEGES;

   

Post a Comment