今天想安装下mysql的最新版本,并且用自定义安装
首先需要到官网下载压缩包,地址是https://dev.mysql.com/downloads/mysql/
下载完毕后,将其放在想要安装的位置,并进行如下步骤
1.将压缩包解压后,通过cmd进入bin下(最好以管理员方式进入cmd,否可创建服务可能会失败)
2.执行mysqld --initialize --console
成功后输出为:
2019-06-16T09:46:32.373905Z 0 [System] [MY-013169] [Server] D:\IT\MySQL\mysql-8.0.16-winx64\bin\mysqld.exe (mysqld 8.0.16) initializing of server in progress as process 10572
2019-06-16T09:46:32.376010Z 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-06-16T09:46:59.309326Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: *RQxe5FU_Qhp
2019-06-16T09:47:10.056559Z 0 [System] [MY-013170] [Server] D:\IT\MySQL\mysql-8.0.16-winx64\bin\mysqld.exe (mysqld 8.0.16) initializing of server has completed
3.记录root密码(重点)
这是执行2后得到的结果,密码是root@localhost: *RQxe5FU_Qhp ->*RQxe5FU_Qhp
4.安装服务
mysqld --install [服务名]
此处我输入为:mysqld --install MySQL_8_0_16
成功后输出为:
Service successfully installed.
5.启动服务
net start [服务名]
此处我输入为:net start MySQL_8_0_16
成功后输出为:
MySQL_8_0_16 服务正在启动 ....
MySQL_8_0_16 服务已经启动成功。
6.尝试登陆
mysql -u root -p
然后输入上面记录的root密码即可
成功后输出为:
Enter password: ************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.16
Copyright (c) 2000, 2019, 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>
7.修改root密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';
8.创建新用户
// 8.0之前
insert into mysql.user(Host,User,Password) values("%","yes",password("123456"));
// 8.0之后
create user yes identified by '123456';
9.更改权限
grant all privileges on test.* to 'yes'@'%';(test是新建表名)
注:其它常用命令可参考:https://blog.csdn.net/a1173356881/article/details/85220577