Home > Database > Mysql Tutorial > What are the steps for Mysql to configure the my.ini file?

What are the steps for Mysql to configure the my.ini file?

PHPz
Release: 2023-05-28 22:52:40
forward
4951 people have browsed it

1. Background

I have installed MySQL Server 8.0 on two computers, and I am going to continue database master-slave replication configuration. At this time, I need to use the my.ini file. configuration, but I can't find the my.ini file.

There is no my.ini file in my installation directory. (My mysql installation directory here is C:\Program Files\MySQL\MySQL Server 8.0).

What are the steps for Mysql to configure the my.ini file?

Then we need to reconfigure it.

2. Delete the original mysql service

mysqld --remove mysql
Copy after login

3. Initialize mysql

mysqld --initialize-insecure --user=mysql
Copy after login

4. Add the my.ini file by yourself

What are the steps for Mysql to configure the my.ini file?

Contents 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
Copy after login

5. Create a new mysql service

# 创建mysql服务
mysqld --install "mysql" --defaults-file="C:\mysql\mysql-8.0.31-winx64\my.ini"
Copy after login

6. Start the mysql service

net start mysql
Copy after login

7. Set the database password

7.1 Log in to the mysql database

Start cmd in the bin directory. Enter the following command.

mysql -u root -p
Copy after login

At this time the password is empty, no need to fill it in, just press Enter:

Note: If the data file here is If the previous one is not regenerated, then the password is still configured before.You can skip the next step of changing the root password

What are the steps for Mysql to configure the my.ini file?

7.2 Modify the root user password

Set the root user password to 123456

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

8. Configuring my.ini issues

This problem may occur

Mysql-Error handling: Found option without preceding group in config file

The following is the solution

Error location: Save as configuration my.ini file, change "Encoding" to: UTF-8.

Correction: After re-saving and changing the encoding to "ANSI", the initialization was successful.

What are the steps for Mysql to configure the my.ini file?

The above is the detailed content of What are the steps for Mysql to configure the my.ini file?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template