mysql 5.7 配置

mysql 5.7.10 配置

首先我们要先下载[mysql-5.7.10-winx64],下面点击下一步安装就行,安装过后,需要配置mysql,如下配置:(http://download.csdn.net/detail/mh942408056/941509

1.打开mysql安装的根目录,修改my-default.ini为my.ini
2.配置mysql,下面是笔者的my.ini配置,可以作为参考

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/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.

[mysql]

#设置mysql客户端默认字符集
default-character-set=utf8

[mysqld]

# 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:\Program Files\MySQL\MySQL Server 5.7"
datadir ="D:\Program Files\MySQL\MySQL Server 5.7\data"
tmpdir = "D:\Program Files\MySQL\MySQL Server 5.7\data"
socket = "D:\Program Files\MySQL\MySQL Server 5.7\data\mysql.sock"
log-error = "D:\Program Files\MySQL\MySQL Server 5.7\data\mysql_error.log"
port =3306
# server_id = .....

#服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8

max_connections = 100
table_open_cache = 256
query_cache_size = 1M

tmp_table_size = 32M
thread_cache_size = 8

#创建新表时将使用的默认存储引擎
default-storage-engine=INNODB

innodb_data_home_dir = "D:\Program Files\MySQL\MySQL Server 5.7\data"
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 128M
innodb_buffer_pool_size = 128M
innodb_log_file_size = 10M
innodb_thread_concurrency = 16
innodb-autoextend-increment = 1000

# 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 = 2M
read_rnd_buffer_size = 2M 

#限制server接受的数据包大小
max_allowed_packet = 32M
explicit_defaults_for_timestamp = true 

sql_mode=STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO
#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES  

3.将bin目录(笔者的bin目录为D:\Program Files\MySQL\MySQL Server 5.7\bin)添加到系统环境变量
4.打开系统提示符(管理员)(笔者为win10,就是cmd,不过要用管理员的权限),切换到bin目录,mysql 5.7版本与以前的版本不一样的地方要先初始化,如下执行

mysqld --defaults-file="D:\mysql\my.ini" --initialize --user=mysql

执行后,会在data文件夹里面生成如下文件:
这里写图片描述
5.将mysql服务添加到系统服务,执行如下代码

mysqld --install MySQL

6.启动MySQL服务:

net start MySQL

7.打开mysql

mysql -u root -p #-u 用户 -p密码 具体信息上网查询

如果有初始密码,就输入初始密码,进去后让更改密码;如果没有,需要在my.in最后增加配置

skip-grant-tables

配置后,需要重启服务,再执行打开mysql步骤,让输密码,直接Entry就能进入,进入以后,执行以下代码修改root密码:

mysql>use mysql;#切换到mysql库
mysql>set password=password("密码");
mysql>flush privileges; #
mysql>quit;

8.去除my.ini最后增加的配置,重启mysql服务,再次进入就要输入密码

skip-grant-tables

9.常用命令
show:显示信息,例如:show database;
use:切换数据库,例如:use mysql;
desc:显示表结构,例如:desc user;
10.如果mysql启动不起来,或者其它错误,勤看错误日志,就是my.ini中配置的log-error,里面信息很详细,不懂的地方,勤查询,网上很多。
11.注意:在2020年7月份安装5.7.x版本的mysql数据库时,发现 net install mysql 始终安装不成功,经过多方尝试,文件路径如下可正常安装。
在这里插入图片描述
原因未如,各位如果知道详情,请在评论区留言,谢过。

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值