mysql的安装与配置教程

首先,进入官网,下载最新版本的mysql社区版
官网网址https://www.mysql.com/downloads/
将下载好的压缩包解压缩
设置环境变量,在系统变量的path部分增加D:\ProgramFiles\MySQL\mysql-8.0.28-winx64\bin
在mysql主目录下面新建my.ini
在my.ini中输入如下代码

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_bin
init_connect='SET NAMES utf8mb4'
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
basedir = D:\ProgramFiles\MySQL\mysql-8.0.28-winx64
datadir = D:\ProgramFiles\MySQL\mysql-8.0.28-winx64\data
port = 3306
# server_id = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
join_buffer_size = 128M
sort_buffer_size = 16M
read_rnd_buffer_size = 16M 
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

以管理员身份打开cmd
输入,mysqld --initialize-insecure --user=mysql
在输入,mysqld --install
启动mysql,net start mysql
输入,mysql -u root -p
不用输密码,直接回车
输入,ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘123456()你的密码’;
输入quit,重新登陆,测试是否改密码成功
输入net start mysql
输入密码
显示成功登录
查看目前的数据库:show databases;
新建表单:create database teaching;
删除表单:drop database teaching;

注:如果想停止mysql服务,输入net stop mysql
想删除mysql的话,输入mysqld -remove MySQL

本内容为合法授权发布,文章内容为作者独立观点,不代表开发云立场,未经允许不得转载。

CSDN开发云