First, download, install
1. Download
(1) Download
https://dev.mysql.com/downloads/mysql/
(2) I am here to download the latest version (8.0.18)
2, installation
(1) unpack and configure the environment variables
step1: Right-click on "My Computer", click Properties, select the Advanced Properties settings, add the environment variable PATH, add the path to the Path bin directory.
Hi如: E: \ soft \ mysql-8.0.18-winx64 \ bin
step2: View the current version. If successful version number is displayed, the environment variable configuration is successful.
mysql --version
(2) modify the configuration file (refer to the following :)
create a file my.ini bin directory.
my.ini as follows
[mysql]
# mysql client set the default character set
default Character-SET-UTF8 =
[mysqld]
default-Time-Zone = '+ 08:00'
# 3306 port disposed
Port = 3306
# Set mysql installation directory
basedir = E: \ Soft \ mysql-8.0.18-Winx64
# data set storage directory mysql database
DATADIR = E: \ Soft \ mysql-8.0.18-Winx64 \ data
# maximum number of connections
max_connections = 200 is
# character set used by the server the default is 8-bit coded character set latin1
character-set-server = utf8
default storage engine # when used to create a new table
default-storage-engine = INNODB
(3) the use of the administrator's run cmd (note: not an ordinary cmd window)
mysqld -install - used to install the database
mysqld --initialize-insecure --user = mysql - used to initialize the mysql, will re-create a bin in the same directory data folder
net start mysql - used to start the mysql service ( can be started manually)
NET STOP MySQL - for closing service
Second, the use of commonly used commands
1, access to the database
When mysql -uroot -p used to log database, the first landing MySql, enter the password, if not directly enter, then go find the data file folder (.err) file, locate the localhost, enter the password that is behind it can.
mysql -uroot -p
The first landing, you can directly press the Enter key.
2, change passwords
mysqladmin -u root -p password to change the password.
Note: You need (ie after the start mysql service, and then use the command) after net start mysql
mysqladmin -u root -p password
If the first change the password, enter the password and press Enter. (For example, here password 123456)
After modifying, enter password database.
3, exit the database
exit - Exit for Database
4, common commands (note; the end)
(1) in which to view the mysql database.
show databases;
(2) create a database.
[Format:]
create database database name; - used to create the database.
Examples:]
create database lyh default character set utf8; - create lyh database, and specify the default utf8 encoding (the default setting)
(3) delete the database.
[Format:]
drop database database name; - deletes a database.
Examples:]
drop database lyh; - delete lyh database
(4) the use of the database (to enter a database)
[Format:]
use the database name; - used to access a database
(5) view the current database in which table.
show tables;
(6) create table
- Create a table emp where id primary key and self-growth.
TABLE EMP the CREATE (
ID int Primary Key AUTO_INCREMENT,
name VARCHAR (50),
the salary Double,
Age int
);
(7) Delete table
drop table emp;
(8) New data
INSERT INTO emp(name, salary, age) VALUES('tom', 2000, 20);
Third, the graphical interface tool --Navicat
1. Download, install (self-Baidu crack version address)
(1) free 14-day Download
https://www.navicat.com.cn/download/navicat-for-mysql
(2) Installation
2, using
(1) Select the type of connection (MySQL)
(2) connecting to the database (mysql service to)