Mysql5.7.11 Green Edition Installation Tutorial

Source: Internet
Author: User
Tags mysql commands mysql host mysql in


1, decompression mysql-5.7.11 compression package to the disk folder you want to store;

2. Create a new Data folder in the folder and create a new My.ini file, and configure the My.ini file

My.ini file contents: Key points for configuring the data directory and storage root directory in the MySQL folder

3, in My Computer--Properties--Advanced system settings--environment variables--Configure the path variable;


4. Open the Cmd.exe program with administrator status

5. Initialize the new Data folder

Command 1:> mysqld--initialize-insecure ; (no root password after initialization, recommended)

Command 2:> mysqld–initialize ; (randomly produce a root password after initialization)

The Data folder after successful execution


6. Install MySQL Service

Command:>mysqld-install

7. Start MySQL

Command:>net start mysql

Command:> mysql -u root -p (first login if no password can directly press ENTER login)

9. Set User password

Command:>setpassword for [email protected] = password(‘new password‘);

Key commands:

Command 1:> mysqld--initialize-insecure ; (no root password after initialization, recommended)

Command 2:> mysqld–initialize ; (randomly produce a root password after initialization)

Command:>mysqld-install

Command:>net startmysql

Command:>mysql -uroot -p

Command:> setpassword for [email protected] = password(‘new password‘) ;

10, through the user, password into the MySQL service

Simple test operation:

1, show databases; List of all databases

2, create database dbName; Create a database

3, use DbName; Select Database

4, show tables; Display a list of data tables

Now that MySQL is based on SQL, it contains basic DML, DDL, DAL, and these basic database languages are easy to use,

In addition, MySQL also encapsulates a lot of database operations commands, these commands are running in the DOS system, which is the difference between him and SQL Server, MySQL environment is the resume on the DOS system, to use DOS command.

It's a bit like Java, which can be said to be built on a virtual machine and can be used once and for all.

To easily use the MySQL command also requires a few prerequisites to set, set the method is similar to the Java environment variables, the following method to avoid the installation version of MySQL as an example to demonstrate its configuration method.

1. mysql Environment configuration

You can use MySQL commands anywhere by configuring the decompression path of MySQL into a system variable.

Note: This is a configured system variable, and any third-party commands that use console commands can be added to system variables, which are a link to the system variables when using commands.


2. mysql server configuration

After configuring the system's environment variables, you can use all the services provided under MySQL's Bin, and then you will need to install MySQL in the system.

2.1 Installing the MySQL server

Open the Unzip file directory, locate the file with the suffix. ini, copy the name to My.ini, and replace the original content with the content below.

[Mysqld]basedir=d:/program Files (x86)/mysql # Setting up the installation directory for MYSQL Datadir=d:/program Files (x86)/mysql/data # Set the data storage directory for the MySQL database, must be either data, or//xxx/data ************************* split line *******************port = 3306socket =/tmp/ MYSQL.SOCKDEFAULT-CHARACTER-SET=GBK # Sets the character set of the MySQL server Skip-lockingkey_buffer = 16kmax_allowed_packet = 1Mtable_cache = 4sort_buffer_size = 64kread_buffer_size = 256kread_rnd_buffer_size = 256knet_buffer_length = 2Kthread_stack = 64K [Clien T] #password = Your_passwordport = 3306socket =/tmp/mysql.sockdefault-character-set=utf-8

Split Line *************************

Note: [Mysqld] The following basedir and DataDir need to be set to the file after extracting the path, where the author put the file in D:\Program files (x86) \mysql.

In addition, the contents of the above split line are optional and can be reset when the database is created, and it is recommended not to be added at the time of creation because there are many uncertainties.

After the My.ini file is configured, you can install the Mysqld service in CMD, run the command in cmd:mysqld--install MySQL--defaults-file= "D:\Program files (x86) \mysql\ My.ini ",

Where MySQL is the name of the installation server, you can specify any name.

After the installation is complete, the following information is prompted: Service successfully installed, that is, the successful installation, the successful installation will be in the system's service Group Policy to add the service, in use only need to open.

Note: when running the install command, be sure to note the path problem within the CMD, which must be in the path of the MySQL bin,

For example, if my MySql is extracted to the D:\Program files (x86) \mysql folder, then the cmd current path must be D:\Program Files (x86) \mysql\bin,

Otherwise, an error message occurs when you start the service after the installation is complete: System error 2. The system cannot find the file specified.

2.2 Starting the server

Start the MySQL server, run the command in cmd: net start MySQL.

2.3 Stopping the server

After use is complete, you can stop the server from running by command by running the command in cmd: net stop MySQL.

2.4 View Design server name and password

Server just installed its default name is root, there is no password at this time, you can use the cmd command to set the name and password. The corresponding command is: Mysql-u root. Alternatively, you can modify the root password by using the UPDATE statement in CMD, as shown in the following code:

1), add a password to root ab12

First enter directory Mysql\bin under DOS, and then type the following command: mysqladmin-u root-p password ab12.

Note: because Root does not have a password at the beginning, the-p old password can be omitted.

2), then change the root password to djg345:mysqladmin-u root-p ab12 password djg345

2.5 Delete Service:mysqld--remove MySQL

Use the Remove command, followed by the name of the database service you want to delete.

Third, MySQL common commands

3.1 Connection Service

Here are two ways to connect to local and remote connections, respectively.

3.1.1 Local Area Connection

Enter and run the command in cmd: Mysql-u root-p, then enter the appropriate password.

Note that there can be no space between the user name-U and the user name, i.e. the-uroot is equally correct, but there must be a space between the password and-P.

If it is just installed MySQL, the default root username is no password, the direct input mysql-u root can enter MySQL, MySQL prompt is:mysql>.

3.1.2 Remote Connection

Assuming the IP address of the remote host is: 219.243.79.8, the user name is root, the password is 123, run the following command in CMD: mysql-h219.243.79.8-uroot-p 123.

3.1.3 Exit MySQL command: Exit

3.2 Adding new users

3.2.1 Super users

Add a user test1 password to ABC so that he can log on on any host and have access to queries, insertions, modifications, and deletions to all databases. First connect to MySQL with the root user, and then type the following command:

Grant Select,insert,update,delete on * * to [[email protected] '%][email protected] '%[/email] ' identified by ' ABC ';

But the added user is very dangerous, you want to like someone to know test1 password, then he can be on any computer on the Internet to log into your MySQL database and your data can do whatever you like, solution see 2.

3.2.2 Native User

Add a user test2 password to ABC, so that he can only login on localhost, and the database mydb can be queried, inserted, modified, deleted operations (localhost refers to the local host, that is, the MySQL database is located on the host),

This allows the user to use a password that knows test2, and he cannot access the database directly from the Internet, but only through a Web page on the MySQL host.

Grant Select,insert,update,delete on mydb.* to [[E-mail Protected]][email protected][/email] identified by "ABC";

If you do not want to test2 have a password, you can call another command to erase the password.

Grant Select,insert,update,delete on mydb.* to [[E-mail Protected]][email protected][/email] identified by "";

3.3 Show Command

The show command is meant to be viewed and can be used to view some of the list information in MySQL, such as: show databases displays the names of all the databases; Show tables displays all the table names in a database.

3.4 Operational databases

Before the operation to enter the relevant database, you can use command, such as: using TestDB into the database named TestDB, after entering the database can be both in the database operation of the object, the corresponding operation command using SQL statements, DDL, DML, DAL.

3.4.1 Viewing the contents of a database

1), view the database of a table field information: DESC table name;

2), view the database table creation statement: Show create table table name; Of course, the same method can be used to view other SQL statements that create content, such as viewing the database creation statement, show create database name.

3.4.2 Modifying column types and names in a table

(1) Modify column type only

ALTER TABLE database name. Table name Modify column name data type, for example: The sex column of the T_animal table is the Boolean type:

ALTER TABLE T_animal modify sex Boolean NOT null

(2) Modify both the column name and the column data type
ALTER TABLE name change column old column name data type, for example: Rename the T_animal table's sex column to Ani_sex and the data type to a Boolean type:

ALTER TABLE t_animal change column sex Ani_sex boolean NOT null

Conclusion

This article has made a preliminary summary of the configuration and use of MySQL, MySQL has a lot of content in the use of slowly accumulated, and the article will also add new content, mainly for the development process of the situation and update.

The article commands the author have carried on the test, there is what wrong place also please point out to learn from each other.

Mysql5.7.11 Green Edition Installation Tutorial

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.