In the learning process need to build local mysql service, this section will build process record
1, download the official mysql service, https: //dev.mysql.com/downloads/mysql/ download the corresponding service version
2, from the following installation procedure: https: //jingyan.baidu.com/article/7e44095387e9a16fc1e2ef3b.html
1. initialize the database
-
Using Notepad, paste the field will look into Notepad, Notepad and rename my.ini.
[client]
default-character-set=utf8
[mysqld]
port = 3306
basedir = E: \\ mysql-8.0.18-winx64 (see their placement directory)
max_connections=20
character-set-server=utf8
default-storage-engine=INNODB
-
①win + r key, enter cmd, terminal open.
②cd to the bin directory, execute mysqld --initialize --console;
After performing generation:
①root initial user and password;
② automatically generated data folder in the mysql-8.0.18-winx64 folder is the database folder.
END
2. Set the server environment variables;
-
Because mysql.exe (client) and mysqld.exe (server) and other executable files in the bin directory. Then put the bin directory to environment variable system.
步骤(win10系统):右键此电脑--属性-高级系统设置--高级--环境变量--Path--编辑--新建--E:\mysql-8.0.18-winx64\bin。
然后确定每一个界面返回。
-
设置完成后需要重启终端,此时就可直接输入mysqld, 和mysqld命令了。
但还没有搭建成功,还需要安装windows服务。
END
3.启动和停止mysql服务
-
如果是用installer安装的mysql会自动设置mysql服务,但压缩包安装的需要设置mysql服务。
打开cmd,输入 "E:\mysql-8.0.18-winx64\bin\mysqld" --install
目录根据自己的安装目录,注意有引号。
若要移除mysql服务,在终端上输入"E:\mysql-8.0.18-winx64\bin\mysqld" --remove。
-
安装成功后,可以启动Windows服务查看:
win+r键,输入 services.msc 打开服务;可以看到有一项Mysql服务。但此时的服务没有启动。
-
方法1:
在cmd 输入 net start mysql,(启动服务)
在cmd 输入 net stop mysql,(停止服务)
方法2:
打开windows 服务(如上步2所述), 可点击‘启动/停止’来操作(这里不再上图说明)。
-
更改密码命令是:ALTER USER 'root'@'localhost' IDENTIFIED BY'密码'; 。
至此,所有设置完成,可以使用并操作MySQL。