windows 免安装版 MySQL-8.0.29 安装配置

windows 免安装版 MySQL-8.0.29 安装配置

编码文章call10242025-06-10 12:13:223A+A-

安装 MySQL

1、mysql安装包下载

下载地址:fw_error_www
下载zip压缩包即可
解压缩下载的安装包

2、进入mysql安装包目录,创建my.ini文件,写入配置

[mysqld]
#设置端口
port=3306
#设置mysql的安装目录
basedir=D:/tools/database/mysql-8.0.29-winx64
#设置mysql数据库的存放目录
datadir=D:/tools/database/mysql-8.0.29-winx64/data
#允许最大连接数
max_connections=200
#允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统 
max_connect_errors=10
#服务端使用的字符集默认为8比特编码的latin1字符集
character-set-client-handshake = FALSE
character-set-server=utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'
#设置字符集
loose-default-character-set=utf8mb4
[client]
#设置客户端字符集
port=3306
default-character-set=utf8mb4
[WinMySQLadmin]
Server=D:/tools/database/mysql-8.0.29-winx64/bin/mysqld.exe

3、以管理员身份运行cmd

4、进入mysql安装包目录(bin)

5、运行命令:mysqld --initialize-insecure --console

注:initialize:初始化;insecure:不安全的【不带root密码】;console:显示

6、运行命令:mysqld install,将mysql注册到windows服务中

注:出现“Install/Remove of the Service Denied”这个错误时,打开cmd.exe程序的时候选择“用管理员身份打开”。cmd.exe路径:C:\Windows\System32\cmd.exe

7、mysql服务移除,运行命令:mysqld remove

MySQL 修改密码(忘记密码时可使用此方式)

1、关闭mysql服务,在安装目录xxxx\bin文件地址栏输入cmd,按enter打开dos,跳过注册表来启动server。命令行:mysqld --console --skip-grant-tables --shared-memory

注:8.0以下使用命令:mysqld --skip_grant_tables

2、再在该路径下重新打开一个DOS,登录MySQL:mysql -u root -p,按eter后,不用输入密码,直接再次enter进入mysql

注:必须启动的是DOS,不可是PowerShell

3、看下当前用户,应该是无权限用户:select current_user(); (此步可以跳过)
4、使用mysql空间:use mysql;
5、改root用户密码:update user set authentication_string='' where user='root';刷新数据:flush privileges;设置密码:alter user 'root'@'localhost' identified with mysql_native_password BY '你的密码';

注:8.0 以前改root用户密码:update user set password=password('root') where user='root'; 或者:update user set authentication_string=password('root') where user='root';

如果报错:ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement.
使用 flush privileges;
如果报错:ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'%',则是远程访问权限不正确,先选择数据库,查看一下再更改。
update user set host = 'localhost' where user ='root';
flush privileges;
如果出现密码过于简单,不让修改密码的情况,ERROR 1819 (HY000): Your password does not satisfy the current policy requirements,这是由于mysql8.0以上密码策略限制必须要大小写加数字特殊符号。

6、执行后会提示一行已修改。然后刷新下表中数据:flush privileges;
7、查看用户:select host,user,password_expired,authentication_string from user;
8、修改允许远程连接:update user set host='%' where user = 'root'; 然后刷新下表中数据:flush privileges;
9、修改完毕,退出MySQL环境:quit;
10、 关闭dos,启动mysql服务。

点击这里复制本文地址 以上内容由文彬编程网整理呈现,请务必在转载分享时注明本文地址!如对内容有疑问,请联系我们,谢谢!
qrcode

文彬编程网 © All Rights Reserved.  蜀ICP备2024111239号-4