因为最近换了电脑,正好趁这个机会记录下,myql安装的相关配置。
环境版本说明
- mysql-8.0.15-winx64
- windows10 x64
1、增加环境变量配置
增加mysql环境变量配置:
新增MYSQL_HOME
PATH后追加:%MYSQL_HOME%\bin
2、新增my.ini文件
在mysql解压根目录增加文件my.ini,添加以下内容(里面对应的【安装目录】,【存放目录】需要根据自己实际路径进行修改)。
版本8以上,目录自带data文件夹,不需要再重新新建。
[mysql]
; 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
;设置3306端口
port = 3306
; 设置mysql的安装目录
basedir=D:\00_develop\mysql-8.0.13
; 设置mysql数据库的数据的存放目录
datadir=D:\00_develop\mysql-8.0.13\data
; 允许最大连接数
max_connections=200
; 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
; 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
3、执行相关命令:
1、mysqld --initialize --console,此时会显示出mysql初始密码,需要记录以便后面修改密码使用
2019-07-14T13:43:11.639614Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: +rPeTQgqg04r
2、net start mysql
这一步如果没有install如果报错 无效的服务名,
执行:mysqld --install 成功之后继续按照这个步骤执行
3、mysql -u root -p
4、然后输入上面第一步返回的初始密码
5、ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'mysql';(修改root用户的密码为mysql)
直接上运行命令
PS C:\Users\Administrator> d:
PS D:\> cd D:\00_develop\mysql-8.0.13\bin
PS D:\00_develop\mysql-8.0.13\bin> mysqld --initialize --console
2019-07-14T13:43:06.813217Z 0 [System] [MY-013169] [Server] D:\00_develop\mysql-8.0.13\bin\mysqld.exe (mysqld 8.0.13) initializing of server in progress as process 7256
2019-07-14T13:43:06.834479Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2019-07-14T13:43:11.639614Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: +rPeTQgqg04r
2019-07-14T13:43:13.793727Z 0 [System] [MY-013170] [Server] D:\00_develop\mysql-8.0.13\bin\mysqld.exe (mysqld 8.0.13) initializing of server has completed
PS D:\00_develop\mysql-8.0.13\bin> net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
PS D:\00_develop\mysql-8.0.13\bin> mysql -u root p
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
PS D:\00_develop\mysql-8.0.13\bin> mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.13
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'mysql';
Query OK, 0 rows affected (0.02 sec)
mysql>
微信图片_20190718140215.png