Programming/MySQL

MySQL - WSL2 Ubuntu 세팅

lee308812 2022. 8. 4. 22:27

1. sudo apt update

 

2. sudo apt install mysql-server

 

3. sudo mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: n
Please set the password for root here.

New password:

Re-enter new password:
 ... Failed! Error: SET PASSWORD has no significance for user 'root'@'localhost' as the authentication method used doesn't store authentication data in the MySQL server. Please consider using ALTER USER instead if you want to change authentication parameters.

4. sudo mysql - 종료 후, mysql 재실행

 

5. ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by 'mynewpassword';

 

완료

 

- 서비스 시작 : sudo service mysql start 후 (ps -ef | grep mysqld로 확인)

- 실행 : sudo mysql -uroot -p

lee308812@DESKTOP-OMFP9TN:~$ sudo service mysql start
 * Starting MySQL database server mysqld                                                                                                                                                                                                     su: warning: cannot change directory to /nonexistent: No such file or directory
                                                                                                                                                                                                                                      [ OK ]
lee308812@DESKTOP-OMFP9TN:~$ sudo mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.30-0ubuntu0.20.04.2 (Ubuntu)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>