MySQL 을 설치한 후 별도의 설정을 하지 않으면 초기 패스워드(암호) 는 비어있게 된다. 이 경우 localhost의 root 접근에 암호를 걸어주어야한다. 순서는 다음과 같다.

mysql 접속


$ mysql -u root

mysql db 사용


mysql> use mysql;

현재 패스워드 설정 관련 내용 리스트


mysql> select host,user,authentication_string from user;

새로운 패스워드 설정


mysql> alter user 'root'@'localhost' identified with mysql_native_password by 'new_password_you_want';

만약 외부에서 들어오는 계정을 생성할 필요가 있다면

mysql> create user 'root'@'192.168.0.100' identified with mysql_native_password by 'new_password_you_want';