Centos7 64bit 웹서버 만들기-mysql설치 CAP4

by 조쉬 posted Jul 17, 2015
?

단축키

Prev이전 문서

Next다음 문서

ESC닫기

크게 작게 위로 아래로 댓글로 가기 인쇄

/*---------------------------------------------------------------------------------------*/

mysql을 설치하자.. 요건 좀 어려울라나~ 우선 고고~~~

그런데 이상하다. 아래처럼 설치하니 뭔가 이상함  항상 쓰던 mysql 접속에서

...그래서 우선 삭제 요점은 맨밑에

/*---------------------------------------------------------------------------------------*/

[root@localhost ~]# yum -y install mysql 

  --생략--  
  perl-podlators.noarch 0:2.5.1-3.el7                     perl-threads.x86_64 0:1.87-4.el7                  
  perl-threads-shared.x86_64 0:1.43-6.el7               

Complete!
 [root@localhost ~]# yum erase mysql
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package mariadb.x86_64 1:5.5.41-2.el7_0 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================
 Package                 Arch                   Version                          Repository             Size
=======================================================================================================
Removing:
 mariadb                 x86_64                 1:5.5.41-2.el7_0                 @base                  49 M

Transaction Summary
=======================================================================================================
--생략--

  Erasing    : 1:mariadb-5.5.41-2.el7_0.x86_64                                                           1/1
  Verifying  : 1:mariadb-5.5.41-2.el7_0.x86_64                                                           1/1

Removed:
  mariadb.x86_64 1:5.5.41-2.el7_0                                                                           

Complete!

/*---------------------------------------------------------------------------------------*/

mariadb?? 이게 뭐지.. 검색해보니 centos7에서 mysql은 다운받아서 써야됨 젠장

그럼 다운받아주지..아래 그림설명해놔야징..

/*---------------------------------------------------------------------------------------*/

/*---------------------------------------------------------------------------------------*/

mysql 홈페이지 다운로드->yum  들어가서 centos7이니까 linux7 다운로드 하자

그담에 받은 패키지를 올려볼까~~ 경로는 맘대로 /usr/etc 요기에 넣었당. 

/*---------------------------------------------------------------------------------------*/

/*---------------------------------------------------------------------------------------*/

자 올렸다.. 올리는 방법은 툴을 이용하는게 좋을듯. 하는김에 툴도 올려놓자 sshclient 아주 자주 사용하니까

그럼 다시 설치 시작

/*---------------------------------------------------------------------------------------*/

[root@localhost ~]# yum -y install /usr/etc/mysql-community-release-el7-5.noarch.rpm
Loaded plugins: fastestmirror
Examining /usr/etc/mysql-community-release-el7-5.noarch.rpm: mysql-community-release-el7-5.noarch
Marking /usr/etc/mysql-community-release-el7-5.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-release.noarch 0:el7-5 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================
 Package                       Arch         Version        Repository                                   Size
=======================================================================================================
Installing:
 mysql-community-release       noarch       el7-5          /mysql-community-release-el7-5.noarch       4.3 k

Transaction Summary
=======================================================================================================
Install  1 Package

Total size: 4.3 k
Installed size: 4.3 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mysql-community-release-el7-5.noarch                                              1/1
  Verifying  : mysql-community-release-el7-5.noarch                                             1/1

Installed:
  mysql-community-release.noarch 0:el7-5                                                                    

Complete!
[root@localhost ~]# yum -y install mysql-community-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: data.nicehosting.co.kr
 * extras: data.nicehosting.co.kr
 * updates: data.nicehosting.co.kr
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.6.24-3.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================
 Package                          Arch             Version                 Repository                   Size
=======================================================================================================
Installing:
 mysql-community-server           x86_64           5.6.24-3.el7            mysql56-community            58 M

Transaction Summary
=======================================================================================================
Install  1 Package

Total download size: 58 M
Installed size: 244 M
Downloading packages:
mysql-community-server-5.6.24-3.el7.x86_64.rpm                                        |  58 MB  00:00:09    
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mysql-community-server-5.6.24-3.el7.x86_64                                            1/1
  Verifying  : mysql-community-server-5.6.24-3.el7.x86_64                                           1/1

Installed:
  mysql-community-server.x86_64 0:5.6.24-3.el7                                                              

Complete!
[root@localhost ~]# systemctl start mysqld  <-(요건 뭐 mysql 실행하는거야) 

[root@localhost ~]# systemctl enable mysqld <-(요것도 뭐 당연히 해야 재부팅시 자동으로 올라온다)

/*---------------------------------------------------------------------------------------*/

여까지 했으면 재부팅 해보는것도 나쁘지 않을듯. 정말 작동되는지도 확인해보고..

그럼 이제 작동하는지 확인해 볼까~~! 시작.. 

/*---------------------------------------------------------------------------------------*/

[root@localhost ~]# mysql -u root -p <-(처음에는 비밀번호가 설정되어있지 않으니 설정해야 겠지)
Enter password:  <-요기서 엔터 치면 바로 넘어감
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.24 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

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> 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> update user set password=password('1111') where user='root';

(쿼리문 설명 user 테이블에서  root라는 유저를 찾아서 패스워드를 1111로 업데이트 해라.)

Query OK, 4 rows affected (0.01 sec)
Rows matched: 4  Changed: 4  Warnings: 0

mysql> flush privileges; <-(요거 해줘야 패스워드 업데이트 된다.)
Query OK, 0 rows affected (0.00 sec) 

mysql> quit <- (mysql query 종료 exit<-요명령도 됨)
Bye
[root@localhost ~]# mysql -u root -p
Enter password: <-(이제 아까 넣었던 패스워드 입력하고 엔터)
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.6.24 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

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>  

/*---------------------------------------------------------------------------------------*/

이제 몇가지 mysql query문을 해볼까~~ 자 해보자 위에문 연결하여 계속간다. 

/*---------------------------------------------------------------------------------------*/

mysql> show databases;
+--------------------+
| Database                    

+--------------------+
| information_schema      
| mysql                         
| performance_schema    
+--------------------+
3 rows in set (0.00 sec)

mysql>

/*---------------------------------------------------------------------------------------*/

위에 3개의 db는 직접적으로 사용하지 않는다. 그런데 내용이 보고싶다면??

한번 볼까? 그럼 아까 수정했던 mysql db를 한번 보자 

/*---------------------------------------------------------------------------------------*/

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> show tables;
+---------------------------+
| Tables_in_mysql

+---------------------------+
| columns_priv             
| db                       
| event                    
| func                     
| general_log            
| help_category         

| help_keyword             
| help_relation            
| help_topic               
| innodb_index_stats       
| innodb_table_stats       
| ndb_binlog_index         
| plugin                   
| proc                     
| procs_priv               
| proxies_priv             
| servers                  
| slave_master_info        
| slave_relay_log_info     
| slave_worker_info        
| slow_log                 
| tables_priv              
| time_zone                
| time_zone_leap_second    
| time_zone_name           
| time_zone_transition     
| time_zone_transition_type
| user                     
+---------------------------+
28 rows in set (0.00 sec)

mysql> desc user;
+------------------------+-----------------------------------+------+-----+-----------------------+-------+
| Field                  | Type                              | Null | Key | Default               | Extra |
+------------------------+-----------------------------------+------+-----+-----------------------+-------+
| Host                   | char(60)                          | NO   | PRI |                       |       |
| User                   | char(16)                          | NO   | PRI |                       |       |
| Password               | char(41)                          | NO   |     |                       |       |
| Select_priv            | enum('N','Y')                     | NO   |     | N                     |       |
| Insert_priv            | enum('N','Y')                     | NO   |     | N                     |       |
| Update_priv            | enum('N','Y')                     | NO   |     | N                     |       |
| Delete_priv            | enum('N','Y')                     | NO   |     | N                     |       |
| Create_priv            | enum('N','Y')                     | NO   |     | N                     |       |
| Drop_priv              | enum('N','Y')                     | NO   |     | N                     |       |
| Reload_priv            | enum('N','Y')                     | NO   |     | N                     |       |
| Shutdown_priv          | enum('N','Y')                     | NO   |     | N                     |       |
| Process_priv           | enum('N','Y')                     | NO   |     | N                     |       |
| File_priv              | enum('N','Y')                     | NO   |     | N                     |       |
| Grant_priv             | enum('N','Y')                     | NO   |     | N                     |       |
| References_priv        | enum('N','Y')                     | NO   |     | N                     |       |
| Index_priv             | enum('N','Y')                     | NO   |     | N                     |       |
| Alter_priv             | enum('N','Y')                     | NO   |     | N                     |       |
| Show_db_priv           | enum('N','Y')                     | NO   |     | N                     |       |
| Super_priv             | enum('N','Y')                     | NO   |     | N                     |       |
| Create_tmp_table_priv  | enum('N','Y')                     | NO   |     | N                     |       |
| Lock_tables_priv       | enum('N','Y')                     | NO   |     | N                     |       |
| Execute_priv           | enum('N','Y')                     | NO   |     | N                     |       |
| Repl_slave_priv        | enum('N','Y')                     | NO   |     | N                     |       |
| Repl_client_priv       | enum('N','Y')                     | NO   |     | N                     |       |
| Create_view_priv       | enum('N','Y')                     | NO   |     | N                     |       |
| Show_view_priv         | enum('N','Y')                     | NO   |     | N                     |       |
| Create_routine_priv    | enum('N','Y')                     | NO   |     | N                     |       |
| Alter_routine_priv     | enum('N','Y')                     | NO   |     | N                     |       |
| Create_user_priv       | enum('N','Y')                     | NO   |     | N                     |       |
| Event_priv             | enum('N','Y')                     | NO   |     | N                     |       |
| Trigger_priv           | enum('N','Y')                     | NO   |     | N                     |       |
| Create_tablespace_priv | enum('N','Y')                     | NO   |     | N                     |       |
| ssl_type               | enum('','ANY','X509','SPECIFIED') | NO   |     |                       |       |
| ssl_cipher             | blob                              | NO   |     | NULL                  |       |
| x509_issuer            | blob                              | NO   |     | NULL                  |       |
| x509_subject           | blob                              | NO   |     | NULL                  |       |
| max_questions          | int(11) unsigned                  | NO   |     | 0                     |       |
| max_updates            | int(11) unsigned                  | NO   |     | 0                     |       |
| max_connections        | int(11) unsigned                  | NO   |     | 0                     |       |
| max_user_connections   | int(11) unsigned                  | NO   |     | 0                     |       |
| plugin                 | char(64)                          | YES  |     | mysql_native_password |       |
| authentication_string  | text                              | YES  |     | NULL                  |       |
| password_expired       | enum('N','Y')                     | NO   |     | N                     |       |
+------------------------+-----------------------------------+------+-----+-----------------------+-------+
43 rows in set (0.00 sec)

mysql>  

/*---------------------------------------------------------------------------------------*/

너무 길어졌다. query문은 고만~

요점정리 하자.. 또 필요하거나 주석달일 생기면 계속업데이트 해놔야징... 

/*---------------------------------------------------------------------------------------*/

 1.  mysql.com에서 패키지 다운 받아서 /usr/etc에 저장
 2. [root@localhost ~]# yum -y install /usr/etc/mysql-community-release-el7-5.noarch.rpm

 3. [root@localhost ~]# yum -y install mysql-community-server
 4. [root@localhost ~]# systemctl start mysqld  <-(요건 뭐 mysql 실행하는거야) 

 5. [root@localhost ~]# systemctl enable mysqld <-(요것도 뭐 당연히 해야 재부팅시 자동으로 올라온다)

 6. [root@localhost ~]# mysql -u root -p mysql

 7. mysql> update user set password=password('알아서넣자') where user='root';

 8. mysql> flush privileges;

 9. mysql> exit
10.[root@localhost ~]#