>  기사  >  데이터 베이스  >  mysql8.0의 몇 가지 간단한 구성을 설명하십시오.

mysql8.0의 몇 가지 간단한 구성을 설명하십시오.

藏色散人
藏色散人앞으로
2021-11-11 14:04:571697검색

이 글은 mysql-8.0의 몇 가지 간단한 구성을 소개하겠습니다. 도움이 되셨으면 좋겠습니다!

mysql-8.0 몇 가지 간단한 구성

다운로드

다운로드 후 zip의 압축을 풀고 디렉토리에 넣은 후 환경 변수를 구성

구성 파일

다운로드 후 루트를 다운로드합니다. 디렉토리에 my.ini 파일(또는 my-default.ini)이 없습니다. my.ini 파일이 없으면 직접 생성해도 됩니다. my.ini

[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=C:\Program Files\mysql-8.0.12-winx64
# 设置mysql数据库的数据的存放目录
datadir=D:\mysql\data
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
max_connect_errors=10
# 服务端使用的字符集默认为UTF8
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8

를 설치 루트 디렉터리에 추가합니다. basedir은 내 로컬 설치 디렉터리이고 datadir은 내 데이터베이스 데이터 파일이 저장되는 위치입니다.

데이터베이스 초기화

MySQL 설치 디렉토리의 bin 디렉토리에서 명령어를 실행하세요:

mysqld --initialize --console

실행이 완료되면 루트 사용자의 초기 기본 비밀번호가 출력됩니다

C:\Program Files\mysql-8.0.12-winx64\bin
λ mysqld --initialize --console
2018-07-28T08:09:39.819831Z 0 [System] [MY-013169] [Server] C:\Program Files\mysql-8.0.12-winx64\bin\mysqld.exe (mysqld 8.0.12) initializing of server in progress as process 8624
2018-07-28T08:09:46.120948Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: thbVf;1w7(Zy
2018-07-28T08:09:48.278535Z 0 [System] [MY-013170] [Server] C:\Program Files\mysql-8.0.12-winx64\bin\mysqld.exe (mysqld 8.0.12) initializing of server has completed

thbVf;1w7(Zy 는 초기 비밀번호입니다(첫 번째 공백 제외) )

초기화된 datadir 디렉터리를 삭제하고 다시 초기화 명령을 실행하면 다시 생성됩니다

Installation service

MySQL 설치의 bin 디렉터리에서 명령을 실행하세요 디렉터리 (관리자로 cmd 명령줄 열기)

mysqld --install [服务名]

그 뒤에는 서비스 이름을 작성할 필요가 없습니다. 물론 기본 이름은 mysql입니다. 컴퓨터에 여러 개의 MySQL 서비스를 설치해야 하는 경우에는 다음과 같이 할 수 있습니다. mysql5 및 mysql8과 같이 서로 다른 이름을 사용하십시오.

설치가 완료되면 net start mysql 명령을 통해 MySQL 서비스를 시작할 수 있습니다.

C:\Program Files\mysql-8.0.12-winx64\bin
λ mysqld --install
Service successfully installed.
C:\Program Files\mysql-8.0.12-winx64\bin
λ net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。

비밀번호를 변경하세요

MySQL 설치 디렉터리의 bin 디렉터리: mysql -u root -p

 이때 비밀번호를 입력하라는 메시지가 표시됩니다. 초기 비밀번호를 입력한 후 다음 코드로 비밀번호를 변경하세요

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';

결과

C:\Program Files\mysql-8.0.12-winx64\bin
λ mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.12
Copyright (c) 2000, 2018, 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 WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.08 sec)
mysql> exit

추천 학습: "mysql 비디오 튜토리얼"

위 내용은 mysql8.0의 몇 가지 간단한 구성을 설명하십시오.의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

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