1、MySQL安装,版本MySQL Community Server 8.0.22
程序员文章站
2024-03-21 18:28:16
...
MySQL安装,版本MySQL Community Server 8.0.22,官网下载地址
MySQL安装包解压位置C:\Users\Lok\Desktop\mysql-8.0.22-winx64
控制面板\系统和安全\系统\高级系统设置\环境变量 添加以下两个变量及值
MYSQL_HOME
C:\Users\Lok\Desktop\mysql-8.0.22-winx64
PATH
%MYSQL_HOME%\bin
在C:\Users\Lok\Desktop\mysql-8.0.22-winx64路径下添加my.ini
[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=C:\Users\Lok\Desktop\mysql-8.0.22-winx64
# 设置mysql数据库的数据的存放目录(此目录会在之后进行命令生成,无需手写)
datadir=C:\Users\Lok\Desktop\mysql-8.0.22-winx64\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
以管理员身份运行CMD
Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。
C:\Windows\system32>cd C:\Users\Lok\Desktop\mysql-8.0.22-winx64\bin
//初始化数据库并生成root账号无密码,my.ini配置有误的话会在Data文件夹下生成错误日志可查看
C:\Users\Lok\Desktop\mysql-8.0.22-winx64\bin>mysqld --initialize-insecure
C:\Users\Lok\Desktop\mysql-8.0.22-winx64\bin>mysqld --install
Service successfully installed.
C:\Users\Lok\Desktop\mysql-8.0.22-winx64\bin>net start mysql
MySQL 服务正在启动 ...
MySQL 服务已经启动成功。
//无密码直接回车
C:\Users\Lok\Desktop\mysql-8.0.22-winx64\bin> mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.22 MySQL Community Server - GPL
Copyright (c) 2000, 2020, 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 |
| sys |
+--------------------+
mysql> use mysql;
Database changed
//修改root密码为123456
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '1
23456' ;
Query OK, 0 rows affected (0.10 sec)
mysql>
下载免费的MySQL数据库图形化管理工具
- Workbench
网站:http://dev.mysql.com/downloads/workbench/
支持平台:Microsoft Windows,Mac OS X,Linux
点击输入root密码123456就可以愉快使用MySQL数据库啦
推荐阅读
-
MySQL Community Server 5.7.22 安装
-
1、MySQL安装,版本MySQL Community Server 8.0.22
-
MySQL Community Server下载与安装配置
-
mysql Community Server 5.7安装教程以及常见错误
-
Ubuntu1604安装MySQL Community Server 8.0
-
如何快速安装mysql-community-server
-
[Mac] MySQL Community Server 8.0.21 安装
-
MySQL Community Server 5.7.19安装指南
-
redhat6.3安装MySQL-server-5.6.13-1.el6.x86_64.rpm_MySQL
-
MySQL Community Server安装失败怎么办 MySQL Community Server正确安装方法