Mysql download and installation and problem solving

1. Download

  1. 地址:MySQL :: Download MySQL Community Server (Archived Versions)

2. Installation

  1. There are two types of MySQL installation files. msi and .zip, and .msi needs to be installed (I am zip)

  1. Environment variable configuration

My Computer -> Properties -> Advanced -> Environment Variables

Select Path and add after it: the path of your mysql bin folder:

D:\MySQL\mysql-5.7.24-winx64\bin

  1. Add a new configuration file mysql.ini in the D:\MySQL\mysql-5.7.24-winx64 directory, and create a data folder (used to store database data) in the same directory as bin

  1. The content of the mysql.ini file is as follows

[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8 
[mysqld]
#设置3306端口
port = 3306 
# 设置mysql的安装目录
basedir=D:\MySQL\mysql-5.7.24-winx64
# 设置mysql数据库的数据的存放目录
datadir=D:\MySQL\mysql-5.7.24-winx64\data
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
explicit_defaults_for_timestamp=true
  1. win+R to open cmd (run as an administrator), no need to enter the installation directory, enter the following command, press Enter, no response

mysqld --initialize-insecure --user=mysql

! Questions I would have:

Reason: The reason for reporting this error is because your mysql database has already been initialized, so you cannot use this method to initialize users again, because mysql will automatically create a root user during initialization.

solve:

(38 messages) [MySQL] initialize specified but the data directory has files in it. Aborting_Wang Xiaotr1912's Blog-CSDN Blog_initialize specified

(I ran this command as a non-administrator and it succeeded, so in the case of an administrator, it said that it had been initialized, so I ignored him and ran the following command directly)

5. Enter the following command and press Enter, it will prompt that the installation is successful

mysqld install

! Question 1 that would arise for me:

提示“Install/Remove of the Service Denied!”

Reason: The reason for prompting this question is that there is no permission, and you need to run cmd as an administrator.

solve:

! Question 2 that would arise for me:

reason:

Mysql has been installed before and has not been deleted

solve:

 1. Run as an administrator, enter sc query mysql, and check the service named mysql:

发现之前确实有安装过。

 2.命令sc delete mysql,删除该mysql

3、继续安装,安装成功

6、启动服务,输入如下命令,回车,启动成功后如下图

net start mysql

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

mysqladmin -u root -p password

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

mysqladmin -u root -p password

三、navicat导入mysql数据库

在桌面上,我有一个db_shop_wgsc.sql的数据库文件需要导入到navicat中运行。

  1. 点开localhost_3036,右击点击新建数据库:

  1. 左键点击新建数据库后,创建一个跟你需要导入的数据库名字一模一样的新的mysql数据库。

3:创建完成后,在左侧便会出现db838,接下去是最关键的一步:右键点击db_shop_wgsc,点击“运行sql文件”

4:选择需要导入的.sql数据库文件,并导入进去

5:点击开始后,即可成功导入

6:这是最后一步了,一定要点击db838,然后按住F5进行刷新,否则的话会显示不出导入的文件

Guess you like

Origin blog.csdn.net/sinat_62012394/article/details/128486206
Recommended