How to install mysql5.7 using commands in windows, windowsmysql5.7

Source: Internet
Author: User

How to install mysql5.7 using commands in windows, windowsmysql5.7

Decompress the zip package and create the my. ini file as follows:

Note that SQL _mode is written here to make MySQL use habits similar to Oracle.

[Mysql] # set the default character set of the mysql client default-character-set = utf8 [mysqld] SQL _mode = 'no _ AUTO_VALUE_ON_ZERO, STRICT_TRANS_TABLES, records, NO_ZERO_DATE, expiration, NO_AUTO_CREATE_USER, ANSI_QUOTES '# Set port 3306 port = 3306 # Set mysql installation directory basedir = E: \ mysql-5.7.13-winx64 # Set the mysql database data storage directory datadir = E: \ mysql-5.7.13-winx64 \ data # maximum number of connections allowed max_connections = 200 # the character set used by the server defaults to an 8-bit latin1 character set character-set-server = utf8 # The default storage that will be used when creating a new table engine default-storage-engine = INNODB

Initialize and start the Mysql service:

1. Run cmd as Administrator (note that Windows 10 must run cmd as Administrator)

2. Go to the mysql bin

3. initialize and generate the data folder

> Mysqld -- initialize-insecure (it is recommended that you do not set the root password)> mysqld -- initialize (generate a random root password-this root password will be displayed in the command prompt line, be sure to write down ...... Or tragedy)

After the command is executed, a data folder will be generated in the mysql file directory for a longer time.

3. Install the MySql Service

 >mysqld -install

4. Start mysql

 >net start mysql

Log on to mysql

>mysql -u root -p

When logging on for the first time, you do not need to enter the password to log on directly.

After logging on to mysql, set the root password

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

Or use mysqlamdin to change the root password.

>mysqladmin -u root -p password NewPassword

After changing the password, we can use root to log on successfully.

Next we will create a new user using lwjs as an example.

1. Create a database

create database lwjs;

2. Create a user and authorize

CREATE USER 'lwjs'@'%' IDENTIFIED BY'lwjs';GRANT ALL PRIVILEGES ON lwjs.* TOlwjs@localhost IDENTIFIED BY 'lwjs' WITH GRANT OPTION;GRANT ALL PRIVILEGES ON lwjs.* TO lwjs@'%'IDENTIFIED BY 'lwjs' WITH GRANT OPTION;

Pay attention to ON lwjs. * The create user, PROCESS, RELOAD, replication client, replication slave, show databases, SHUTDOWN, and SUPER permissions cannot be authorized in this method, this is mainly because this permission applies to all users, not to a user in a database. Therefore, if you really want a permission, use grant reload on *. * to lwjs @ 'localhost'. If you want security, some permissions should only allow local operations. Of course, if you want to save trouble, you can directly use the on *. * above so that the user has all permissions.

Here, lwjs. * indicates that the user only has permissions for the lwjs database.

Lwjs @ locallhost and @ '%' means that you can log on to the local machine in a wide range of '%' with any other ip address. For example, I can limit that only users in a certain network segment can connect

After creation, you can log on normally.

3. Import Data

After the file is selected, the following prompt box indicates that an error occurs and you must not select it.

Data is being imported. Wait until execution is complete.

The above section describes how to install mysql5.7 using commands in windows. I hope it will help you. If you have any questions, please leave a message, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!

Related Article

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.