Mysql installation service cannot start the solution

1. Download MySQL8.0.12 version from the Internet, download address: https://dev.mysql.com/downloads/mysql/

2. Create a new my.ini file in the file directory, the code is as follows, change two of the working paths to your own according to the path.

[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=D:\google_Download\mysql-8.0.21-winx64
# 设置mysql数据库的数据的存放目录
datadir=D:\google_Download\mysql-8.0.21-winx64\data
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
max_connect_errors=10
# 服务端使用的字符集默认为UTF8
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8

3. Execute mysqld --initialize-insecure command to configure, the installation path will generate a data folder by default 

4. Enter mysqld --install to install the mysql service

5. Start the service net start mysql

The following is the solution for reporting system error 2

mysqld --remove 

mysqld --install

net start mysql

 Previously, I used mysql-8.0.17, which could be connected, but I didn’t know why I couldn’t connect. Baidu didn’t work in many ways, and then re-downloaded mysql-8.0.21-winx64, and then executed the above The operation is fine.

If you forget your password (tested it by yourself, it doesn’t work, and I haven’t found the reason yet):

1. Find the my.ini file

2. To set the permission authentication skip is to add skip-grant-tables ** under [mysqld]

[mysqld]
skip-grant-tables

3. Restart the mysql service (here you can directly enter the following commands in the command line or find the mysql service restart in the service)

net stop mysql
net start mysql

**After restarting, log in with mysql -uroot -p and you will find that we can log in without a password****

4. Reset the password

First select the mysql database

use mysql

Then update the password

update user set authentication_string = password ( 'new-password' ) where user = 'root' ; 

5. Remove the added skip-grant-tables in the my.ini file

6. Restart the mysql service

7. Log in to the command line with the new password to enter the mysql environment

mysql -uroot -p

How to modify the character set encoding

Create a my.ini configuration file under the mysql installation directory (my.cnf file for unxi system), and write the following content in the file:

[mysql]
character_set_server=utf8
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8

 

Guess you like

Origin blog.csdn.net/baidu_39043816/article/details/107960600