Home >Database >Mysql Tutorial >How to install two mysql databases on the computer?
(Recommended tutorial: mysql video tutorial)
In actual development, some lower version databases do not support some special sql statement, so there will be problems when high version database data is imported into lower version. Therefore, in some special cases, lower version database cannot be moved, and high version mysql data cannot be imported into lower version mysql. We have to use the same machine. Install two versions of mysql.
Examples of sql statements that are not supported by the lower version of mysql, such as the following:
CREATE TABLE `storage` ( `storageid` INT(11) NOT NULL AUTO_INCREMENT, `createTime` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP, `updateTime` TIMESTAMP NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`storageid`) ) ENGINE=INNODB AUTO_INCREMENT=292 DEFAULT CHARSET=utf8 COMMENT='仓库'
Executing the above statement on the 5.1 version of mysql will result in an error
The 5.7 version of mysql supports dual timestamp timestamp. The above sql statement can be executed normally
First, stop the previously installed lower version of mysql service:
Second, install it on my other computers Copy mysql5.7 (I have installed the mysql-5.7.22-winx64.zip version on other computers)
After copying the three copies, enter the folder, delete the data directory, then open my.ini, modify the port number, change the port number to 3307, and reconfigure basedir and datadir
Modify the content as shown in the picture:
If you want the configuration file content, you can take it: ------>
[mysqld] port = 3307 basedir=C:\mysql-5.7.22-winx64 datadir=C:\mysql-5.7.22-winx64\data max_connections=200 character-set-server=utf8 default-storage-engine=INNODB sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES [mysql] default-character-set=utf8
four Start the steps to install and add services:
4.1 Run the command line window as an administrator
4.2 Enter the bin of mysql5.7 Directory
4.3 Install the mysql service, specify the mysql service name as mysql2, and install it according to the my.ini file. The command is as follows:
C:\mysql-5.7.22-winx64\bin>mysqld install mysql2 --default-file="C:\mysql-5.7.22-winx64\my.ini" 成功安装后会提示: Service successfully installed.
Go to the service and you can see that there is an additional mysql2 service at this time
5 initialization database
After the mysql service is installed successfully, The database needs to be initialized, otherwise the service cannot be started.
Execute the following command in the bin directory
C:\mysql-5.7.22-winx64\bin>mysqld --initialize
After the initialization is successful, there will be no prompt on the command line. But the data directory has been automatically generated in the mysql5.7 folder
6 Open the registry, find HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\mysql2, and modify the ImagePath Parameters, correct the path related to the mysql2 service.
Modify the ImagePath parameters:
7 Start the database and change the password
Use the net start mysql2 command to start the mysql2 service
C:\mysql-5.7.22-winx64\bin>net start mysql2 mysql2 服务正在启动 . mysql2 服务已经启动成功。
(If mysql2 fails to start, please check whether you have stopped the previous mysql service, see the first step)
After the mysql2 service is started, find the temporary password in the data/xxx.err file and log in
Use the temporary password to log in (Note: P port, p password)
C:\mysql-5.7.22-winx64\bin>mysql -P3307 -uroot -p
Enter password: ************ (此处输入的是临时密码)
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.22Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
修改密码
mysql> set password for root@localhost=password('001nX123456'); Query OK, 0 rows affected, 1 warning (0.00 sec)
使用 quit 退出,使用新密码登录。
mysql> quit Bye C:\mysql-5.7.22-winx64\bin>mysql -P3307 -uroot -p Enter password: ************* Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.22 MySQL Community Server (GPL)
结束。
The above is the detailed content of How to install two mysql databases on the computer?. For more information, please follow other related articles on the PHP Chinese website!