MySql Basics - Note 1 - Graphical Tutorial for Installation and Configuration under Windows

@TOC

1. Download

https://dev.mysql.com/downloads/mysql/

  • Open the above link and choose according to your own system (this article uses 64-bit system as an example)
  • If it is a 32-bit system, please select msi installation

2. Installation

  • The zip format does not need to be installed, the download is in the zip format, and it is directly decompressed to a certain directory. Note that the directory does not contain Chinese. The directory of this article is: D:\mysql-8.0.19-winx64

3. Set environment variables

  • Go to D:\mysql-8.0.19-winx64\bin, copy the path

  • Open "Start" - "Computer" in sequence, right-click and select "Properties", enter the following page, and click "Advanced System Settings":
  • Select "Environment Variables"
  • Find the path in the system environment variable
  • Add D:\mysql-8.0.19-winx64\bin at the end of the path (separate each path with English semicolons), and confirm

4. Configure the Mysql configuration file

  • Go to the D:\mysql-8.0.19-winx64\ directory and create a new my.ini configuration file in this directory
  • Edit my.ini to configure the following basic information:
[client]
# Set the default character set of the mysql client
default-character-set=utf8
 
[mysqld]
# Set port 3306
port = 3306
# Set the installation directory of mysql
basedir=D:\\mysql-8.0.19-winx64
# Set the data storage directory of the mysql database. MySQL 8+ does not need the following configuration, and the system can generate it by itself, otherwise an error may be reported
# datadir=C:\\web\\sqldata
# Maximum number of connections allowed
max_connections=20
# The character set used by the server defaults to the 8-bit encoded latin1 character set
character-set-server=utf8
# The default storage engine that will be used when creating new tables
default-storage-engine=INNODB

5. Start Mysql

Go to the D:\mysql-8.0.19-winx64\bin directory, hold down the shift key, right mouse button, select "Open command window here"

  • Initialize the database
mysqld --initialize --console


After the execution is complete, the above information will be output, where the password of the root user is the initial default password: vzSn9>6V(tjw, which will be used for subsequent logins

  • Enter the following install command
mysqld install

  • Start by typing the following command
net start mysql

6. Login to Mysql

  • If it is local and the environment variable has been added, enter it directly in cmd, press Enter in mysql:

  • If it is another installation method, enter the following command to open mysql,
mysql -h CPU name -u username -p

-h : Specify the MySQL host name that the client wants to log in to, this parameter can be omitted when logging in to the local machine (localhost or 127.0.0.1);
-u : login username;
-p : Tell the server that a password will be used to log in. If the user name and password to be logged in are empty, this option can be ignored.

  • If we want to log in to the local MySQL database, we only need to enter the following command:
mysql -u root -p
  • Press Enter to confirm, if installed correctly and MySQL is running, you will get the following response:
Enter password:

If the password exists, enter the password to log in, if it does not exist, press Enter to log in directly. After successful login, you will see the prompt Welcome to the MySQL monitor....
Then the command prompt will always wait for the input of the command with mysq> plus a blinking cursor, and enter exit or quit to log out.

7. Modify the Mysql default password

  • The first method: use the tool SQLyog or Navicat for MySQL to modify
    After logging in to the database, select the tool, enter the user management page and directly modify the password;
  • The second type:
Method 1: Use SET PASSWORD Order  
Format: mysql> set password for username@localhost = password('New Password');  
example: mysql> set password for root@localhost = password('123456');  

Method 2: use mysqladmin  
Format: mysqladmin -u username -p Old Password password New Password  
example: mysqladmin -u root -p 123456 password 123456  

Method 3: Method 3: Use UPDATE edit directly user surface   
mysql> use mysql; 
ysql> update user set password=password('123') where user='root' and host='localhost';  
mysql> flush privileges;  

Method 4: In forgetting root For the password, you can do this  
by windows For example:   
 - close the running MySQL Serve.  
 - Open DOS window, go to mysql\bin Table of contents.  
 - enter mysqld --skip-grant-tables Enter.--skip-grant-tables means start MySQL Skip permission table authentication when serving.  
 - open another DOS window (because the DOS window can no longer be moved), go to mysql\bin Table of contents.  
 - enter mysql Enter, if successful, will appear MySQL prompt >.   
 - Connect to the authority database: use mysql; .   
 - change Password: update user set password=password("123") where user="root";(Don't forget the semicolon at the end).  
 - Refresh permissions (required steps): flush privileges; .   
 - quit quit.   
 - Log out of the system, and then enter, using the username root Log in with the new password 123 you just set.

Tags: Database MySQL software testing

Posted by cool30 on Wed, 11 Jan 2023 10:57:41 +0530