首先进入MySQL官网:https://www.mysql.com/
下载安装包:
下载社区版的这个:
解压(路径最好不要有中文)
管理员身份打开cmd命令行
cd到mysql目录下的bin目录
执行mysqld --install
安装mysql的服务
D:\Users\mysql-8.0.22-winx64\bin>mysqld --install
Service successfully installed.
执行mysqld --initialize --console
初始化mysql
注意:执行完会给出一个初始密码
D:\Users\mysql-8.0.22-winx64\bin>mysqld --initialize --console
2020-12-15T03:08:37.293189Z 0 [System] [MY-013169] [Server] D:\Users\mysql-8.0.22-winx64\bin\mysqld.exe (mysqld 8.0.22) initializing of server in progress as process 12308
2020-12-15T03:08:37.306291Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-12-15T03:08:37.929297Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2020-12-15T03:08:39.188232Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: ThNNga4rIf_&
执行net start mysql
开启mysql的服务
D:\Users\mysql-8.0.22-winx64\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
执行mysql -u root -p
登录验证,mysql是否安装成功
D:\Users\mysql-8.0.22-winx64\bin>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.22
Copyright (c) 2000, 2020, 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.
改密码alter user 'root'@'localhost' identified by '0000';
mysql> alter user 'root'@'localhost' identified by '0000';
Query OK, 0 rows affected (0.02 sec)
加入环境变量:
这边只是自己做个记录,记的比较简单,
详细移步:https://www.cnblogs.com/winton-nfs/p/11524007.html
以下是centos7下安装mysql方法
wget https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm
yum -y localinstall mysql80-community-release-el7-3.noarch.rpm
systemctl start mysqld
// 查看初始默认密码:
cat /var/log/mysqld.lo
mysql -u root -p