>  기사  >  데이터 베이스  >  centos7 mysql 데이터베이스를 설치하고 구성하는 방법

centos7 mysql 데이터베이스를 설치하고 구성하는 방법

WBOY
WBOY앞으로
2023-05-28 21:55:041468검색

1 mysql-server가 다음과 같이 실패했습니다.

[root@yl-web yl]# cat /etc/redhat-release 
centos linux release 7.1.1503 (core)
정보를 확인한 결과 centos 7 버전에서는 기본 프로그램 목록에서 mysql 데이터베이스 소프트웨어가 제거되고 mariadb로 교체된 것으로 나타났습니다.

두 가지 해결 방법이 있습니다.

1. 방법 1: mariadb 설치

mariadb 데이터베이스 관리 시스템은 주로 오픈 소스 커뮤니티에서 유지 관리하고 GPL 라이센스를 사용하는 mysql의 한 부분입니다. 이 브랜치를 개발한 이유 중 하나는 오라클이 MySQL을 인수한 후 MySQL을 소스로 폐쇄할 잠재적인 위험이 있었기 때문에 커뮤니티는 이러한 위험을 피하기 위해 브랜치 접근 방식을 채택했습니다. mariadb의 목적은 API 및 명령줄을 포함하여 MySQL과 완벽하게 호환되어 MySQL을 쉽게 대체하는 것입니다.

mariadb를 설치하세요(크기 59m).

#yum install mysql
#yum install mysql-server
#yum install mysql-devel

mariadb 데이터베이스에 대한 관련 명령은 다음과 같습니다.

[root@yl-web yl]# yum install mysql-server
loaded plugins: fastestmirror
loading mirror speeds from cached hostfile
 * base: mirrors.sina.cn
 * extras: mirrors.sina.cn
 * updates: mirrors.sina.cn
no package mysql-server available.
error: nothing to do

그러므로 데이터베이스를 먼저 시작하세요.

[root@yl-web yl]# yum install mariadb-server mariadb

그러면 정상적으로 mysql을 사용할 수 있습니다

systemctl start mariadb #启动mariadb

systemctl stop mariadb #停止mariadb

systemctl restart mariadb #重启mariadb

systemctl enable mariadb #设置开机启动
mariadb를 설치하고 나면 표시도 mariadb [(none)]>입니다. 조금 이상해 보일 수도 있습니다. 두 번째 방법은 다음과 같습니다.

2. 방법 2: 공식 웹사이트

[root@yl-web yl]# systemctl start mariadb

에서 mysql-server를 다운로드하여 설치합니다. 설치가 성공적으로 완료되면 mysql 서비스를 다시 시작합니다.

[root@yl-web yl]# mysql -u root -p
enter password: 
welcome to the mariadb monitor. commands end with ; or \g.
your mariadb connection id is 3
server version: 5.5.41-mariadb mariadb server

copyright (c) 2000, 2014, oracle, mariadb corporation ab and others.

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

mariadb [(none)]> show databases;
+--------------------+
| database  |
+--------------------+
| information_schema |
| mysql  |
| performance_schema |
| test  |
+--------------------+
4 rows in set (0.00 sec)

mariadb [(none)]>

mysql을 처음 설치할 때 루트 계정에는 비밀번호가 없습니다.

# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
# rpm -ivh mysql-community-release-el7-5.noarch.rpm
# yum install mysql-community-server

비밀번호

# service mysqld restart

설정은 적용을 위해 데이터베이스를 다시 시작할 필요가 없습니다.

mysql 설치 과정에서 다음과 같은 내용이 나옵니다.

[root@yl-web yl]# mysql -u root 
welcome to the mysql monitor. commands end with ; or \g.
your mysql connection id is 3
server version: 5.6.26 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> show databases;
+--------------------+
| database  |
+--------------------+
| information_schema |
| mysql  |
| performance_schema |
| test  |
+--------------------+
4 rows in set (0.01 sec)

mysql>
그래서 설치가 완료된 후에는 mariadb가 자동으로 교체되어 더 이상 적용되지 않습니다.

mysql> set password for 'root'@'localhost' =password('password');
query ok, 0 rows affected (0.00 sec)

mysql>

3. mysql 구성

1. 인코딩

mysql 구성 파일은 /etc/my.cnf

마지막으로 인코딩 구성을 추가하세요

installed:
 mysql-community-client.x86_64 0:5.6.26-2.el7  mysql-community-devel.x86_64 0:5.6.26-2.el7  
 mysql-community-libs.x86_64 0:5.6.26-2.el7   mysql-community-server.x86_64 0:5.6.26-2.el7  

dependency installed:
 mysql-community-common.x86_64 0:5.6.26-2.el7          

replaced:
 mariadb.x86_64 1:5.5.41-2.el7_0  mariadb-devel.x86_64 1:5.5.41-2.el7_0 mariadb-libs.x86_64 1:5.5.41-2.el7_0 
 mariadb-server.x86_64 1:5.5.41-2.el7_0

여기서 문자 인코딩은 /usr/share와 동일해야 합니다. /mysql/charsets /index.xml 일관성.

2. 원격 연결 설정

모든 데이터베이스의 모든 테이블에 대한 모든 권한을 모든 IP 주소에 있는 루트 사용자에게 할당합니다.

[root@yl-web yl]# rpm -qa |grep mariadb
[root@yl-web yl]#

루트가 아닌 신규 사용자라면 먼저 신규 사용자를 생성해야 합니다

[mysql]
default-character-set =utf8

이제 원격으로 연결할 수 있습니다.

위 내용은 centos7 mysql 데이터베이스를 설치하고 구성하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
이 기사는 yisu.com에서 복제됩니다. 침해가 있는 경우 admin@php.cn으로 문의하시기 바랍니다. 삭제