Windows10 安装 MySQL8 并开启远程访问

首先去官网下载MySQL8

https://dev.mysql.com/downloads/windows/installer/8.0.html

我是解压到C:\mysql-8.0.12-winx64

然后配置环境变量:

变量名:MYSQL_HOME

变量值:C:\mysql-8.0.12-winx64

在Path变量值最前面添加:

%MYSQL_HOME%\bin;

以管理员权限打开CMD,切换到C:\mysql-8.0.12-winx64\bin目录

使用下面的命令进行安装:

mysql install 

使用下面的命令启动MySQL:

net start mysql 

然后使用下面的命令连接MySQL:

mysql -u root -p

提示需要输入密码的时候直接回车

C:\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 MySQL Community Server - GPL

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.

登陆成功之后修改密码(密码修改为admin):

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'admin';

默认不允许远程访问MySQL,下面是开启远程访问的命令:

use mysql;

update user set host = '%' where user = 'root';

FLUSH PRIVILEGES;

猜你喜欢

转载自www.cnblogs.com/1x11/p/9508222.html