MySQL configuration under Windows (first time)

Source: Internet
Author: User

Busy most of the day, finally configured, this article is dedicated to Windows not tried MySQL small white, do not spray

http://blog.csdn.net/z1074907546/article/details/51482718

1. First go to the official website www.mysql.com Download the latest version, my version is 5.7.13zip, is free to install, can be directly extracted to the desired place.

2. Environment variable configuration: computer-"Right"-"Properties-" Advanced system Settings-"advanced-" environment variables in the path to add the decompression place, such as I am the e-drive, join E:\mysql-5.7.13-winx64\bin

Attention! with \ Bin

3. In the extracted place E:\mysql-5.7.13-winx64 create a new My.ini file and add the following:

[client]port=3306default-character-set=utf8[mysqld]port=3306character_set_server=utf8# Extract Directory Basedir=e:\ mysql-5.7.13-winx64# extract directory under the data directory Datadir=e:\mysql-5.7.13-winx64\data Sql_mode=no_engine_substitution,strict_trans _tables

4. Start-"run-" cmd.

First CD E:\mysql-5.7.13-winx64\bin

Command: mysqld--initialize #直接初始化mysql to generate files in the Data folder.

Command: Mysqld-install #安装mysql

Command: net start MySQL #启动服务器

If successful, then 5 failure, self-Baidu a bit. Because it failed several times today. Forget exactly what was wrong.

5. Login

At this time with Mysql-uroot-p login, do not know the password, follow the steps to set the password.

1) Edit the My.ini file in the extracted directory and add it under the [Mysqld] entry

Skip-grant-tables

Restart MySQL after saving exit

① Click "Start", "Run" (shortcut key Win+r).

② STOP: Enter net stop MySQL

③ Startup: input net start MySQL

At this time in the cmd input mysql-u root-p can not password login, appear password: When the direct enter can enter.

(1) Enter MySQL database :

Usemysql> MySQL;

Show:
Database changed

(2) Set a new password for the root user and enter it at the command line:
mysql>
(version 5.7) update user set Authentication_string=password (' 123qwe ') where user= ' root ' and Host = ' localhost ';

Show:

Query OK, 1 rows affected (0.01 sec)
Rows matched:1 changed:1 warnings:0

(3) Refresh the database
mysql> flush Privileges;

Show:
Query OK, 0 rows Affected (0.00 sec)

(4) Exit MySQL:
Mysql> quit

Show
Bye

After the change, and then modify the My.ini this file, we just joined the "Skip-grant-tables" this line to delete, save the exit and then restart MySQL.

The modification is complete. Restart the MySQL service.

Login: Mysql-uroot-p123qwe

MySQL is ready to connect.

But at this point the operation seems to be incomplete, but also alter user ...

mysql> alter user ' root ' @ ' localhost ' identified by ' 123 ';

This also allows you to:

mysql> set password for ' root ' @ ' localhost ' =password (' 123 ');

And then:

mysql>quit;

Login:

Mysql-uroot-p123 will be able to log in directly.

You can then enter mysql-uroot-p directly from the command line

Password: 123

Enter!

By the way, attach the MySQL statement you learned today.

#建数据库mysql_shiyanCREATE database Mysql_shiyan; #查看数据库show databases; #使用 Mysql_shiyan databases Use mysql_shiyan# view table show tables; #新建表CREATE table name (column name a data type (data length), column name B data type (data length), column name C data type (data length)); For example: CREATE table employee (ID int), name        char (+), phone int), #插入数据INSERT into table name (column name A, column name B, column name C) VALUES (value 1, value 2, value 3), #查询数据SELECT * from employee; #约束约束类型: Primary key Default value unique foreign key non-null keyword: PRIMARY keydefault unique FOREIGN key not nul# directly using the copied source code on GitHub source/home/shiyanlou/ Desktop/sql3/mysql-03-01.sql#select statement Select the column name to query from table name WHERE restriction condition; (WHERE can not be filled out) SELECT name,age from employee WHERE     Age<25 OR age>30;    #筛选出age小于25, or age greater than 30SELECT name,age from employee WHERE age>25 and age<30; #筛选出age大于25, and age less than 30SELECT NAME,AGE,PHONE,IN_DPT from the employee WHERE IN_DPT in (' Dpt3 ', ' dpt4 '); SELECT NAME,AGE,PHONE,IN_DPT from the employee WHERE IN_DPT not in (' dpt1 ', ' DPT3 '); SELECT Name,age,phone from the employee WHERE phone like ' 1101__ '; #_代表一个 SELECT name,age,phone from employee WHERE name is like ' j% '; #% represents an indeterminate quantity select Name,age,salary,phone from Employee ORDER by salary DESC; # Sort results ASC L DESC Descending function Name: Countsumavg MAX min Function: Count sum average maximum minimum value select MAX (Salary) as max_salary,min (salary) from employ EE; #子查询SELECT Of_dpt,count (Proj_name) as Count_project from Projectwhere of_dpt in (SELECT IN_DPT from employee WHERE name= ' Tom '); #连接查询SELECT id,name,people_numfrom Employee,departmentwhere EMPLOYEE.IN_DPT = Department.dpt_nameorder by ID;

  

MySQL configuration under Windows (first time)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.