-
CentOS7 mysql 설치하기LINUX 2017. 3. 22. 15:33반응형
이글은 CentOS Linux release 7.3.1611 (Core) 서버에서 작업되었습니다.
글 중간에 나오는 systemctl 명령어는 CentOS 7 부터 가능한 명령어로 , 6점대 버전에서는 도움이 되지 않습니다.
mysql 이설치가 되어있을때 , 버전이 나온다.
[root@cobuy-0884 ~]# mysql --version
mysql Ver 14.14 Distrib 5.1.69, for unknown-linux-gnu (x86_64) using readline 5.1
[root@cobuy-0884 ~]# rpm -qa | grep mysql
mysql-connector-odbc-5.1.5r1144-7.el6.x86_64
mysql-libs-5.1.73-3.el6_5.x86_64
설치가 되어있지 않을때 , mysql 명령어를 알수 없다고 나온다.
[root@cobuy-0938 ~]# mysql --version
-bash: mysql: command not found
[root@cobuy-0938 ~]# pm -qa | grep mysql
-bash: pm: command not found
방법 1. yum 을 이용한 간단한 설치
yum install mysql-server
// 하지만 CentOS 7 부터는 데이터베이스가 Mariadb 로 바뀌어서 yum 으로 바로 설치가 불가능하다.
// 이전 버전에서는 가능하다.
방법 2. 패키지로 직접설치!
https://opentutorials.org/module/1701/10229
(위 주소가 매우잘 설명되어있다.)
1. yum -y install http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
명령 실행
Complete! 명령이 나온다면 다음으로~
만약 안된다면 , 서버가 네트워크 설정이 되었는지 부터 확인해 봐야할듯 하다.
2. yum -y install mysql-community-server
명령 실행
Complete! 명령이 나온다면 다음으로~
3. systemctl start mysqld // mysql 시작
systemctl 에 대해서는
http://linux.systemv.pe.kr/centos-7-systemd-%EC%9D%B4%ED%95%B4%ED%95%98%EA%B8%B0/ <-- 에 잘 정리되어있다.
명령어 실행
좀 오래걸리지만, 잠시 기다리면 완료
4. systemctl enable mysqld // mysql 를 부팅시 자동으로 실행되게 설정
5. mysql 접속해보자!
mysql -u root -p
mysql
둘중 하나로 접속해보자
접속이 된다면 설치완료!
이제 좀더 확인,작업 해봐야할것이
1. mysql 서비스가 리부팅후 자동실행이 정상적으로 되고있는가.
2. mysql root 계정 패스워드설정 (리눅스 root / mysql root 패스워드는 다르다.)
3. DB 생성 - 및 쿼리 테스트 (이건 후에 ftp 계정을 생성후 , ftp 에서 mysql 접속을 할때 확인하는걸로 한다.)
1 mysql 서비스가 리부팅후 자동실행이 정상적으로 되고있는지 확인하기
reboot
명령 실행
mysql
명령 입력
mysql 접속이 된다면 자동실행 완료
2 mysql root 계정 패스워드설정 (리눅스 root / mysql root 패스워드는 다르다.)
보안사항의 기본이니까 반드시 해주자!
2-1 mysqladmin 찾기
find 명령어로 mysqladmin 를 찾아가준다.
[root@cobuy-0938 mysql]# find / -name mysqladmin <-- find 명령어로 위치를 찾는다.
/usr/bin/mysqladmin
[root@cobuy-0938 mysql]# cd /usr/bin/ <-- 위치이동
[root@cobuy-0938 bin]# pwd <!-- 현 위치 출력
/usr/bin
[root@cobuy-0938 bin]#
[root@cobuy-0938 bin]#
[root@cobuy-0938 bin]# ./mysqladmin -u root -p password 123asd <!-- mysql root 계정의 패스워드를 123asd 로 변경하는 명령문이다.
Enter password: <!-- 기존 root 계정 패스워드를 입력한다. 없으니까 그냥 엔터치면 된다.
Warning: Using a password on the command line interface can be insecure.
[root@cobuy-0938 bin]# mysql <!-- 이젠 mysql 명령어로는 들어갈 수 없다.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@cobuy-0938 bin]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@cobuy-0938 bin]# mysql -u root -p <!-- 이렇게 해야만 root 계정의 패스워드를 입력받고 들어갈 수 있다.
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.6.35 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, 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> quit
Bye
이렇게 root 계정 패스워드 설정도 완료
반응형'LINUX' 카테고리의 다른 글
CentOS7 php 설치하기 (0) 2017.03.22 CentOS 아파치 설치하기 (0) 2017.03.22 리눅스 ssh ,http 외부네트워크 접속환경구축 (0) 2017.03.22 configure: error: no acceptable C compiler found in $PATH (0) 2017.03.21 CentOS - php - mail 함수 사용하기 (0) 2017.03.13