• 售前

  • 售后

热门帖子
入门百科

mysql community server 8.0.12安装配置方法图文教程

[复制链接]
白龙江左岸 显示全部楼层 发表于 2021-10-26 14:21:59 |阅读模式 打印 上一主题 下一主题
MySQL 8 带来了全新的体验,比如支持 NoSQL、JSON 等,拥有比 MySQL 5.7 两倍以上的性能提升。本文讲授如安在 Windows 下安装 MySQL 8,以及根本的 MySQL 用法。
下载
下载地址
本例为:MySQL Community Server 8.0.12。
解压
解压至安装目次,比如 D 盘根目次下。
本例为:D:\mysql-8.0.12-winx64。
创建 my.ini
my.ini 是 MySQL 安装的设置文件:
  1. [mysqld]
  2. # 安装目录
  3. basedir=D:\\mysql-8.0.12-winx64
  4. # 数据存放目录
  5. datadir=D:\\mysqlData\\data
复制代码
my.ini放置在 MySQL 安装目次的根目次下。需要留意的是,要先创建D:\mysqlData目次。data目次是由 MySQL 来创建。
初始化安装
实行:
  1. mysqld --defaults-file=D:\mysql-8.0.12-winx64\my.ini --initialize --console
复制代码
控制台输出如下,说明安装乐成:
  1. >mysqld --defaults-file=D:\mysql-8.0.12-winx64\my.ini --initialize --console
  2. 2018-08-20T16:14:45.287448Z 0 [System] [MY-013169] [Server] D:\mysql-8.0.12-winx64\bin\mysqld.exe (mysqld 8.0.12) initializing of server in progress as process 5012
  3. 2018-08-20T16:14:45.289628Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
  4. 2018-08-20T16:14:45.299329Z 0 [ERROR] [MY-010119] [Server] Aborting
  5. 2018-08-20T16:14:45.301316Z 0 [System] [MY-010910] [Server] D:\mysql-8.0.12-winx64\bin\mysqld.exe: Shutdown complete (mysqld 8.0.12) MySQL Community Server - GPL.
  6. D:\mysql-8.0.12-winx64\bin>mysqld --defaults-file=D:\mysql-8.0.12-winx64\my.ini --initialize --console
  7. 2018-08-20T16:15:25.729771Z 0 [System] [MY-013169] [Server] D:\mysql-8.0.12-winx64\bin\mysqld.exe (mysqld 8.0.12) initializing of server in progress as process 18148
  8. 2018-08-20T16:15:43.569562Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: L-hk!rBuk9-.
  9. 2018-08-20T16:15:55.811470Z 0 [System] [MY-013170] [Server] D:\mysql-8.0.12-winx64\bin\mysqld.exe (mysqld 8.0.12) initializing of server has completed
复制代码
此中,“L-hk!rBuk9-.”就是 root 用户的初始化暗码。稍后可以做更改。
启动、关闭 MySQL server
实行mysqld就能启动 MySQL server,或者实行 mysqld –console可以看到完整的启动信息:
  1. >mysqld --console
  2. 2018-08-20T16:18:23.698153Z 0 [Warning] [MY-010915] [Server] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
  3. 2018-08-20T16:18:23.698248Z 0 [System] [MY-010116] [Server] D:\mysql-8.0.12-winx64\bin\mysqld.exe (mysqld 8.0.12) starting as process 16304
  4. 2018-08-20T16:18:27.624422Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
  5. 2018-08-20T16:18:27.793310Z 0 [System] [MY-010931] [Server] D:\mysql-8.0.12-winx64\bin\mysqld.exe: ready for connections. Version: '8.0.12' socket: '' port: 3306 MySQL Community Server - GPL.
复制代码
关闭,可以实行 mysqladmin -u root shutdown
利用 MySQL 客户端
利用 mysql 来登录,账号为 root,暗码为“L-hk!rBuk9-.”:
  1. >mysql -u root -p
  2. Enter password: ************
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 11
  5. Server version: 8.0.12
  6. Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  7. Oracle is a registered trademark of Oracle Corporation and/or its
  8. affiliates. Other names may be trademarks of their respective
  9. owners.
  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
复制代码
实行下面的语句来改暗码。此中“123456”即为新暗码。
  1. mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
  2. Query OK, 0 rows affected (0.13 sec)
复制代码
MySQL 常用指令
显示已有的数据库:
  1. mysql> show databases;
  2. +--------------------+
  3. | Database  |
  4. +--------------------+
  5. | information_schema |
  6. | mysql  |
  7. | performance_schema |
  8. | sys  |
  9. +--------------------+
  10. 4 rows in set (0.08 sec)
复制代码
创建新的数据库:
  1. mysql> CREATE DATABASE lite;
  2. Query OK, 1 row affected (0.19 sec)
复制代码
利用数据库:
  1. mysql> USE lite;
  2. Database changed
复制代码
建表:
建表实行:
  1. mysql> CREATE TABLE t_user (user_id BIGINT NOT NULL, username VARCHAR(20));
  2. Query OK, 0 rows affected (0.82 sec)
复制代码
检察表:
检察数据库中的全部表:
  1. mysql> SHOW TABLES;
  2. +----------------+
  3. | Tables_in_lite |
  4. +----------------+
  5. | t_user  |
  6. +----------------+
  7. 1 row in set (0.00 sec)
复制代码
检察表的详情:
  1. mysql> DESCRIBE t_user;
  2. +----------+-------------+------+-----+---------+-------+
  3. | Field | Type | Null | Key | Default | Extra |
  4. +----------+-------------+------+-----+---------+-------+
  5. | user_id | bigint(20) | NO | | NULL | |
  6. | username | varchar(20) | YES | | NULL | |
  7. +----------+-------------+------+-----+---------+-------+
  8. 2 rows in set (0.00 sec)
复制代码
插入数据:
  1. mysql> INSERT INTO t_user(user_id, username) VALUES(1, '老卫');
  2. Query OK, 1 row affected (0.08 sec)
复制代码
以上就是本文的全部内容,盼望对各人的学习有所资助,也盼望各人多多支持脚本之家。

帖子地址: 

回复

使用道具 举报

分享
推广
火星云矿 | 预约S19Pro,享500抵1000!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

草根技术分享(草根吧)是全球知名中文IT技术交流平台,创建于2021年,包含原创博客、精品问答、职业培训、技术社区、资源下载等产品服务,提供原创、优质、完整内容的专业IT技术开发社区。
  • 官方手机版

  • 微信公众号

  • 商务合作