First Disclaimer: This blog is mainly to record their installation process and stepped pit, wrong place please write the correct understanding.
1. Download the official website: https://dev.mysql.com/downloads/mysql/
2. Extract to the location you want to install and configure the path
Note: all the way and then click OK.
4. Create a text file, write the following content and then save and renamed my.ini
[mysql] # 4.1, set the mysql client default character set is utf8 default-Character-the SET = utf8 [mysqld] # 4.2, set up port 3306 Port = 3306 # 4.3, set the mysql installation directory basedir = D: \ Promware \ MySQL \ MySQL-8.0.17-Winx64 # 4.4, setting the server to the default character set UTF8 character-Server-sET = UTF8 # 4.5 of 5, to set the default storage engine InnoDB default = INNODB-storage-engine # 4.6, the maximum allowed number of connections max_connections = 20
Note: 4.1, utf8 character set is not utf-8.4.3, change the path to your own extraction path .
5. initialize and mount mysql8
5.1 Right Windows Start icon, select windows powershell (Administrator)
5.2cd D:\Promware\MySQL\mysql-8.0.17-winx64\bin(换成你自己的路径)
5.3执行命令进行初始化:mysqld --initialize --console
请记住第二句输出的冒号后边的字符串:A temporary password is generated for root@localhost:这里是root用户的临时密码
5.4 执行命令进行安装:mysqld --install [服务名]
中括号服务名可以不写
5.5更改密码
输入命令启动mysql:net start mysql
输入登陆命令:mysql -uroot -p这里是root用户的临时密码
输入命令修改密码:ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码'; (注意结尾的分号别丢了)
6.安装完成!!!!!
7.常见问题
第4步中my.ini文件无法修改。原因分析:权限不够。 建议(解决方案):解压到C盘以外的目录。如果在C盘试试:右击my.ini-属性-安全
任意文件示例图
第4步中:关于编码字符集以及存储引擎的种类和区别的请自行百度(偷个懒)。关于路径,有时路径中单斜杠会导致错误,解决方案:改为双斜杠 \\
第5步中:mysqld命令报错,(本人在安装的时候出现过一次这个错误,首先保证前边的path配置正确且已经cd到bin目录下)有提示信息:目录下确实存在该文件,但无法运行。则根据提示信息进行将mysqld命令改为.\mysqld命令进行运行 ,运行成功。(!学计算机看懂英文真的很重要!)
第5.4步中:中括号中的服务名可以不写,默认为mysql.如果电脑上安装多个版本的MySQL,可以根据自己的需要将服务名改为mysql8。
最后强调一下在mysql环境中分号“;”别忘写。