MySQL notes

From IdeaNet
Jump to navigationJump to search

change MySQL user password using mysql sql command

user@host:~$ mysql -u root -p
mysql> use mysql;
mysql> update user set password=PASSWORD("new_password") where user='username';
mysql> flush privileges;

list character encoding used for each database

mysql> select * from information_schema.SCHEMATA

list authorized pair (user,host)

mysql> select User,Host from mysql.user

delete user

mysql> DROP USER 'seismo'@'localhost';

string replacement

  • general form:
REPLACE(str,from_str,to_str)
  • example:
mysql> SELECT REPLACE('www.mysql.com', 'w', 'Ww');
-> 'WwWwWw.mysql.com'