mysql mysql notes of service to build and create a simple database table

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

 
  1. Get 'mysql-8.0.18-winx64' folder, and placed directly under a letter unzip the downloaded archive "mysql-8.0.18-winx64.zip", for example: I have here renamed directly placed under the E disk, open the folder with the contents of the figure.
    How to install and set up MySQL services
  2. Creating the initial configuration file:

    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

    How to install and set up MySQL services
  3. The server performs initialization commands;

    ①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.

    How to install and set up MySQL services
    END

2. Set the server environment variables;

 
  1. Each execution mysqld must turn the letter when you start a terminal, enter the long path, a lot of trouble.
    How to install and set up MySQL services
  2. 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。

    然后确定每一个界面返回。

    How to install and set up MySQL services
  3. 3

    设置完成后需要重启终端,此时就可直接输入mysqld, 和mysqld命令了。

    但还没有搭建成功,还需要安装windows服务。

    How to install and set up MySQL services
    END

3.启动和停止mysql服务

 
  1.  

    如果是用installer安装的mysql会自动设置mysql服务,但压缩包安装的需要设置mysql服务。

    打开cmd,输入 "E:\mysql-8.0.18-winx64\bin\mysqld" --install

    目录根据自己的安装目录,注意有引号。

    若要移除mysql服务,在终端上输入"E:\mysql-8.0.18-winx64\bin\mysqld" --remove。

    How to install and set up MySQL services
  2.  

    安装成功后,可以启动Windows服务查看:

    win+r键,输入 services.msc 打开服务;可以看到有一项Mysql服务。但此时的服务没有启动。

    How to install and set up MySQL services
  3.  

    启动和停止mysql服:

    方法1:

    在cmd 输入 net start mysql,(启动服务)

    在cmd 输入 net stop mysql,(停止服务)

    方法2:

    打开windows 服务(如上步2所述), 可点击‘启动/停止’来操作(这里不再上图说明)。

    How to install and set up MySQL services
  4. 此时可以登录root用户,登录后需要更改初始密码,

    更改密码命令是:ALTER USER 'root'@'localhost' IDENTIFIED BY'密码'; 。

    至此,所有设置完成,可以使用并操作MySQL。

    How to install and set up MySQL services
     
     Note Installation process "E: \ mysql-8.0.18-winx64 \ bin \ mysqld" --install possible error Install / Remove of the Service Denied !, administrator needs to run the cmd command window
     
    3. Create a database table

     

       Insert data:

     

     

     

     

     

Guess you like

Origin www.cnblogs.com/heertong/p/12118082.html