一、MySQL的下载
下载地址:https://dev.mysql.com/downloads/mysql/
下载的文件:
二、MySQL安装和配置
解压,zip格式解压缩之后其实MySQL就可以使用了,但是要进行环境变量配置
我的电脑->属性->高级系统设置->环境变量,选择Path,在其后面添加: 你的mysql bin文件夹的路径 :D:installmysql-8.0.26-winx64in
配置完环境变量之后,在D:installmysql-8.0.26-winx64目录下新增加一个配置文件my.ini ,同时在bin的同级目录下创建一个data文件夹(用于存放数据库数据)
[client] # 设置mysql客户端默认字符集 default-character-set=utf8 [mysqld] # 设置3306端口 port = 3306 # 设置mysql的安装目录 basedir=D:installmysql-8.0.26-winx64 # 设置 mysql数据库的数据的存放目录,MySQL 8+ 不需要以下配置,系统自己生成即可,否则有可能报错 datadir=D:installmysql-8.0.26-winx64data # 允许最大连接数 max_connections=200 # 服务端使用的字符集默认为8比特编码的latin1字符集 character-set-server=utf8 # 创建新表时将使用的默认存储引擎 default-storage-engine=INNODB
以管理员身份打开 cmd 命令行工具,即我们在Windows10系统的搜索框中直接输入命令CMD。在命令提示符上单击右键,选择管理员身份运行。切换目录:D:installmysql-8.0.26-winx64in
初始化数据库:
mysqld --initialize --console
执行完成后,会输出 root 用户的初始默认密码,如:
D:installmysql-8.0.26-winx64in>mysqld --initialize --console 2021-10-03T15:13:48.329496Z 0 [System] [MY-013169] [Server] D:installmysql-8.0.26-winx64inmysqld.exe (mysqld 8.0.26) initializing of server in progress as process 5380 2021-10-03T15:13:48.330236Z 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. 2021-10-03T15:13:48.412807Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2021-10-03T15:13:48.905376Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2021-10-03T15:13:49.965476Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main 2021-10-03T15:13:49.966392Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main 2021-10-03T15:13:50.060809Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: MPs)*UFna2dw
MPs)*UFna2dw就是初始密码,后续登录需要用到,你也可以在登陆后修改密码。
输入以下安装命令:
mysqld install
启动输入以下命令即可:
net start mysql
结果如下:
D:installmysql-8.0.26-winx64in>mysqld install Service successfully installed. D:installmysql-8.0.26-winx64in>net start mysql MySQL 服务正在启动 . MySQL 服务已经启动成功。 D:installmysql-8.0.26-winx64in>
修改密码:alter user user() identified by '密码';
mysql> alter user user() identified by '123456'; Query OK, 0 rows affected (0.02 sec)
在cmd中访问MySQL服务:
C:Usersmiracle>mysql -u root -p Enter password: ****** Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 12 Server version: 8.0.26 MySQL Community Server - GPL Copyright (c) 2000, 2021, Oracle and/or its affiliates. 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> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.02 sec) mysql>
本文摘自 :https://www.cnblogs.com/