windows 安装mysql
首先去下载Mysql文件
我下载的是zip版本的
2.解压文件
3.在解压的文件主目录下创建一个my.ini文件
# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL. [mysqld] # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # These are commonly set, remove the # and set as required. # 设置mysql的安装目录 basedir = C:\\MySQL2\\ # 设置mysql数据库的数据的存放目录 datadir = C:\\MySQL2\\data # 设置3307端口 port = 3307 # server_id = ..... # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES # 允许最大连接数 max_connections = 200 # 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统 max_connect_errors = 10 # 服务端使用的字符集默认为UTF8 character-set-server = utf8mb4 # 创建新表时将使用的默认存储引擎 default-storage-engine = INNODB # 默认使用“mysql_native_password”插件认证 default_authentication_plugin = mysql_native_password [mysql] # 设置mysql客户端默认字符集 default-character-set = utf8mb4 [client] # 设置mysql客户端连接服务端时默认使用的端口 port=3307 default-character-set = utf8mb4
使用cmd进入解压出来的bin目录
1 | cd C:\MySQL2\Install\bin |
初始话数据库
1 | mysqld --initialize --console |
这里会有一段话@localhost:xxxxx
这个xxxxx就是默认的初始密码,记得保存下来。
运行安装服务
1 | C:\MySQL\mysql-8.1.0-winx64\Install\bin>mysqld.exe -install<br>如果需要改服务名称的话<br>C:\MySQL\mysql-8.1.0-winx64\Install\bin>mysqld.exe -install MySQL2 |
提示
1 | Service successfully installed. |
说明服务安装成功
再运行
1 | net start mysql |
1 | C:\MySQL\mysql-8.1.0-winx64\Install\bin>net start mysql |
服务启动成功,
到目前为止都安装完了
但是目前只能通过localhost也就是本机登录
继续cmd管理员模式进入安装目录的bin文件下
登录mysql
1 | mysql -u root -p |
输入刚刚保存的密码(这里只能手打不能粘贴)
选择“mysql”数据库
1 | <strong>use mysql;</strong> |
更新“user”表中root账号的host项
1 | update user set host= '%' where user= 'root' ; |
刷新权限
1 | flush privileges; |
查看是否修改成功
1 | select host,user from user where user= 'root' ; |
完成!
修改登录密码(需要先登录)
1 | alter user 'root' @ 'localhost' identified with mysql_native_password by '你的密码' ; |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix