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).
Then we need to reconfigure it.
mysqld --remove mysql
mysqld --initialize-insecure --user=mysql
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
# 创建mysql服务 mysqld --install "mysql" --defaults-file="C:\mysql\mysql-8.0.31-winx64\my.ini"
net start mysql
Start cmd in the bin directory. Enter the following command.
mysql -u root -p
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
Set the root user password to 123456
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
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.
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!