MySQL is a very popular relational database management system. The installation package launched on the official website comes in two formats: ZIP format and MSI format. For the MSI format, you can directly click to install it and follow the installation prompts given by it. Generally, MySQL will be installed in the directory C:Program FilesMySQLMySQL Server x.x (x.x is the version number); the ZIP format needs to be decompressed by yourself. MySQL is ready to use, but it needs to be configured. I use ZIP format, so here I will mainly describe the download, installation and configuration of MySQL in ZIP format.
One. Tools
Win7 64-bit operating system
II. Steps
Step 1: Download the installation package
Download address: http://www.mysql.com/
As of now (2016/7/24), the latest version on the official website is 5.7.13, but I have not used this version. I downloaded the previous version 5.6.31.
The platform defaults to Windows.
Confirm your machine word length and click download.
Step 2: Unzip
After unzipping, you can rename the folder and put it in a suitable location. I renamed the folder MySQL Server 5.6 and placed it in the D:Program FilesMySQL path. Of course, you can also place it anywhere you want.
Step 3: Configuration (don’t rush to use it, it’s best to configure it first)
After configuring the environment variable PATH, you can open mysql in the future without switching directories. Principle: Simply put, the PATH in the environment variable is the search directory path of the cmd system. When you enter a command, how does the system know whether the command exists? How does the system do it? In fact, the system searches in the current directory and the path in the system environment variable PATH. The first one found shall prevail. If it cannot be found, an error will be reported. Therefore, after setting PATH, you can save the trouble of switching directories with commands every time. To use an analogy: the system is like a bus that follows a predetermined route. The path in the environment variable is the driving route. When you get to a station (find the first directory), get off (run).
Process: Computer—>System Properties—>Advanced System Configuration—>Environment Variables
Select PATH and add after it: the path of your mysql bin folder (for example: mine is: D:Program FilesMySQLMySQL Server 5.6bin) The modified PATH is:
PATH=…….;D:Program FilesMySQLMySQL Server 5.6bin (Note: 1. A semicolon under English input must be added after the original PATH; 2. It is appended, not overwritten.)
Step 4: Modify the configuration file
After configuring the environment variables, do not start mysql. You also need to modify the configuration file. The default configuration file for mysql-5.6.1X is in D:Program FilesMySQLMySQL Server 5.6my-default.ini. You can create a my.ini file yourself. , modify the configuration in it:
[mysqld] basedir=C:Program FilesMySQLMySQL Server 5.6 (the directory where mysql is located) datadir=C:Program FilesMySQLMySQL Server 5.6data (the directory where mysql is located data)
The content of mydefault.ini is as follows:
my.ini content is as follows:
Step 5: Install mysql
First, run cmd as an administrator (it must be run as an administrator, otherwise you will not have enough permissions and an error will occur)
Then, enter the D:Program FilesMySQL Server 5.6bin directory,
Then, execute the command mysql –install. If there are no errors, it will prompt that the installation is successful.
Note: If mysql has been installed before but was not uninstalled for some reason, when you install mysql again, you will be prompted that this service already exists. You can use the sc delete mysql command to delete the previous version, and then execute the mysqld –install command.
Step 6: Start the mysql server
Enter the net start mysql command in cmd.
Step 7: Log in to mysql
In cmd, enter mysql –u root –p. There is no password for the first login. Just press Enter and the login is successful.
The command to exit mysql is exit. Directly closing the cmd window will not exit. You have to enter exit to exit.