mysql 8.0.19 安装 及 端口修改

时间:2020-05-21
本文章向大家介绍mysql 8.0.19 安装 及 端口修改,主要包括mysql 8.0.19 安装 及 端口修改使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

1.创建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.
[mysqld]
# 设置3309端口 
port=3309	#根据自己的需要修改端口
# 设置mysql的安装目录
basedir=L:\1_mysql\mysql-8.0.19-winx64 #根据自己的文件位置修改
# 设置mysql数据库的数据的存放目录
datadir=L:\1_mysql\mysql-8.0.19-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
sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3309	#根据自己的需要修改端口
default-character-set=utf8

2.解压mysql-8.0.19-winx64.zip到安装目录;
3.将my.ini文件复制到mysql-8.0.19-winx64根目录;
4.进入mysql-8.0.19-winx64\bin文件夹,在此文件夹下打开Powershell窗口;
5.安装mysql,
输入:
mysqld --install
返回:
Service successfully installed.
6.初始化mysql,
输入:
mysqld --initialize --console
返回:
2020-05-21T01:51:15.619733Z 0 [System] [MY-013169] [Server] L:\1_mysql\mysql-8.0.19-winx64\bin\mysqld.exe (mysqld 8.0.19) initializing of server in progress as process 328
2020-05-21T01:51:15.622433Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2020-05-21T01:51:30.165449Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: e-%Uh<=ga1qp
7.启动mysql,
输入:
net start mysql
回显:
MySQL 服务正在启动 ..
MySQL 服务已经启动成功。
8.登录mysql,
输入:
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.19

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.

9.修改密码:
输入:
ALTER user 'root'@'localhost' IDENTIFIED BY '新密码';
回显:
Query OK, 0 rows affected (0.34 sec)
10.查看端口号:
输入:
show global variables like 'port';
回显:
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port | 3309 |
+---------------+-------+
1 row in set, 1 warning (0.01 sec)


11.其它操作
停止mysql服务:net stop mysql
删除mysql:mysqld -remove mysql
删除服务:sc delete mysql

原文地址:https://www.cnblogs.com/panfengyou/p/12931568.html