从官网下载MySQL-5.7.11-winx64压缩版,安装后发现竟然有密码,尝试无果,通过修改密码搞定
安装成功后:
关闭mysql服务在跟目录下修改文件my.ini,内容如下:注意两点 1:内容中myql的安装目录换成读者的安装目录;2最后一行代表登录是否需要密码,这里我们绕过密码登录进入mysql修改密码,所以不注释skip-grant-tables
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
####################配置文件开始###################
# 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.
[client]
default-character- set =utf8
[mysqld]
port=3306
# D:\Program Files\mysql-5.7.11-winx64\mysql-5.7.11-winx64
basedir = "D:\Program Files\mysql-5.7.11-winx64\mysql-5.7.11-winx64/"
datadir = "D:\Program Files\mysql-5.7.11-winx64\mysql-5.7.11-winx64/data/"
tmpdir = "D:\Program Files\mysql-5.7.11-winx64\mysql-5.7.11-winx64/data/"
socket = "D:\Program Files\mysql-5.7.11-winx64\mysql-5.7.11-winx64/data/mysql.sock"
log-error= "D:\Program Files\mysql-5.7.11-winx64\mysql-5.7.11-winx64/data/mysql_error.log"
#server_id = 2
#skip-locking
max_connections=100
table_open_cache=256
query_cache_size=1M
tmp_table_size=32M
thread_cache_size=8
innodb_data_home_dir= "D:\Program Files\mysql-5.7.11-winx64\mysql-5.7.11-winx64/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
join_buffer_size = 128M
sort_buffer_size = 32M
read_rnd_buffer_size = 32M
max_allowed_packet = 32M
explicit_defaults_for_timestamp= true
sql-mode= "STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
skip-grant-tables
####################配置文件结束###################
|
修改保存后,在cmd中,由于我们已经在path配置了环境变量,所以我们可以直接启动mysql
1
|
net start mysql
|
启动成功后,登录mysql
1
|
mysql -u root -p
|
密码为空 这里我们直接回车登录成功
登录成功后,我们修改数据库执行如下
1
|
use mysql
|
1
|
update user set authentication_string=password("123456") where user="root";
|
这里注意最后必需加上分号
成功后刷新
1
|
flush privileges;
|
致此我们密码就修改成功了,退出关闭mysql服务,然后把my.ini中最后一行注释掉,从新启动mysql服务,发现新密码生效。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。