windows下安装mysql5.7

2018-01-31  本文已影响0人  mejhwu
  1. 以管理员进入bin目录
  2. 执行mysqld --initialize --user=mysql --console
D:\dev\mysql-5.7.20-winx64\bin
λ mysqld --initialize --user=mysql --console
2018-01-31T05:21:00.806546Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-01-31T05:21:03.168969Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-01-31T05:21:03.979674Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-01-31T05:21:04.224014Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 887e399a-0646-11e8-9db2-2089847fda4f.
2018-01-31T05:21:04.341216Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-01-31T05:21:04.355224Z 1 [Note] A temporary password is generated for root@localhost: )o7gplfB(ugW
  1. 执行mysqld -install
D:\dev\mysql-5.7.20-winx64\bin
λ mysqld -install
Service successfully installed.
  1. 进入MySQL,密码在步骤而产生
D:\dev\mysql-5.7.20-winx64\bin
λ mysql -u root -p
Enter password: ************
  1. 修改密码
mysql> alter user root@localhost identified by "12345";
Query OK, 0 rows affected (0.00 sec)
  1. 修改字符集编码
    (1)查看字符集编码
mysql> show variables like 'character%';                                   
+--------------------------+--------------------------------------------+  
| Variable_name            | Value                                      |  
+--------------------------+--------------------------------------------+  
| character_set_client     | gbk                                        |  
| character_set_connection | gbk                                        |  
| character_set_database   | latin1                                     |  
| character_set_filesystem | binary                                     |  
| character_set_results    | gbk                                        |  
| character_set_server     | latin1                                     |  
| character_set_system     | utf8                                       |  
| character_sets_dir       | D:\dev\mysql-5.7.20-winx64\share\charsets\ |  
+--------------------------+--------------------------------------------+  
8 rows in set, 1 warning (0.00 sec)                                        

(2)在mysql根目录下增加my.ini文件,并添加如下内容

[client]
default-character-set=utf8

[mysqld]
character-set-server=utf8
character-set-filesystem = utf8

(3)重启mysql并查看字符集编码

D:\dev\mysql-5.7.20-winx64\bin
λ net stop mysql
MySQL 服务正在停止.
MySQL 服务已成功停止。

D:\dev\mysql-5.7.20-winx64\bin
λ net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。

D:\dev\mysql-5.7.20-winx64\bin
λ mysql -u root -p

mysql> show variables like 'character%';
+--------------------------+--------------------------------------------+
| Variable_name            | Value                                      |
+--------------------------+--------------------------------------------+
| character_set_client     | utf8                                       |
| character_set_connection | utf8                                       |
| character_set_database   | utf8                                       |
| character_set_filesystem | utf8                                       |
| character_set_results    | utf8                                       |
| character_set_server     | utf8                                       |
| character_set_system     | utf8                                       |
| character_sets_dir       | D:\dev\mysql-5.7.20-winx64\share\charsets\ |
+--------------------------+--------------------------------------------+
8 rows in set, 1 warning (0.01 sec)

mysql>
上一篇下一篇

猜你喜欢

热点阅读