之前安装mysql时未做总结,换新电脑,补上安装记录,安装的时候,找了些网友的安装记录,发现好多坑
1、mysql-5.7.12-winx64.zip下载
官方下载地址:http://dev.mysql.com/downloads/mysql/
2.解压到C:jobmysql-5.7.12-winx64
3.在C:jobmysql-5.7.12-winx64下新建my.ini配置文件
内容如下:
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 # *** 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 basedir = "C:jobmysql-5.7.12-winx64/" datadir = "C:jobmysql-5.7.12-winx64/data/" tmpdir = "C:jobmysql-5.7.12-winx64/data/" socket = "C:jobmysql-5.7.12-winx64/data/mysql.sock" log-error= "C:jobmysql-5.7.12-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= "C:jobmysql-5.7.12-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 #sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES ####################配置文件结束################### |
重点是以下配置,其中datadir的目录名称必须是:C:jobmysql-5.7.12-winx64/data/,加上skip-grant-tables,使root不输密码,登陆
4.在windows系统环境变量path,加入如下内容
C:jobmysql-5.7.12-winx64in;(注意加分号)
5、将mysql注册为windows系统服务
具体操作是在命令行中执行以下命令(需要以管理员身份运行命令行):
cd C:WindowsSystem32
以管理员身份运行cmd.exe
需要切换到bin目录,否则,会将服务目录指定为C:jobmysql-5.7.12-winx64in
增加服务命令:mysqld install MySQL --defaults-file="C:jobmysql-5.7.12-winx64my.ini"
移除服务命令为:mysqld remove
6.第5步成功后,初始化data目录
C:jobmysql-5.7.12-winx64in>mysqld --initialize
此步骤非常重要,未初始化,可能会导致mysql服务无法启动(坑一)
7.打开系统服务管理
可以看到mysql系统服务
在命令行启动mysql命令为: net start mysql
关闭mysql命令为:net stop mysql
8、修改root密码
命令行执行:
1
2
3
4
5
6
7
8
9
10
11
12
|
mysql –uroot mysql>show databases; mysql>use mysql; mysql> update mysql. user set authentication_string= password ( '12345' ) where user = 'root' and Host = 'localhost' ; mysql> alter user 'root' @ 'localhost' identified by '12345' ; mysql> FLUSH PRIVILEGES ; mysql> QUIT |
坑二:新版的mysql数据库下的user表中已经没有Password字段了,而是将加密后的用户密码存储于authentication_string字段
9、远程登陆配置
允许root用户在任何地方进行远程登录,并具有所有库任何操作权限,具体操作如下:
1)在本机先使用root用户登录mysql:
命令行执行:mysql -u root -p
输入密码(第7步中设置的密码):12345
2)进行授权操作:
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '12345' WITH GRANT OPTION;
重载授权表:
mysql>FLUSH PRIVILEGES;
退出mysql:quit
以上就是mysql 5.7.12winx64安装配置方法,希望对大家的学习有所帮助。
http://www.jb51.net/article/83365.htm