Mysql 5.6.17 Green Edition (Installation-free) installation and configuration tutorial, 5.6.17 installation and configuration tutorial

Source: Internet
Author: User
Tags mysql host

Mysql 5.6.17 Green Edition (Installation-free) installation and configuration tutorial, 5.6.17 installation and configuration tutorial

I recently used the MySql database for project development. After reading some articles about MySql, I quickly started using it. Some problems still occur in the process of use, because the green installation-free version of MySql is used, so some problems occur during configuration, this article mainly discusses the configuration and usage of MySql Green Edition.

I. MySql Overview
MySql database is developed by MySql AB in Sweden and is now owned by Oracle. Similar to SQL Server, MySQL is also a relational database management system. In terms of Web applications, MySQL is one of the best RDBMS because it is a lightweight RDBMS. The latest MySql version is 5.6.17. Latest: Latest.

Ii. MySql Configuration

Since MySql is based on SQL, it includes basic DML, DDL, and DAL. These basic database languages are easy to use, in addition, MySql also encapsulates many database operation commands, which are run in the dossystem. This is different from SQL Server. The MySql environment is stored on the dossystem, use the doscommand. It is a bit similar to java. It can be said that it is also built on a virtual machine and can be used everywhere at a time. To use the MySql Command conveniently, you also need to set some prerequisites. The setting method is similar to the Java environment variable. The following method prevents the MySql version from being installed as an example to demonstrate its configuration method.

1. MySql environment Configuration

You can use the MySql Command anywhere by configuring the MySql decompression path to the system variables.

Note: This is the configured system variable. any third-party command that uses console commands can be added to the system variable. The system variable is a link. When using the command, the system variable is preferentially searched.

2. MySql Server Configuration 

After the system environment variables are configured, you can use all the services provided under MySql bin. Next, you need to install MySQL in the system.
2.1 install the MySql server

Open the decompressed file directory, find the file with the extension name. ini, copy a file named my. ini, and replace the original content with the following content.

[Mysqld] basedir = D:/Program Files (x86)/MySql # Set the mysql installation directory datadir = D:/Program Files (x86) /MySql/data # Set the data storage directory of the mysql database, which must be data, or/xxx/data ******** * ********* port = 3306 socket =/tmp/mysql. sockdefault-character-set = gbk # set the character set skip-lockingkey_buffer for the mysql server = bytes = 1Mtable_cache = 4sort_buffer_size = 64Kread_buffer_size = bytes = 2Kthread_stack = 64 K [client] # password = your_passwordport = 3306 socket =/tmp/mysql. sockdefault-character-set = gbk

************************** Line*************************

Note:[Mysqld] the following basedir and datadir must be set to the decompressed path of the file. Here, the author places the file under D: \ Program Files (x86) \ MySql. In addition, the content in the preceding split line is optional. You can set it again when creating a database. We recommend that you do not add it when creating the database because there are many uncertainties.

After configuring the my. ini file, you can install the mysqld service in cmd. Run the following command in cmd:Mysqld -- install MySQL -- defaults-file = "D: \ Program Files (x86) \ MySql \ my. ini"MySQL is the name of the Installation server. You can specify any name. After the installation is complete, the following message is displayed: Service successfully installed, indicating that the installation is successful. After the installation is successful, the Service is added to the system Service group policy. You only need to enable the Service when using the Service.

Note:When running the installation command, you must pay attention to the path issue in cmd. The path must be in the path of mysql bin. For example, decompress mysql to D: \ Program Files (x86) in the \ MySql folder, the current cmd path must be D: \ Program Files (x86) \ MySql \ bin. Otherwise, an error message will appear when the service is started after installation: system Error 2. The system cannot find the specified file.

2.2 start the server

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

2.3 stop the server

After use, you can run the command to stop the server, and run the command: net stop MySQL in cmd.

2.4 view the name and password of the design Server

The default name of the newly installed server is root. There is no password at this time. You can use the cmd command to set the name and password. The command is mysql-u root. In addition, you can use the update statement in cmd to modify the root password. The specific setting method is as follows:

1) Add a password ab12 to the root user.

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

 Note:Because the root account does not have a password at the beginning, the old-p password can be omitted.

2) Change the root password to djg345: mysqladmin-u root-p ab12 password djg345.

2.5 Delete A service:Mysqld -- remove MySQL

Use the remove command, followed by the name of the Database Service to be deleted.

Iii. MySql Common commands

3.1 Connection Service

The following describes two Connection Methods: Local Connection and remote connection.

3.1.1 local connection

In cmd, enter and run the command mysql-u root-p and enter the password. Note that there can be no space between the user name-u and the user name, that is,-uroot is also correct, but there must be a space between the password and-p. If you have just installed MYSQL, the default root user name has no password. Enter mysql-u root to enter MYSQL. The MYSQL prompt is: mysql>.

3.1.2 remote connection

If the IP address of the remote host is 219.243.79.8, the username is root, and 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 new users added

3.2.1 superuser

Add a user named "test1" with the password "abc" so that he can log on to any host and have the permission to query, insert, modify, and delete all databases. First, use the root user to connect to MYSQL, and then type the following command:

Grant select, insert, update, delete on *. * to [email = test1 @ "%] test1 @" % [/email] "Identified by" abc ";

However, the added users are very dangerous. If someone knows the password of test1, then he can log on to your mysql database on any computer on the internet and do whatever he wants for your data. See solution 2.

3.2.2 Add a user named "test2" as abc for the local user so that the user can only log on to localhost, you can also query, insert, modify, and delete the database mydb (localhost refers to the local host, that is, the host where the MYSQL database is located), so that the user knows the password of test2, he cannot access the database directly from the internet, but can only access the database through the web pages on the MYSQL host.

Grant select, insert, update, delete on mydb. * to [email = test2 @ localhost] test2 @ localhost [/email] identified by "abc ";

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

Grant select, insert, update, delete on mydb. * to [email = test2 @ localhost] test2 @ localhost [/email] identified by "";

3.3 show command

The show command is used to view some list information in MySql. For example, show databases displays the names of all databases, and show tables displays the names of all tables in a database.

3.4 database operations

Before the operation, you need to enter the relevant database. You can use the use command, for example, use testdb to enter the database named testdb. after entering the database, you can operate on objects in the database, the corresponding operation commands use SQL statements, DDL, DML, and DAL.

3.4.1 view database content

1) view the field information of a table in the database: desc table name;

2) view the statement for creating a database table: show create table name. Of course, you can use the same method to view other SQL statements for creating a database, such as the statement for creating a database, name of the show create database.

3.4.2 modify the column type and name in the table

(1) only modify the column type

Alter table database name. table Name modify column name data type. For example, you can set the sex column of the t_animal table to the boolean Type:

alter table t_animal modify sex boolean not null

(2) modify the column name and column data type at the same time
Alter table name change column old column name new column name data type, for example: change the sex column of t_animal table to ani_sex, and change the data type to boolean:

alter table t_animal change column sex ani_sex boolean not null

Conclusion

This article makes a preliminary summary of the configuration and usage of MySql. MySql still has a lot of content to accumulate in use, and this article will also add new content from time to time, it is mainly updated in the development process.

I have tested all the commands in this article. Please point out what is wrong with each other.

The above is all the content in this article. I hope it will be helpful for your learning and support for scripts.

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.