Detailed explanation of Mysql 5.7.18 installation method and the process of starting MySQL service

Detailed explanation of Mysql 5.7.18 installation method and the process of starting MySQL service

MySQL is a very powerful relational database. However, some beginners encounter various difficulties during installation and configuration. I will not talk about the installation process here, but will talk about the configuration process. When you download MySQL from the official website, there are msi and zip formats. You can directly run the Msi installation, and unzip the zip file to your favorite directory address. When installing both of these, you need to configure them before you can use them. The following introduction mainly focuses on the default address of the msi format: C:\Program Files\mysql-5.7.18-win32.

one. After installation or decompression, you need to configure environment variables. The process is as follows: My Computer -> Properties -> Advanced System Settings -> Advanced -> Environment Variables. In System Variables, click Path and select Edit. Add "C:\ProgramFiles\mysql-5.7.18-win32\bin;" What needs to be noted here is that it is not covering! Also, it is best to add it at the very beginning. The British semicolon ";" cannot be omitted. (You can also insert it in the middle, but remember to add it after ";".)

two. Click the Start menu, search for cmd.exe, left-click and run as administrator. Be sure to run it as administrator! ! !

If you run cmd directly, when you enter mysqld -install, an error will appear due to insufficient permissions: Install/Remove of theService Denied!

When you correctly enter mysqld –install and press Enter, it will display The service already exists!

three. Then enter net start mysql to start the server. If it shows that the server startup failed, as shown in the figure below.

This is because in versions 5.7 and above, there is no data folder in the C:\Program Files\mysql-5.7+ directory. Here, remember not to copy the data folder of other versions of MySQL. Instead, enter mysqld--initialize-insecure --user=mysql in the window. Note that there is a space before the "--", then press Enter. (It takes half a minute to wait, depending on the speed of the computer)


(In the C:\ProgramFiles\mysql-5.7.18-win32 directory, there is no data folder. As shown below)

    

Note: In versions below 5.7, you need to modify my-default.ini in the C:\ProgramFiles\mysql-5.* directory. Right-click and edit.

basedir=……
datadir=…..

Modified to

basedir= C:\Program Files\mysql-5.*
datadir= C:\Program Files\mysql-5.*\data

That's it, where "C:\Program Files\mysql-5.*" is determined by the actual installation location

Four. In the C:\ProgramFiles\mysql-5.7.18-win32 directory, it shows that the data folder was created successfully.

After creating the data, enter mysqld –install and press Enter (if the startup is successful in step 3, you do not need to enter it again)

five. After the service is successfully started, you can log in. Enter mysql -u root –p and press Enter. Enter password will appear. Since no login password is set, you don’t need to enter anything. Just press Enter.

After pressing Enter, as shown below, the MySQL configuration has been successful!


After the service is started, because the newly created root user has an empty password, you need to set the password first. The following commands can be executed:

mysqladmin -u root -p password Enter the new password here

Enter password: Enter the old password here

After executing the above two commands, as long as the old password entered after Enter password: is correct, the new password for the root user is set successfully. After this, you will need to use the new password to log in to the root user.
Note: The newly created root user has an empty password. Therefore, when you change the root user's password for the first time, you do not need to enter any password after Enter password:. Just press Enter.

At this point, the decompression and installation of MySQL v5.7.18 has been completed. Therefore, you need to stop the previously started MySQL service by executing the following command:

net stop mysql

Log in and use MySQL

The MySQL database has been installed. Once the installation is successful, you can log in as the root user and perform data operations such as creating tables, adding, deleting, modifying, and checking data. Here is the simple process:

Open cmd as an administrator and switch to the bin directory of the mysql installation directory

net start mysql // Description: This command starts the mysql service mysql -u root -p // Description: This command is used to log in as the root user

Enter password: The password of the root user previously set

After logging in correctly, you can perform operations on the data such as adding, deleting, modifying, checking, etc. Example:

mysql> show databases; // Display all databasesmysql> select statement............
...

When you no longer use the database, you need to log out of the user and stop the service by executing the following command:

mysql> quit;
net stop mysql

Deleting a Database

If you no longer want to use mysql, you can execute the following command:

mysqld --remove

The above is the detailed description of the installation method of Mysql 5.7.18 and the process of starting the MySQL service introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • Analysis and Solution of ERROR:2002 Reported When MySQL Starts
  • Solution to the problem that the InnoDB engine is disabled when MySQL is started
  • How to solve "Unable to start mysql service error 1069"
  • Solution to the problem that the configuration file my.cnf in MySQL cannot be started due to permission issues
  • How to solve the problem that MySQL cannot start because it cannot create PID
  • Solve the problem that the service cannot be started when installing the decompressed version of mysql 5.7.18 winx64 on Win7 x64
  • Solution to MySQL failure to start

<<:  Example of configuring multiple SSL certificates for a single Nginx IP address

>>:  How to get the width and height of the image in WeChat applet

Recommend

Sharing several methods to disable page caching

Today, when developing, I encountered a method wh...

Quick understanding of Vue routing navigation guard

Table of contents 1. Global Guard 1. Global front...

Steps for encapsulating element-ui pop-up components

Encapsulate el-dialog as a component When we use ...

A complete guide to clearing floats in CSS (summary)

1. Parent div defines pseudo-classes: after and z...

Detailed graphic tutorial on installing and uninstalling Tomcat8 on Linux

[ Linux installation of Tomcat8 ] Uninstall Tomca...

Today I encountered a very strange li a click problem and solved it myself

...It's like this, today I was going to make a...

Vue+SSM realizes the preview effect of picture upload

The current requirement is: there is a file uploa...

Detailed explanation of nginx installation, deployment and usage on Linux

Table of contents 1. Download 2. Deployment 3. Ng...

Quickly solve the Chinese input method problem under Linux

Background: I'm working on asset reporting re...

React State state and life cycle implementation method

1. Methods for implementing components:組件名稱首字母必須大...

JavaScript implements an input box component

This article example shares the specific code for...

In-depth understanding of this in JavaScript

In-depth understanding of this in Js JavaScript s...