본문 바로가기

DB&NoSQL/MySQL\MariaDB

mysql set user password

DB 추가

CREATE DATABASE database_name default CHARACTER SET UTF8mb4;

사용자 추가

// GRANT ALL PRIVILEGES ON database_name.* TO user_name@hostname IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON dbname.* TO username@localhost IDENTIFIED BY 'password';

// INSERT INTO mysql.user (host, user, password) VALUES ('hostname', 'username', password('password'));
// insert into 를 사용하기 위해서는 null을 허용하지 않는 필드를 모두 구성해야 합니다.

호스트 추가

GRANT ALL PRIVILEGES ON database_name.* TO 'root'@'xxx.xxx.xxx.%';

비밀번호 변경

mysql> SET PASSWORD FOR 'user'@'localhost' = PASSWORD('password')
[2019-11-12 18:15:42] [HY000][1287] 'SET PASSWORD FOR <user> = PASSWORD('<plaintext_password>')' is deprecated and will be removed in a future release. Please use SET PASSWORD FOR <user> = '<plaintext_password>' instead
[2019-11-12 18:15:42] completed in 40 ms
mysql> set password for 'user'@'localhost' = 'password'
[2019-11-12 18:16:13] completed in 24 ms