1. Mysql download
- Official website download address: https://www.mysql.com/downloads/
- If for project requirements, you need to download the old version if
https://dev.mysql.com/downloads/
version of Download: https://downloads.mysql.com/archives/community/ (later if troublesome can enter this address downloaded)
- The form of mysql we download here is in the form of compressed package, because it is so convenient, it will not cause unnecessary trouble when it is removed.
- After decompressing the compressed package, we can configure the corresponding mysql
2. Mysql configuration
- Configure MYSQL_HOME, this is the directory where our mysql is decompressed
- Add mysql bin directory on Path variable
- New mysql configuration file to the end of the .ini (my.ini here for an example)
the specific content of my.ini
[mysqld]
# 目录一定要切换成自己的安装目录
basedir = F:\mysql-5.7.24-winx64
# 这里的data目录不需要手动建,后面通过命令初始化
datadir =F:\mysql-5.7.24-winx64\data
port = 3306
# 这里是为例跳过密码验证
skip-grant-tables
(--------- The following steps have been installed before, so it is the installation of the screenshot course, but the commands are the same except for the directory change ----------------)
4. Start CMD in administrator mode , and switch the path to the bin directory under mysql, then enter mysqld -install (install mysql)
mysqld -install
5. Initialize the data file
Here can help us generate the corresponding data file
mysqld --initialize -insecure --user=mysql
6. Start mysql
net start mysql
7. Enter mysql -u root -p
When the following characters are displayed, it means that the startup was successful (this is that our database has no password set)
8. After entering the interface, change the root password (this will change our database password to (123456)
update mysql.user set authentication_string=password('123456') where user='root' and Host='localhost';
9. Refresh permissions
flush privileges;
10. Modify the
skip-grant-tables in my.ini file to comment this line (because we have set a password)
[mysqld]
# 目录一定要切换成自己的安装目录
basedir = F:\mysql-5.7.24-winx64
# 这里的data目录不需要手动建,后面通过命令初始化
datadir =F:\mysql-5.7.24-winx64\data
port = 3306
# skip-grant-tables
- Log in to mysql with a password
mysql -u root -p123456
Thinking:
Attentive people may have discovered this wonderful use of skipping passwords. If our password is forgotten, we can set it in the configuration file of my.ini, and then complete a wave of raccoon cat to change the prince by changing the password above.
------------ The above content is the record after learning the mad god saying Java -------------------