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.

扫描二维码关注公众号,回复: 14726851 查看本文章

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

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 系统安装配置基本完成,可以开始下一步的使用啦,希望对大家有用。

猜你喜欢

转载自blog.csdn.net/UniMagic/article/details/119156341