MySQL安装配置方法(Windows10)

最近又想学习些JAVA的东西了,好久没有操练,很多都升级换代很多,不好弄了,下面先介绍一下Windows10系统下MySQL的安装配置。

1、第一步,下载安装程序,https://edelivery.oracle.com/osdc/faces/SoftwareDelivery

需要登录Oracle,如果没有账户,需要先注册一下,免费。

然后就是选择自己需要的程序了,我选择的压缩包版本的,没有选择安装版。下载时会弹出一个网站自带的下载工具,比较快就可以下完。

为避免下载后不知道那个文件对应的程序,建议提前把截图保存一下,或者复制文本保存文件名和程序的对应关系。接下来,解压文件到英文目录(强烈推荐),中文目录没有试过,建议不做尝试。

 2、安装:

接着WIN+R调出命令窗口,进入程序根目录下的\bin目录,执行下面命令:

D:\Program Files\mysql-commercial-8.0.26-winx64\bin>mysqld --install
Service successfully installed.

然后执行初始化操作,此时会生成一个随机初始密码,提醒大家在这一步时一定要把最后的密码保存好。

D:\Program Files\mysql-commercial-8.0.26-winx64\bin>mysqld --initialize --console
2021-07-27T15:15:35.050999Z 0 [System] [MY-013169] [Server] D:\Program Files\mysql-commercial-8.0.26-winx64\bin\mysqld.exe (mysqld 8.0.26-commercial) initializing of server in progress as process 3868
2021-07-27T15:15:35.523145Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-07-27T15:15:42.196034Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-07-27T15:15:54.399791Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
2021-07-27T15:15:54.403445Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
2021-07-27T15:15:54.666044Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: QgdJw+9XKwl/

接着,启动mysql

D:\Program Files\mysql-commercial-8.0.26-winx64\bin>net start mysql
MySQL 服务正在启动 ..
MySQL 服务已经启动成功。

3、登录mysql,需要使用初始化时生成的临时密码:QgdJw+9XKwl/

D:\Program Files\mysql-commercial-8.0.26-winx64\bin>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.26-commercial

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

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.

 在这里,提醒各位,临时密码有时候比较坑,我这个密码的倒数第二个字符,我一直认为是1,试了很多次都显示如下错误:

D:\Program Files\mysql-commercial-8.0.26-winx64\bin>mysql -u root -p
Enter password: ************
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

最后快要放弃的时候,突然想到会不会是小写字母l,这才成功登录进去。大家一定要瞪大眼睛了看清楚了。

4、修改root密码

由于临时密码权限很小,无法正常操作数据库,

mysql> select User.Password from mysql.user;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

所以第一步就是要把密码修改一下:

先查询一下用户信息:

use mysql

select host, user from user;

如果host列是 localhost root,则只能本地访问。如果是 % root则可以远程访问。

修改密码,是否为localhost用户决定了这里的修改密码的用户权限,请根据自己的用户更改

alter user 'root'@'localhost' identified by '密码';

alter user 'root'@'%' identified by '密码';

mysql> alter user 'root'@'localhost' identified by 'rootxxx';
Query OK, 0 rows affected (0.36 sec)

好了,到此MySQL在Windows 10 系统安装配置基本完成,可以开始下一步的使用啦,希望对大家有用。

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

UniMagic

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值