MySql 기본설치
Remark:
MySql 의 최신 버전 version: 8.0.23 을 설치해 보자.
1. Download the MySQL repositories
1 2 3 |
# sudo wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm |
2. Install MySQL packages
1 2 3 |
# sudo rpm -Uvh mysql80-community-release-el7-3.noarch.rpm |
3. Install MySQL
1 2 3 |
# sudo yum install mysql-server |
4. Start MySQL
1 2 3 |
# sudo systemctl start mysqld |
5. Start MySQL
1 2 3 |
# sudo systemctl status mysqld |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
# sudo systemctl status mysqld ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2021-01-19 11:19:30 KST; 2h 32min ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 3137 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 3214 (mysqld) Status: "Server is operational" CGroup: /system.slice/mysqld.service └─3214 /usr/sbin/mysqld |
5. MySQL Root User temporary root password check
1 2 3 |
# sudo grep 'password' /var/log/mysqld.log |
1 2 3 4 |
# sudo grep 'password' /var/log/mysqld.log 2021-01-19T02:18:21.839765Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: &12323232 |
6. Changing MySQL Root User Password
1 2 3 |
sudo mysql_secure_installation |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# sudo mysql_secure_installation Securing the MySQL server deployment. Enter password for user root: <span style="color: #ff6600;">&12323232</span> The existing password for the user account root has expired. Please set a new password. New password: 복잡하게조합 Re-enter new password: Estimated strength of the password: 100 Change the password for root ? ((Press y|Y for Yes, any other key for No) : y New password: Re-enter new password: Estimated strength of the password: 100 Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? (Press y|Y for Yes, any other key for No) : y Success. Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n ... skipping. By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y - Dropping test database... Success. - Removing privileges on test database... Success. Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y Success. All done! |
7. Root remote allow authority (root % )
IP 로 세팅하면 host mysql 로그인이 되지 않음
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 27 Server version: 8.0.23 MySQL Community Server - GPL Copyright (c) 2000, 2021, 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> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.01 sec) mysql> use mysql Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> select user,host from user; +------------------+-----------+ | user | host | +------------------+-----------+ | root | localhost | | | mysql.infoschema | localhost | | mysql.session | localhost | | mysql.sys | localhost | +------------------+-----------+ 4 rows in set (0.00 sec) mysql> update user set host='%' where user='root'; Query OK, 1 row affected (0.15 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select user,host from user; +------------------+-----------+ | user | host | +------------------+-----------+ | root | % | | mysql.infoschema | localhost | | mysql.session | localhost | | mysql.sys | localhost | +------------------+-----------+ 4 rows in set (0.00 sec) mysql> FLUSH PRIVILEGES; mysql> quit; |
8. Remote allow configuration (bind-address
)
1 2 3 |
# vi /etc/my.cnf |
1 2 3 4 5 6 |
# vi /etc/my.cnf # add line bind-address=0.0.0.0 |
9. Mysql Restart
1 2 3 |
# sudo systemctl restart mysqld |