MYSQL local installation and problem solving

MYSQL local installation and problem solving

Preface

This article is quite detailed and even a bit cumbersome. Many steps are omitted in other tutorial documents, but I still want to write it out because I took a lot of detours at the time, and I hope you can avoid them. Of course, if you know the answer, you can skip this and choose the part you want to know.

1. Download the installation package

Open the MySQL official website download page: http://dev.mysql.com/downloads/mysql/

Select the appropriate version and platform

Select the first one and click Download to enter the real download page. You will find that you need to log in to download. If you are careful, you will find that there is No thanks, just start my download. Just click this link.

Download and unzip to the corresponding directory, here it is all placed in D:\mysql

After decompression, rename the folder to mysql according to your preference. All mysql decompression files are in this directory: D:\mysql

2. MySQL configuration

Open the folder C:\wamp-all\mysql-5.7.13 that you just unzipped and find the my-default.ini configuration file in it. This is the default configuration file. Copy your own and rename it to my.ini

Edit my.ini and configure the following basic information:

[mysql]
# Set the default character set of the mysql client to default-character-set=utf8
 
[mysqld]
# Set port 3306 port = 3306
# Set the installation directory of mysql to basedir=D:\mysql
# Set the storage directory of mysql database data datadir=D:\mysql\sqldata
# Maximum number of connections allowed max_connections=20
# The default character set used by the server is the 8-bit latin1 character set character-set-server=utf8
# The default storage engine that will be used when creating a new table default-storage-engine=INNODB

3. Install and start MySQL

Open the cmd command line tool as an administrator and cd to the bin directory of the unzipped file: D:\mysql\bin

1. Enter mysqld install and press Enter to run. When the installation is successful, it will be OK.

2. Initialize mysqld --initialize-insecure to automatically generate a root user without a password. mysqld --initialize automatically generates a root user with a random password. Here, select a root user without a password.

3. Run net start mysql again to successfully start mysql

It may be that MySQL was installed before but not deleted or deleted completely, resulting in an incorrect installation directory in 1. If you want to query, you can execute sc query mysql in c:\windows\system32 to check the service named mysql: To delete, you can execute sc delete mysql in the current directory to delete mysql, and then continue to execute 1

4. Enter the MySQL environment

1. Go to the bin directory and execute mysql -uroot (no password required)

2. Create a new user and authorize him

create user 'test'@'localhost' identified by 'your password';
grant all privileges on . to test@'localhost';

Enter mysql -utest -p in the command line and press Enter, then enter the password you just set to enter.

If you want to exit the sql environment and return to the normal cmd environment, enter exit and press Enter. Enter mysql again and execute step 3.

5. Configure environment variables

Configure MYSQL_HOME=D:\mysql in the environment variables, and then add MYSQL_HOME/bin to Path

6. Connect to MySQL

It will appear when connecting

Solution:

1. Open the cmd command line window and enter the bin directory of MySQL.

Execute the command:

mysql -u root -p

Enter password:

2. Execute the following command: (change the password to 123456)

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456'; 

3. Refresh permissions and execute commands:

FLUSH PRIVILEGES; 

4. Connection successful:

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM.

You may also be interested in:
  • MySQL installation diagram MySQL graphic installation tutorial (detailed instructions)
  • Installation and configuration of MySQL 5.6 under Windows with screenshots and detailed instructions
  • MySQL 5.6 (Win7 64-bit) download, installation and configuration graphic tutorial
  • MySQL 5.5 installation and configuration method graphic tutorial
  • CentOS 6.4 installation and configuration of LAMP server (Apache+PHP5+MySQL)
  • Install Apache and PHP under Linux; Apache+PHP+MySQL configuration strategy
  • Complete steps to install mysql5.7 on Mac (with pictures and text)
  • Graphic tutorial for installing mysql-5.6.4 under Linux
  • Summary of solutions for the problem that MySQL 5 cannot be started after installation (cannot start service)
  • Explain MySQL installation and login method under Linux

<<:  CentOS7 enables MySQL8 master-slave backup and daily scheduled full backup (recommended)

>>:  Vue implements the question answering function

Recommend

How to use ssh tunnel to connect to mysql server

Preface In some cases, we only know the intranet ...

Example of how to quickly delete a 2T table in mysql in Innodb

Preface This article mainly introduces the releva...

3 functions of toString method in js

Table of contents 1. Three functions of toString ...

What to do if the container started by docker run hangs and loses data

Scenario Description In a certain system, the fun...

Summary of basic knowledge points of MySql database

Table of contents Basic database operations 2) Vi...

How to implement gzip compression in nginx to improve website speed

Table of contents Why use gzip compression? nginx...

Introduction to reactive function toRef function ref function in Vue3

Table of contents Reactive Function usage: toRef ...

How to use Linux paste command

01. Command Overview The paste command will merge...

MySQL 8.0.11 installation and configuration method graphic tutorial

The installation and configuration methods of MyS...

About MYSQL, you need to know the data types and operation tables

Data Types and Operations Data Table 1.1 MySQL ty...

Solution to the problem that docker logs cannot be retrieved

When checking the service daily, when I went to l...

How to use a field in one table to update a field in another table in MySQL

1. Modify 1 column update student s, city c set s...

Let's talk in detail about the difference between unknown and any in TypeScript

Table of contents Preface 1. unknown vs any 2. Th...