집 >데이터 베이스 >MySQL 튜토리얼 >mysql5.7.18 인스턴스의 centos7.3 설치에 대한 자세한 설명
이 글은 주로 centos7.3에 mysql5.7.18을 설치하기 위한 자세한 튜토리얼을 소개하고 있으니, 필요한 친구들이 참고하시면 도움이 될 것 같습니다.
1 Linux 출시 버전을 확인하세요
[root@typecodes ~]# cat /etc/redhat-release
CentOS Linux 출시 7.2.1511(Core)
2 MySQL 공식 Yum Repository 다운로드
Linux 출시 버전에 따라 (CentOS, Fedora는 모두 Red Hat 시스템에 속합니다.) 공식 mysql(http://dev.mysql.com/downloads/repo/yum/)에서 Yum Repository를 구하세요.
[root@typecodes ~]# wget -i http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm --2016-02-03 18:36:02-- http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm Resolving dev.mysql.com (dev.mysql.com)... 137.254.60.11 Connecting to dev.mysql.com (dev.mysql.com)|137.254.60.11|:80... connected. HTTP request sent, awaiting response... 302 Found Location: http://repo.mysql.com//mysql57-community-release-el7-7.noarch.rpm [following] --2016-02-03 18:36:04-- http://repo.mysql.com//mysql57-community-release-el7-7.noarch.rpm Resolving repo.mysql.com (repo.mysql.com)... 104.102.164.25 Connecting to repo.mysql.com (repo.mysql.com)|104.102.164.25|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 8984 (8.8K) [application/x-redhat-package-manager] Saving to: ‘mysql57-community-release-el7-7.noarch.rpm' 100%[=============================================================================================================================>] 8,984 --.-K/s in 0s 2016-02-03 18:36:07 (68.4 MB/s) - ‘mysql57-community-release-el7-7.noarch.rpm' saved [8984/8984] 3 安装MySQL的Yum Repository 安装完MySQL的Yum Repository,每次执行yum update都会检查MySQL是否更新。 [root@typecodes ~]# yum -y install mysql57-community-release-el7-7.noarch.rpm Loaded plugins: axelget, fastestmirror, langpacks Examining mysql57-community-release-el7-7.noarch.rpm: mysql57-community-release-el7-7.noarch Marking mysql57-community-release-el7-7.noarch.rpm to be installed Resolving Dependencies --> Running transaction check ---> Package mysql57-community-release.noarch 0:el7-7 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================================================= Package Arch Version Repository Size ======================================================================================================================================================================= Installing: mysql57-community-release noarch el7-7 /mysql57-community-release-el7-7.noarch 7.8 k Transaction Summary ======================================================================================================================================================================= Install 1 Package Total size: 7.8 k Installed size: 7.8 k Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : mysql57-community-release-el7-7.noarch 1/1 Verifying : mysql57-community-release-el7-7.noarch 1/1 Installed: mysql57-community-release.noarch 0:el7-7 Complete!
3 MySQL 데이터베이스의 서버 버전 설치
[root@typecodes ~]# yum -y install mysql-community-server Loaded plugins: axelget, fastestmirror, langpacks No metadata available for base No metadata available for epel No metadata available for extras repomd.xml | 2.5 kB 00:00:00 update mysql-connectors-community metadata successfully repomd.xml | 2.5 kB 00:00:00 update mysql-tools-community metadata successfully repomd.xml | 2.5 kB 00:00:00 update mysql57-community metadata successfully No metadata available for updates mysql-connectors-community | 2.5 kB 00:00:00 mysql-tools-community | 2.5 kB 00:00:00 mysql57-community | 2.5 kB 00:00:00 (1/3): mysql-tools-community/x86_64/primary_db | 24 kB 00:00:01 (2/3): mysql57-community/x86_64/primary_db | 28 kB 00:00:01 (3/3): mysql-connectors-community/x86_64/primary_db | 8.6 kB 00:00:02 Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: mirrors.neusoft.edu.cn * extras: mirrors.163.com * updates: mirrors.163.com Resolving Dependencies --> Running transaction check ---> Package mysql-community-server.x86_64 0:5.7.10-1.el7 will be installed --> Processing Dependency: mysql-community-common(x86-64) = 5.7.10-1.el7 for package: mysql-community-server-5.7.10-1.el7.x86_64 --> Processing Dependency: mysql-community-client(x86-64) = 5.7.10-1.el7 for package: mysql-community-server-5.7.10-1.el7.x86_64 --> Running transaction check ---> Package mysql-community-client.x86_64 0:5.7.10-1.el7 will be installed --> Processing Dependency: mysql-community-libs(x86-64) = 5.7.10-1.el7 for package: mysql-community-client-5.7.10-1.el7.x86_64 ---> Package mysql-community-common.x86_64 0:5.7.10-1.el7 will be installed --> Running transaction check ---> Package mariadb-libs.x86_64 1:5.5.44-2.el7.centos will be obsoleted --> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64 --> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64 ---> Package mysql-community-libs.x86_64 0:5.7.10-1.el7 will be obsoleting --> Running transaction check ---> Package mysql-community-libs-compat.x86_64 0:5.7.10-1.el7 will be obsoleting --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================================================= Package Arch Version Repository Size ======================================================================================================================================================================= Installing: mysql-community-libs x86_64 5.7.10-1.el7 mysql57-community 2.2 M replacing mariadb-libs.x86_64 1:5.5.44-2.el7.centos mysql-community-libs-compat x86_64 5.7.10-1.el7 mysql57-community 2.0 M replacing mariadb-libs.x86_64 1:5.5.44-2.el7.centos mysql-community-server x86_64 5.7.10-1.el7 mysql57-community 142 M Installing for dependencies: mysql-community-client x86_64 5.7.10-1.el7 mysql57-community 24 M mysql-community-common x86_64 5.7.10-1.el7 mysql57-community 269 k Transaction Summary ======================================================================================================================================================================= Install 3 Packages (+2 Dependent packages) Total download size: 171 M Downloading packages: mysql-community-server-5.7.10-1.el7.x86_64.rpm | 142 MB 00:03:42 mysql-community-libs-compat-5.7.10-1.el7.x86_64.rpm | 2.0 MB 00:00:03 mysql-community-libs-5.7.10-1.el7.x86_64.rpm | 2.2 MB 00:00:05 mysql-community-client-5.7.10-1.el7.x86_64.rpm | 24 MB 00:00:41 warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.10-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY00 ETA Public key for mysql-community-common-5.7.10-1.el7.x86_64.rpm is not installed mysql-community-common-5.7.10-1.el7.x86_64.rpm | 269 kB 00:00:01 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql Importing GPG key 0x5072E1F5: Userid : "MySQL Release Engineering <mysql-build>" Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5 Package : mysql57-community-release-el7-7.noarch (@/mysql57-community-release-el7-7.noarch) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : mysql-community-common-5.7.10-1.el7.x86_64 1/6 Installing : mysql-community-libs-5.7.10-1.el7.x86_64 2/6 Installing : mysql-community-client-5.7.10-1.el7.x86_64 3/6 Installing : mysql-community-server-5.7.10-1.el7.x86_64 4/6 Installing : mysql-community-libs-compat-5.7.10-1.el7.x86_64 5/6 Erasing : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64 6/6 Verifying : mysql-community-server-5.7.10-1.el7.x86_64 1/6 Verifying : mysql-community-libs-compat-5.7.10-1.el7.x86_64 2/6 Verifying : mysql-community-common-5.7.10-1.el7.x86_64 3/6 Verifying : mysql-community-libs-5.7.10-1.el7.x86_64 4/6 Verifying : mysql-community-client-5.7.10-1.el7.x86_64 5/6 Verifying : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64 6/6 Installed: mysql-community-libs.x86_64 0:5.7.10-1.el7 mysql-community-libs-compat.x86_64 0:5.7.10-1.el7 mysql-community-server.x86_64 0:5.7.10-1.el7 Dependency Installed: mysql-community-client.x86_64 0:5.7.10-1.el7 mysql-community-common.x86_64 0:5.7.10-1.el7 Replaced: mariadb-libs.x86_64 1:5.5.44-2.el7.centos Complete! [root@typecodes ~]# clear</mysql-build>
마지막 스크린샷:
4 데이터베이스 시작:
[root@typecodes ~]# systemctl start mysqld.service
그런 다음 systemctl status mysqld.service 명령을 사용하여 MySQL 데이터베이스 이후의 서비스 상태를 확인하세요. 시작됨:
5 초기 비밀번호 얻기
YUM을 사용하여 MySQL 서비스를 설치하고 시작한 후 MySQL 프로세스는 프로세스 로그에 루트 사용자의 초기 비밀번호를 자동으로 인쇄합니다.
#######从mysql进程日志中获取root用户的初始密码:ra%yk7urCBIh [root@typecodes ~]# grep "password" /var/log/mysqld.log 2016-02-03T10:42:17.272166Z 1 [Note] A temporary password is generated for root@localhost: ra%yk7urCBIh 2016-02-03T10:42:36.776875Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO) 2016-02-03T10:42:52.063138Z 3 [Note] Access denied for user 'root'@'localhost' (using password: NO) 2016-02-03T10:42:57.564373Z 4 [Note] Access denied for user 'root'@'localhost' (using password: NO) 2016-02-03T10:43:01.477007Z 5 [Note] Access denied for user 'root'@'localhost' (using password: NO) 2016-02-03T10:46:03.642008Z 6 [Note] Access denied for user 'root'@'localhost' (using password: NO) 2016-02-03T10:46:11.217889Z 7 [Note] Access denied for user 'root'@'localhost' (using password: NO) 2016-02-03T10:47:44.755199Z 0 [Note] Shutting down plugin 'validate_password' 2016-02-03T10:47:46.505844Z 0 [Note] Shutting down plugin 'sha256_password' 2016-02-03T10:47:46.505851Z 0 [Note] Shutting down plugin 'mysql_native_password'
6 수정 루트 사용자 비밀번호
섹션 5 초기 비밀번호에서 얻은 루트 사용자를 사용하고 수정합니다.
set global verify_password_policy =0; //기본값은 1, MEDIUM이므로 처음에 설정한 비밀번호는 다음을 충족해야 합니다. 길이이며 숫자, 소문자 또는 대문자, 특수 문자를 포함해야 합니다.
set global validate_password_length=4;//指定了密码中数据的长度 alter user root@localhost identified by 'crow';//修改密码
원격 접속 권한을 높여주세요
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'crow' WITH GRANT OPTION; FLUSH PRIVILEGES;
mysql 종료 후 서비스 재시작
systemctl restart mysqld
방화벽에서 3306 포트 열기
firewall-cmd --zone=public --add-port=3306/tcp --permanent
방화벽 다시 시작
firewall-cmd --reload [root@typecodes ~]# mysql -uroot -p Enter password: #######输入默认的root密码后回车 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.10 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> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password'; Query OK, 0 rows affected (0.00 sec) mysql> exit Bye
7 설치 완료
이때 YUM을 사용하세요 CentOS7 데이터베이스에 MySQL5.7.10을 설치하는 방법이 완료되었습니다. 아래와 같이 새로운 루트 비밀번호를 사용하여 MySQL에 로그인할 수 있습니다.
[root@typecodes ~]# mysql -uroot -ppassword mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.10 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> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec) mysql> clear mysql> exit Bye [root@typecodes ~]# clear
부록 1: MySQL 데이터베이스의 구성 정보 보기
MySQL 구성 파일은 여전히 /etc/my.cnf입니다. 기타 설치 정보는 mysql_config 명령을 통해 볼 수 있습니다. 그 중 동적 라이브러리 파일은 /usr/lib64/mysql 디렉터리에 저장됩니다.
부록 2: C/C++ 및 기타 개발자의 경우
mysql.h 등의 헤더 파일을 사용해야 하므로, mysql 개발 버전을 설치하려면 다음 명령을 실행해야 합니다.
[root@typecodes ~]# yum -y install mysql-community-devel
부록 3: MySQL의 저장소 삭제
MySQL의 Yum 저장소는 섹션 3에 설치되어 있으므로 앞으로 yum 작업을 수행할 때마다 업데이트를 확인합니다. 이 자동 검사 작업을 제거하려면 다음 명령을 사용하여 MySQL 리포지토리를 제거할 수 있습니다.
[root@typecodes ~]# yum -y remove mysql57-community-release-el7-7.noarch update 2017.04.10 11:10
위의 yum 방식을 사용하면 현재 mysql 공식 홈페이지에서 최신 버전인 mysql5.7.18을 설치할 수도 있습니다. 섹션 2의 rmp 패키지 버전을 교체하면 후속 단계는 변경되지 않습니다.
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
관련 권장 사항:
centos6.4에서 mysql5.7.18의 설치 및 구성 방법에 대한 그래픽 튜토리얼 공유
압축 해제 버전 설치 방법 Windows Tutorial
의 MySQL5.7.18위 내용은 mysql5.7.18 인스턴스의 centos7.3 설치에 대한 자세한 설명의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!