美文网首页
在Windows 10 上配置MySQL Community S

在Windows 10 上配置MySQL Community S

作者: zzzzzzzzdddd11 | 来源:发表于2019-02-07 13:34 被阅读0次

参考了 MySQL 8.0.14安装教程(windows 64位) https://blog.csdn.net/qq_37350706/article/details/81707862

  1. 在页面 https://dev.mysql.com/downloads/mysql/ 下载MySQL Community Server 8.0.15
    5.png
  2. 解压,并把\bin添加到系统的环境变量


    8.png
    9.png
  3. 在根目录(即解压到的目录,bin的上级目录)添加包含如下内容的my.ini
    10.png
    注意basedir和datadir要根据自己实际情况设置
[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=C:\Program Files\MySQL
# 设置mysql数据库的数据的存放目录
datadir=C:\Program Files\MySQL\Data
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。
max_connect_errors=10
# 服务端使用的字符集默认为UTF8
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
#mysql_native_password
default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8
  1. 在根目录shift+右键点击空白处打开powershell,执行mysqld --initialize --console
    输出
2019-02-06T04:00:56.041550Z 0 [System] [MY-013169] [Server] D:\zz\path\mysql-8.0.15-winx64\bin\mysqld.exe (mysqld 8.0.15) initializing of server in progress as process 13020
2019-02-06T04:00:56.042807Z 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.
2019-02-06T04:01:23.143694Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: s,g#wKS-P4Gt
2019-02-06T04:01:39.307357Z 0 [System] [MY-013170] [Server] D:\zz\path\mysql-8.0.15-winx64\bin\mysqld.exe (mysqld 8.0.15) initializing of server has completed

从输出里得知,临时密码是s,g#wKS-P4Gt

  1. 执行mysqld --install
    输出
Service successfully installed.

执行net start mysql,输出

MySQL 服务正在启动 .
MySQL 服务已经启动成功。
  • 如果输出
The service already exists!
The current server installed: "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe" MySQL

说明之前安装的mysql服务仍然残留,处理方法如下:
打开cmd(这里不能在之前的powershell执行不然会没有输出),执行sc delete mysql
输出

[SC] DeleteService 成功

重新执行mysqld --install
输出

Service successfully installed.

执行net start mysql

  1. 在cmd里执行mysqladmin -uroot -p password
    输出Enter password:
    手打刚刚的临时密码进去(无法粘贴),回车,再输入两次新密码,回车。临时密码已经修改完毕。

参考资料 http://www.cnblogs.com/maxomnis/p/5479040.html

  1. 至此,MySQL Community Server 8.0.15已经配置完毕,可以使用mysql -u root -p以及Navicat连接MySQL数据库了。
  • 如果在步骤6,7之前,试图在命令行中执行mysql -h localhost -u root -ppassword s,g#wKS-P4Gt,并确保MySQL服务处于正在运行的状态,会报错
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
  • 如果在步骤6,7之前,用Navicat使用临时密码配置连接
    6.png
    连接测试,会报错1862 - Your password has expired. To log in you must change it using a client that supports expired password.
    图片.png
  • 以上解决方法都是执行步骤6,7

相关文章

网友评论

      本文标题:在Windows 10 上配置MySQL Community S

      本文链接:https://www.haomeiwen.com/subject/ooeysqtx.html