Notes:
- The process described here is for Linux OS.
- We can only have one version of MySQL setup on the machine using default installation procedure with apt-get.
- If we try to install one version over other, it will replace the first version and will retain the second version.
1. Create Data directory
1.1 Create a directory
1.2 Initializing the directory
Initializing the directory
Add rules to the policy file to stop the OS from restricting MySQL to access our newly created directoriesy, etc.
Edit “/etc/apparmor.d/usr.sbin.mysqld”, add these permissions (as the default data dir has).
Restart apparmor service
(AppArmor is a linux kernel security module that allows you to restrict program capabilities on a per-program basis)
1.3 Initialize the created data dir as a MySQL data directory
Check the contents of the dir: “sudo ls -l /opt/second_server_data/”.
These files should be there (drwxr-x--- 2 mysql mysql …..) : mysql, performance_schema, sys
A default root password was generated and stored in “/var/log/mysql/error.log”
2020-12-17T08:45:06.170673Z 1 [Note] A temporary password is generated for root@localhost: 1hfBQ5G66d_V
2. Create a socket (and a TCP port) for a client
Given correct permissions MySQL is able to create these on its own.
3. MySQL configurations
* Steps 3-5 can be done also using mysqld or mysqld_safe.
start mysqld / mysqld_safe
- no-defaults: Makes sure no options are loaded from option files.
- data-dir: Path to the data directory that we created.
- port: TCP port.
- mysqlx: X plugin is an interface to allow MySQL function as a document store. Since we don’t need it, we will disable it.
- socket: Specify location of socket file
4. Testing
In order to perform SQL operations, the auto generated password should be changed:
5. Create cnf file for the second instance
5.1 Copy the cnf file and add to it:
or
5.2 start mysqld/mysqld_safe with the new cnf
or
5.3 Testing as before
6. Create a service for the new instance
Create a service using system
6.1 Create “.service” file
Save in “/lib/systemd/system/” or “/etc/systemd/system”
No comments:
Post a Comment