Table of contents
2. Delete the original mysql service
4. Add my.ini file by yourself
Seven, set the database password
Eight, configure my.ini problem
1. Background
I installed MySQL Server 8.0 on two computers, and I am going to continue to configure the database master-slave replication . At this time, I need to use the my.ini file for configuration, but I cannot find the my.ini file.
I don't have a my.ini file in my installation directory. (Here my mysql installation directory is C:\Program Files\MySQL\MySQL Server 8.0).
Then we need to reconfigure it.
2. Delete the original mysql service
mysqld --remove mysql
3. Initialize mysql
mysqld --initialize-insecure --user=mysql
4. Add my.ini file by yourself
The content in my.ini (you need to configure basedir and datadir yourself)
[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录 ----------是你的文件路径-------------
basedir=C:\mysql\mysql-8.0.31-winx64
# 设置mysql数据库的数据的存放目录 ---------是你的文件路径data文件夹自行创建
datadir=C:\mysql\mysql-8.0.31-winx64\data
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。
max_connect_errors=10
# 服务端使用的字符集默认为utf8mb4
character-set-server=utf8mb4
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
#mysql_native_password
default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8mb4
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8mb4
5. Create a new mysql service
# 创建mysql服务
mysqld --install "mysql" --defaults-file="C:\mysql\mysql-8.0.31-winx64\my.ini"
6. Start the mysql service
net start mysql
Seven, set the database password
7.1 Login to mysql database
Start cmd in the bin directory. Enter the next command.
mysql -u root -p
At this time, the password is empty and does not need to be filled in, just press Enter:
Note: If the data file here is previous and not regenerated , then the password is still configured before, and you can skip the next step of changing the root password
7.2 Modify root user password
Set root user password to 123456
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
Eight, configure my.ini problem
this problem may occur
Mysql-error handling: Found option without preceding group in config file
Here is the solution
Mysql-error handling: Found option without preceding group in config file__拉的博客-CSDN Blog