iis服务器助手广告广告
返回顶部
首页 > 资讯 > 数据库 >不卸载原有mysql直接安装mysql8.0
  • 895
分享到

不卸载原有mysql直接安装mysql8.0

安装mysql8.0直接安装mysql8.0 2023-01-12 15:01:47 895人浏览 八月长安
摘要

目录下载zip安装包初始化数据库登陆Mysql数据库注册/删除mysql服务下载zip安装包 下载地址:https://dev.mysql.com/downloads/mysql/

下载zip安装包

下载地址:https://dev.mysql.com/downloads/mysql/

下载完成后,解压压缩包,进入压缩的目录,新建文本文件my.ini。

假设你解压出来的目录为E:\Program Files\mysql-8.0.19-winx64,my.ini内容如下:

[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=E:\Program Files\mysql-8.0.19-winx64
# 设置mysql数据库的数据的存放目录
datadir=E:\Program Files\mysql-8.0.19-winx64\data   
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
max_connect_errors=10
# 服务端使用的字符集默认为UTF8
character-set-server=UTF8MB4
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_passWord插件认证
default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set=UTF8MB4
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=UTF8MB4

初始化数据库

在MySQL安装目录的bin目录执行命令:

mysqld --initialize --console

此时,我的win7系统报错:

image-20200607003323063

解决方案:去百度下载一个vcruntime140_1.dll放入%windir%\system32\目录中。

我使用的下载地址:Https://www.jb51.net/dll/vcruntime140_1.dll.html

%windir%\system32\在我的系统中表示C:\windows\System32

再次执行上述命令后:

E:\Program Files\mysql-8.0.19-winx64\bin>mysqld --initialize --console
2020-06-06T16:34:34.062007Z 0 [System] [MY-013169] [Server] E:\Program Files\mys
ql-8.0.19-winx64\bin\mysqld.exe (mysqld 8.0.19) initializing of server in progre
ss as process 7816
2020-06-06T16:34:37.513202Z 5 [Note] [MY-010454] [Server] A temporary password i
s generated for root@localhost: /rfMQ+bGi22z

表示初始化成功。

注意:我这里生成的临时密码是/rfMQ+bGi22z,下文会使用到。

登陆mysql数据库

启动mysql服务端,需要另外启动一个命令后,执行mysqld:

E:\Program Files\mysql-8.0.19-winx64\bin>mysqld

image-20200607004704811

就如上图一样,让这个命令行一直后台挂着,mysql的服务进程占用着它,不能关闭,关闭后mysql的服务进程也会跟着被关闭。

再用mysql客户端登陆后,顺利登陆:

E:\Program Files\mysql-8.0.19-winx64\bin>mysql -uroot -p/rfMQ+bGi22z
mysql: [Warning] Using a password on the command line interface can be insecure.

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.

mysql>

修改密码为123456:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '1
23456';
Query OK, 0 rows affected (0.01 sec)

mysql>

注册/删除mysql服务

经过上述操作mysql8.0已经可以正常使用,但启动mysql服务需要占用一个命令行未免有些麻烦,现在我们通过将mysqld注册为系统服务解决这个问题。

在MySQL安装目录的bin目录执行命令:

E:\Program Files\mysql-8.0.19-winx64\bin>mysqld --install mysql8.0
Service successfully installed.

mysql8.0可以改为其他你喜欢的服务的名字。

注册成功后,任务管理器上可以看到服务的名字:

image-20200607005626027

只需要右键启动服务,mysql8.0就可以正常使用了。

然后mysql客户端就可以使用新密码正常的登陆了:

E:\Program Files\mysql-8.0.19-winx64\bin>mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.19 MySQL CommUnity Server - GPL

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.

mysql>

如果你希望在任何目录下都能执行mysql客户端命令,则需要将mysql的安装目录下的bin目录加入环境变量中,例如:E:\Program Files\mysql-8.0.19-winx64\bin。

删除服务:

sc delete mysql8.0 -remove

mysql8.0是你要删除的服务名称

到此这篇关于不卸载原有mysql直接安装mysql8.0的文章就介绍到这了,更多相关安装mysql8.0内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

您可能感兴趣的文档:

--结束END--

本文标题: 不卸载原有mysql直接安装mysql8.0

本文链接: https://www.lsjlt.com/news/177561.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作