Windows系统重装了, 想恢复一下之前的MySQL环境, 而且本地数据库也是比较常用的, 刚好本次也在安装, 做一个简单的记录. 也算是自己的学习记录输出. 遇到的问题当然也可以同时记录在这里, 方便后
续回顾.
// TODO 估计放了也会被CSDN屏蔽, 这里就不放了, 后续如果有好的共享磁盘工具, 再分享. 百度网盘也是垃圾, 限速狗.
这里直接给下载源头地址(不太清楚是否需要科学上网):
MySQL官网: https://www.mysql.com
下载地址: https://dev.mysql.com/downloads/installer
我选得是这个:
设置一个密码, 我的是: 1一排2一排逗句, 反正也没人看懂, 哈哈
我这里好像是之前选了高级配置, 才有这个选项.
这里我仔细配置了一下日志目录, 方便更加深入的了解MySQL, 不能简单的为了安装一个软件而安装件, 最好是可以学习到有点东西, 毕竟也花费了一点时间.
Beginning configuration step: Writing configuration file
Saving my.ini configuration file...
Saved my.ini configuration file.
Ended configuration step: Writing configuration file
Beginning configuration step: Updating Windows Firewall rules
Adding a Windows Firewall rule for MySQL80 on port 3306.
Attempting to add a Windows Firewall rule with command: netsh.exe advfirewall firewall add rule name="Port 3306" protocol=TCP localport=3306 dir=in action=allow
确定。
Successfully added the Windows Firewall rule.
Adding a Windows Firewall rule for MySQL80 on port 33060.
Attempting to add a Windows Firewall rule with command: netsh.exe advfirewall firewall add rule name="Port 33060" protocol=TCP localport=33060 dir=in action=allow
确定。
Successfully added the Windows Firewall rule.
Ended configuration step: Updating Windows Firewall rules
Beginning configuration step: Adjusting Windows service
Attempting to grant the required filesystem permissions to the 'NT AUTHORITY\NetworkService' account.
Granted permissions to the data directory.
Granted permissions to access the 'E:\21-MySQL\01-ErrorLogs\zhengbizhong.err' log file.
Granted permissions to access the 'E:\21-MySQL\02-GeneralLog\zhengbizhong.log' log file.
Granted permissions to access the 'E:\21-MySQL\03-SlowQueryLog\zhengbizhong-slow.log' log file.
Granted permissions to access the 'E:\21-MySQL\04-BinaryLog\zhengbizhong-bin' log file.
Adding new service
New service added
Ended configuration step: Adjusting Windows service
Beginning configuration step: Initializing database (may take a long time)
Attempting to run MySQL Server with --initialize-insecure option...
Starting process for MySQL Server 8.0.34...
Starting process with command: C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini" --console --initialize-insecure=on --lower-case-table-names=1...
C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe (mysqld 8.0.34) initializing of server in progress as process 8508
InnoDB initialization has started.
InnoDB initialization has ended.
root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
Process for mysqld, with ID 8508, was run successfully and exited with code 0.
Successfully started process for MySQL Server 8.0.34.
MySQL Server 8.0.34 intialized the database successfully.
Ended configuration step: Initializing database (may take a long time)
Beginning configuration step: Updating permissions for the data folder and related server files
Attempting to update the permissions for the data folder and related server files...
Inherited permissions have been converted to explicit permissions.
Full control permissions granted to: NETWORK SERVICE.
Full control permissions granted to: Administrators.
Full control permissions granted to: CREATOR OWNER.
Full control permissions granted to: SYSTEM.
Access to the data directory is removed for the users group.
Permissions for the data folder and related server files are updated correctly.
Ended configuration step: Updating permissions for the data folder and related server files
Beginning configuration step: Starting the server
Attempting to start service MySQL80...
C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe (mysqld 8.0.34) starting as process 3616
InnoDB initialization has started.
InnoDB initialization has ended.
CA certificate ca.pem is self signed.
Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
X Plugin ready for connections. Bind-address: '::' port: 33060
C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe: ready for connections. Version: '8.0.34' socket: '' port: 3306 MySQL Community Server - GPL.
Successfully started service MySQL80.
Waiting until a connection to MySQL Server 8.0.34 can be established (with a maximum of 10 attempts)...
Retry 1: Attempting to connect to Mysql@localhost:3306 with user root with no password...
Successfully connected to MySQL Server 8.0.34.
Ended configuration step: Starting the server
Beginning configuration step: Applying security settings
Attempting to update security settings.
Updated security settings.
Ended configuration step: Applying security settings
Beginning configuration step: Updating the Start menu link
Attempting to verify command-line client shortcut.
Verified command-line client shortcut.
Verified command-line client shortcut.
Ended configuration step: Updating the Start menu link
配置环境变量就行. 这里不多赘述了.
把这个目录配置进去, 我是这个目录: C:\Program Files\MySQL\MySQL Server 8.0\bin
命令记错了.
mysqld命令是MySQL的主程序,用来安装初始化;mysql是MySQL的命令行工具;这里因为命令敲成了mysqld -u root -p导致的,正确的命令应该是mysql -uroot -p