MySql配置问题2019-06-21

MySql配置问题

Navicat for MySQL 连接localhost的时候报错,(其实在登录mysql的时候也报了这个错) Error 1045 (28000) : Access denided for user 'root'@....., 网上找了很多地方,终于找到一个能解决我问题的方案,原始连接:【详记MySql问题大全集】三、安装之后没有my.ini配置文件怎么办 - 在7楼 - 博客园, 这里针对我的问题重新记录一下:

网上很多地方都说修改my.ini文件,但是我本地并没有这个文件,包括ProgrameData目录下面也没有,最后用上面的方法

1、先停止mysql服务:net stop mysql

2、删除MySql目录下的data文件夹

3、自己建一个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 = D:\MySQL

datadir = D:\MySQL\data

这两个目录记得修改成自己的

3、重新生成data文件夹:回到cmd输入:mysqld --initialize-insecure --user=mysql,等待一段时间会自动建立新的data文件夹

4、设置绑定my.ini文件:cmd输入:mysqld --install"MySql" --defaults-file="d:/mysql/my.ini"

5、最后重新启动服务:cmd输入:net start mysql

好了 ,到这里我的问题都解决了。

你可能感兴趣的:(MySql配置问题2019-06-21)