MySQL

From WhyAskWhy.org Wiki
Revision as of 09:25, 21 February 2014 by Deoren (talk | contribs) (Adding MySQL page. Other tips should include creating accounts and setting privileges on a database)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Resetting the root user account

[1] [2] The safest approach is to add the statement containing the password to a file and run

mysqld_safe --init-file=/home/me/FILE &

followed by:

sudo /etc/init.d/mysql stop
sudo mysqld --skip-grant-tables &
mysql -u root mysql
UPDATE user SET Password=PASSWORD('YOURNEWPASSWORD') WHERE User='root'; FLUSH PRIVILEGES; exit;

Viewing privileges granted to a user

[3] [4]

  • select * from mysql.user;
    
    • Parse results by eye (not pretty)
  • SHOW GRANTS FOR username@ipaddress;
    
  • SHOW GRANTS;
    
    • For current user

References

  1. Set / Change / Reset the MySQL root password on Ubuntu Linux
  2. MySQL :: MySQL 5.0 Reference Manual :: C.5.4.1 How to Reset the Root Password
  3. How can I show user's privileges in MySQL?
  4. How to show user privileges on mysql