【详记MySql问题】安装之后没有my.ini配置文件怎么办 |
您所在的位置:网站首页 › 目录少了怎么办啊 › 【详记MySql问题】安装之后没有my.ini配置文件怎么办 |
Windows操作系统中,我们安装Mysql有两个选择:一是下载MSI点击运行,利用windows系统安装程序的方法按部就班的来安装;二是下载ZIP,解压出来就能立即使用。 在使用ZIP安装时,安装好之后默认是没有my.ini配置文件的: 当我们想修改数据库的配置信息如 wait_timeout、interactive_timeout、max_connections 或大小写敏感时,却找不到my.ini 配置文件。 虽然这时,还可以通过命令行来修改配置信息,但重启mysql后修改会失效,配置会回归默认值,所以这种方式治标不治本。 这里提供了另一种方法,解决的基本思路是:先删除Mysql服务,然后自己新建一个my.ini文件,最后使用命令行重新初始化mysql服务,同时指定新建的my.ini作为服务默认的配置文件。 以下是详细步骤: 1. 删除MySql服务打开cmd(记得”使用管理员身份“打开),如果没有配置环境变量,请cd(切换目录)到mysql程序下的bin文件夹下(详细步骤参见第一章~): 运行命令: C:\mysql\mysql-8.0.23-winx64>sc delete MySql
删除完成之后,最好去电脑的服务窗口看下,如果找不到MySql服务,说明已经已经删除成功。 如果还能看到MySql服务,可以手动右击选择”停止“,服务停止之后就会自动消失了。 2. 新建my.ini配置文件在mysql程序的根目录下,新建一个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 = FALSE character-set-server = utf8mb4 collation-server = utf8mb4_bin init_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:\MySQL datadir = D:\MySQL\data port = 3306 # server_id = ..... # 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 = 128M sort_buffer_size = 16M read_rnd_buffer_size = 16M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES其中basedir 和 datadir 根据实际MySql安装的位置进行修改。 3. 重新生成data文件删除之前生成的data文件,如果有重要的数据表,请先备份好。 回到cmd,重新生成data文件。运行: C:\mysql\mysql-8.0.23-winx64>mysqld --initialize-insecure --user=mysql该命令需要执行大概一分钟或者更快,完成后会在MySql程序文件夹下重新生成名称为data的文件夹: 安装MySql服务,同时设置绑定my.ini配置文件。命令: C:\mysql\mysql-8.0.23-winx64>mysqld --install "MySql" --defaults-file="C:/mysql/mysql-8.0.23-winx64/my.ini"
如果启动成功,是这样的: 如果不成功: 命令: C:\mysql\mysql-8.0.23-winx64\bin>mysql -u root -p这时密码为空,不需要填写,直接回车: (敲黑板)这里有个需要注意的地方,在8.0之后的版本,修改root用户密码的命令是: ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密码';之前的版本是: update mysql.user set authentication_string=password("你的密码") where user="root";
|
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |