一、背景
我在两台电脑上安装了mysql server 8.0,准备继续做主从配置,这时候就需要用到my.ini文件进行配置,但是我找不到my.ini文件。
我的安装目录中没有my.ini文件。(这里我的mysql安装目录为C:Program FilesMySQLMySQL Server 8.0)。

那么我们就需要重新配置一下。
二、删除原有的mysql服务
因为我的mysql已经用了一段时间,我这里就删除服务重新配置。
删除方法。
进入mysql安装的bin目录。在路径栏输入cmd命令,即可进入命令提示符。


查看我们mysql服务的名字。我们的服务名称是MySQLD514,这个名称是我们自定义的,每个人的情况可能不同,需要自己插入相应的名称。)


命令如下:
# 删除已安装的mysql服务sc delete MySQLD514
三、初始化mysql
# 初始化mysqlmysqld --initialize-insecure --user=mysql

四、自行添加my.ini文件
在bin文件夹同级目录,新建my.ini文件。

将下面脚本复制到 my.ini文件
# For advice on how to change settings please see# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the# *** default location during install, and will be replaced if you# *** upgrade to a newer version of MySQL.[client]default-character-set = utf8mb4[mysql]default-character-set = utf8mb4[mysqld]character-set-client-handshake = FALSEcharacter-set-server = utf8mb4collation-server = utf8mb4_bininit_connect='SET NAMES utf8mb4'# Remove leading # and set to the amount of RAM for the most important data# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.innodb_buffer_pool_size = 128M# Remove leading # to turn on a very important data integrity option: logging# changes to the binary log between backups.# log_bin# These are commonly set, remove the # and set as required.basedir = D:MySQLdatadir = D:MySQLdataport = 3306server_id = 1# Remove leading # to set options mainly useful for reporting servers.# The server defaults are faster for transactions and fast SELECTs.# Adjust sizes as needed, experiment to find the optimal values.join_buffer_size = 128Msort_buffer_size = 16Mread_rnd_buffer_size = 16M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
五、新建mysql服务
输入命令 ,意思是创建一个名字为MySql的服务,相关配置文件为C:Program FilesMySQLMySQL Server 8.0my.ini
# 创建mysql服务mysqld --install "MySql" --defaults-file="C:Program FilesMySQLMySQL Server 8.0my.ini"

再次打开服务,即可看到我们的MySql服务项。

六、启动mysql服务
可以在服务中直接启动,也可以在cmd中命令启动。命令为:
net start MySql

七、设置数据库密码
7.1 登录mysql数据库
在bin目录启动cmd。输入下命令。
mysql -u root -p
这时密码为空,不需要填写,直接回车:

7.2 修改root用户密码
设置root用户密码为123456
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';

设置退出,再次登录,即可。
以上就是Mysql应用安装后找不到my.ini文件如何解决的详细内容,更多请关注创想鸟其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/146391.html
微信扫一扫
支付宝扫一扫