Windows下MySQL安装及配置
my.ini 配置
官方下载:http://dev.mysql.com/downloads/mirrors/
复制 my-default.ini 为 my.ini
[mysqld]
explicit_defaults_for_timestamp = true
basedir = "D:/Server/MySQL/mysql-5.7.20-winx64"
datadir = "D:/Server/MySQL/mysql-5.7.20-winx64/data"
socket = "D:/Server/MySQL/mysql-5.7.20-winx64/tmp/mysql.sock"
port = 3306
character_set_server = utf8 # 设置MySQL服务器默认字符集(可选)
sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
[client]
default_character_set = utf8 # 设置MySQL客户端默认字符集(可选)
初始化并安装服务
Install MySQL Service.bat
@echo off
set mysql_home=D:/Server/MySQL/mysql-5.7.20-winx64
echo Installing MySQL5.7 Service...
%mysql_home%/bin/mysqld --install "MySQL5.7" --defaults-file="%mysql_home%/my.ini"
%mysql_home%/bin/mysqld --initialize --user=mysql --console
pause
也可以单独执行mysqld --initialize初始化数据,注意记录默认生成的root用户密码
D:\Server\MySQL\mysql-5.7.20-winx64\bin>mysqld --initialize --user=mysql --console
2017-11-21T13:23:04.415538Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-11-21T13:23:04.460653Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-11-21T13:23:04.526828Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: a23b05a6-afed-11e6-869d-704d7b36dddd.
2017-11-21T13:23:04.528835Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-11-21T13:23:04.533849Z 1 [Note] A temporary password is generated for root@localhost: Hq?E7tajGi/e
启动服务
Start MySQL Service.bat
@echo off
echo Starting MySQL5.7 Service...
net start MySQL5.7
pause
停止和卸载服务
Stop MySQL Service.bat
@echo off
echo Stoping MySQL5.7 Service...
net stop MySQL5.7
pause
Uninstall MySQL Service.bat
@echo off
set mysql_home=D:/Server/MySQL/mysql-5.7.20-winx64
echo Uninstalling MySQL5.7 Service...
%mysql_home%/bin/mysqld.exe --remove "MySQL5.7"
pause
修改root用户密码
mysql> set password = password('ubuntu');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> alter user 'root'@'localhost' password expire never;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
版权声明:
作者:Joe.Ye
链接:https://www.appblog.cn/index.php/2023/02/26/mysql-installation-and-configuration-under-windows/
来源:APP全栈技术分享
文章版权归作者所有,未经允许请勿转载。
THE END
0
二维码
打赏
海报
Windows下MySQL安装及配置
my.ini 配置
官方下载:http://dev.mysql.com/downloads/mirrors/
复制 my-default.ini 为 my.ini
[mysqld]
explicit_defaults_for_timestamp = true
basedir……
文章目录
关闭
共有 0 条评论