How to start multiple MySQL databases on a Linux host

How to start multiple MySQL databases on a Linux host

Today, let’s talk about how to start four MySQL databases on a Linux host:

1. Make sure MySQL is installed on your machine. My MySQL is under /usr/loacl/:

cd /usr/local/mysql-5.7.18/
ll

2. Enter the /usr/loacl/data folder (not created by yourself), and create four folders under data, such as: 3307 3308 3309 3310:

mkdir data
cd data
mkdir 3307
mkdir 3308
mkdir 3309
mkdir 3310 

3. Initialize the database under /usr/loacl/mysql-5.7.18/bin/ and specify these four folders:

./mysqld --initialize-insecure --basedir=/usr/local/mysql-5.7.18 --datadir=/usr/local/mysql-5.7.18/data/3307 --user=mysql
./mysqld --initialize-insecure --basedir=/usr/local/mysql-5.7.18 --datadir=/usr/local/mysql-5.7.18/data/3308 --user=mysql
./mysqld --initialize-insecure --basedir=/usr/local/mysql-5.7.18 --datadir=/usr/local/mysql-5.7.18/data/3309 --user=mysql
./mysqld --initialize-insecure --basedir=/usr/local/mysql-5.7.18 --datadir=/usr/local/mysql-5.7.18/data/3310 --user=mysql

initialize-insecure means that no random password is generated for the root user of the MySQL database, that is, the root password is empty.

4. Create a file named my.cof under 3307 3308 3309 3310 and insert the configuration content. Note that it is created in each folder:

cd /usr/local/mysql-5.7.18/data/3307/
mkdir my.conf
vim my.cof
***Insert content below***
[client]
port = 3307
socker = /usr/local/mysql-5.7.18/data/3307/mysql.sock
default-character-set=utf-8
 
[mysqld]
port = 3307
socker = /usr/local/mysql-5.7.18/data/3307/mysql.sock
datadir = /usr/local/mysql-5.7.18/data/3307
log-error = /usr/local/mysql-5.7.18/data/3307/error.log
pid-file = /usr/local/mysql-5.7.18/data/3307/mysql.pid
 
character-set-server=utf8
lower_case_table_names=1
autocommit=1

The folder name in each configuration file can be modified by yourself, so I will not go into details here.

port: port number 3307

socker: IP and port

datadir: data path

log-error: error file location

pid-file : pid file location

character-set-server : character set

lower_case_table_names: Whether to ignore table case. 1 means ignore

autocommit: Automatically submit 1 is yes

5. Start the test:

cd /usr/loacl/mysql-5.7.18/bin/
./mysql_safe --defaults-file=/usr/loacl/mysql-5.7.18/data/3307/my.cnf &
./mysql_safe --defaults-file=/usr/loacl/mysql-5.7.18/data/3308/my.cnf &
./mysql_safe --defaults-file=/usr/loacl/mysql-5.7.18/data/3309/my.cnf &
./mysql_safe --defaults-file=/usr/loacl/mysql-5.7.18/data/3310/my.cnf &

Among them, --defaults-file specifies the configuration file, and & indicates background startup

Check:

6. Login:

./mysql -uroot -p -P3307 -h127.0.0.1 #Note that it is executed under /usr/loacl/mysql-5.7.18/bin 

7. You can modify the root password:

alter user 'root'@'localhost' identified by 'xxx';

To log in remotely in the user interface, you need to configure:

grant all privileges on *.* to root@'%' identified by 'xxx';

*.*: The first * represents all database names, and the second * represents all database tables.

root@'%': root represents the user name, % represents the IP address, which can be specific to a certain IP address, such as: [email protected]

Then execute the permission refresh:

flush privileges;

You can try each database one by one ^ _ ^. .

This is the end of this article about how to start multiple MySQL databases on a Linux host. For more relevant content about starting multiple MySQL databases on Linux, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • MySQL multi-instance deployment and installation guide under Linux
  • MySQL 8.0.25 installation and configuration tutorial under Linux
  • Steps and pitfalls of upgrading linux mysql5.5 to mysql5.7
  • Solve the problem of no my.cnf file in /etc when installing mysql on Linux
  • Steps to install MySQL using Docker under Linux
  • Detailed explanation of how to manually deploy a remote MySQL database in Linux
  • Detailed explanation of the idea of ​​using mysqldump+expect+crontab to implement mysql periodic cold backup in linux
  • Aliyun Linux compile and install php7.3 tengine2.3.2 mysql8.0 redis5 process detailed explanation
  • How to implement scheduled backup of MySQL in Linux
  • How to reset the root password in Linux mysql-5.6
  • Use MySQL to open/modify port 3306 and open access permissions in Ubuntu/Linux environment
  • MySQL scheduled backup solution (using Linux crontab)
  • Detailed tutorial on installing MySQL database in Linux environment
  • How to automatically backup mysql remotely under Linux
  • Linux MySQL root password forgotten solution
  • Detailed tutorial on installing mysql-8.0.20 under Linux
  • How to use MyCat to implement MySQL master-slave read-write separation in Linux

<<:  Vue routing lazy loading details

>>:  CSS3 creates web animation to achieve bouncing ball effect

Recommend

10 Website Usability Tips Everyone Should Know

Let’s not waste any more time and get straight to...

In-depth analysis of MySQL deadlock issues

Preface If our business is at a very early stage ...

HTML tag ID can be a variable

<table id=" <%=var1%>">, the...

Analysis of the process of implementing Nginx+Tomcat cluster under Windwos

Introduction: Nginx (pronounced the same as engin...

Will Update in a Mysql transaction lock the table?

Two cases: 1. With index 2. Without index Prerequ...

MySQL single table query example detailed explanation

1. Prepare data The following operations will be ...

How to implement logic reuse with Vue3 composition API

Composition API implements logic reuse steps: Ext...

Simple tutorial on using Navicat For MySQL

recommend: Navicat for MySQL 15 Registration and ...

How to migrate local mysql to server database

We can use the scp command of Linux (scp cannot b...

Detailed explanation of Vue-Jest automated testing basic configuration

Table of contents Install Configuration Common Mi...

JS implements sliding up and down on the mobile terminal one screen at a time

This article shares with you the specific code of...

Analysis of Hyper-V installation CentOS 8 problem

CentOS 8 has been released for a long time. As so...

HTML Several Special Dividing Line Effects

1. Basic lines 2. Special effects (the effects ar...