Install MySQL server


1. Windows install MySQL server

1. Download the 5.7.24 decompressed version

Enter the download address

2. As shown in the picture

Insert picture description here

3. Unzip the file

Insert picture description here

4. Open -> mysql-5.7.24-winx64 in the root directory must create a new file data, add the configuration file my.ini

Insert picture description here
The content of my.ini file:

[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=E:\Environment\mysql-5.7.24-winx64
# 设置mysql数据库的数据的存放目录
datadir=E:\Environment\mysql-5.7.24-winx64\data
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码latin1字符集
character-set-server=utf8
#创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
5. Install and start the service

Right-click the cmd.exe file to enter the bin directory of mysql as an administrator. If it is shown

Insert picture description here

  1. Initialize the database (must be done the first time, if you reinstall after uninstall, skip this step)
    mysqld --initialize

  2. Installation service
    mysqld instal MySQL57

If the installation is unsuccessful, you can check whether the server has been installed through the command, and if it is deleted through the command, proceed with the installation

sc query mysql(service name)
sc delete mysql(service name)

Other problems can arise if the command mysqld --consolefor more information.

  1. Start the service
    net start MySQL57
6. Configure the database
配置数据库做两件事情:修改root默认密码;设置root可以远程访问;
1.登陆:mysql -uroot -p
初始密码在data文件夹中以.err结尾的文件中,如:A temporary password is generated for root@localhost: =&Oifq2Nugk;
2.修改默认密码:alter user root@localhost identified by '123456';
3.切换数据库:use mysql;
3.设置用户可以远程访问(%表示不限制访问ip):update user set host = '%' where user = 'root';
4.确认设置(或重启服务器让设置生效):FLUSH PRIVILEGES;
  • Service: System background process
    * Start service: net start mysql
    * Stop service: net stop mysql

The above is to complete the installation of the MySQL server

Note: sql statement must add a semicolon

Guess you like

Origin blog.csdn.net/lirui1212/article/details/114586304