Windows install and uninstall mysql database and solve Navicat link error

Install mysql

1. Download the mysql installation package, unzip it to the directory to be installed, and open the corresponding mysql directory. For example, my unzipped directory is D:\testSql\mysql-8.0.22-winx64, then enter D:\testSql\mysql-8.0.22- winx64
Insert picture description here
2. The content of the new my.ini file is as follows

[client]
# 设置mysql客户端默认字符集
default-character-set=utf8
 
[mysqld]
# 设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=D:\\testSql\\testMySql
# 设置 mysql数据库的数据的存放目录,MySQL 8+ 不需要以下配置,系统自己生成即可,否则有可能报错
# datadir=C:\\web\\sqldata
# 允许最大连接数
max_connections=20
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB

3. Open cmd as an administrator and enter D:\testSql\mysql-8.0.22-winx64\bin to
execute the following command

mysqld --initialize --console

Remember the initial password in this step (must remember the database password, it is easy to step on the pit if lost)
Insert picture description here
4. Execute the following command to complete the installation

mysqld install

5. Execute the following command to start MySQL

net start mysql

Then you can log in with mysql -uroot -p

The following error occurred when using Navicat to establish a database connection

Insert picture description here
Solution:

  1. Log in to mysql

mysql -uroot -p

  1. Execute the following command

alter user ‘root’@‘localhost’ identified with mysql_native_password by ‘123456’;

Insert picture description here
Continue to execute (focus, if the statement is not executed at a time, the new password and the old password can not be posted, and can only be reinstalled)

flush privileges;

Insert picture description here
Create a new link again, success

Uninstall and reinstall mysql

Enter the installation directory D:\testSql\mysql-8.0.22-winx64\bin and execute the following command

sc delete mysql

2. Exit the directory and open the task manager to end the mysql process
3. Back up the my.ini file
4. Delete the decompressed file
Insert picture description here
5. Re-extract the mysql installation package
6. Move the my.ini file into D:\testSql\mysql-8.0.22 -Under winx64, use the administrator identity to open cmd to
execute the same command when installing

mysqld --initialize --console
mysqld install
net start mysq
mysql -uroot -p

Guess you like

Origin blog.csdn.net/qq_40969782/article/details/113611554