Download and install MySQL, resolve error

Download and install MySQL

First, download

1. Log Mysql official website: https: //www.mysql.com/

 

2, click to download the community version Mysql

 

 

 

 

3, Download

 

 

 4, click to download Mysql community service

 

 

 

 

 

 

 5, Download:

Version history: https: //downloads.mysql.com/archives/community/

The latest version: https: //dev.mysql.com/downloads/mysql/

The current latest version is 8.0, I chose a new mysql-5.7.24-winx64.zip

 

 

 

 

Second, the installation

MySQL are two .msi installation file and .zip, .msi installation required

zip format their own decompression, after decompression in fact, MySQL is ready for use, but to the environmental variable configuration zip format is its own decompression
My Computer -> Properties -> Advanced -> Environment Variables
select the Path, add behind it: your path mysql bin folder: D: \ Software \ mysql- 5.7.24 \ bin

 

 

 

After you finish configuring the environment variables in [D: \ Software \ bin \ mysql-5.7.24] directory to add a new profile mysql.ini, at the same time create a data folder (used to store the database in the same directory bin data)

mysql.ini文件的内容如下
[mysql]

# 设置mysql客户端默认字符集
default-character-set=utf8

[mysqld]

#设置3306端口
port = 3306

# 设置mysql的安装目录
basedir=D:\Software\mysql-5.7.24\bin
# 设置mysql数据库的数据的存放目录
datadir=D:\Software\mysql-5.7.24\bin\data

# 允许最大连接数
max_connections=200

# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8

# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB

  


打开cmd,不需要进入安装目录(∵之前配置过环境变量),输入下面命令,回车,没有反应
mysqld --initialize-insecure --user=mysql

 

 

 

输入下面命令,回车,会提示安装成功
mysqld install

 

 

 

启动服务,输入如下命令,回车,启动成功后如下图
net start mysql

 

 

 

 若:net start mysql 提示:发生系统错误 2。 系统找不到指定的文件。

因为要用到MySQL数据库,从官网下载了Windows版本的MySQL Server,因为不是msi版本,所以在安装了时候出现了一些问题。

问题1. 提示:服务名无效。
这种情况一般是因为没有安装mysqld,在cmd中输入mysqld install,安装即可。

问题2. 安装后,要启动MySQL服务,输入net start mysql 提示:发生系统错误 2。 系统找不到指定的文件。

这个是因为MySQL的路径没有指定,解决办法是,先将MySQL卸载,cmd输入mysqld remove,提示成功后,切换到MySQL的目录,如C:\mysql8013,然后在执行安装mysqld install,成功后,再net start mysql,这时候就应该正常启动了。

 

 

服务启动成功之后,需要登录的时候输入命令(第一次登录没有密码,直接按回车过)

mysql -u root -p

 

 

 


修改密码(必须先启动mysql),执行如下命令回车,enter password也回车,密码一般设置为root,方便记忆
mysqladmin -u root -p password

 

 

 


退出exit 就行了,记住直接关闭cmd窗口是没有退出的,要输入exit才会退出啊

关闭mysql开机自启动

在运行中输入Services.msc

 

 

mysql右键属性,自动改成手动

 

 

 


三、Navicat图形化界面连接mysql

新建连接,填写连接ip和密码

 

 

 

查看是否连通

 

 

 

 

 

 

出现如下状况的原因:没有启动mysql:

 

 

 

Guess you like

Origin www.cnblogs.com/fanblogs/p/11927861.html