MySQL - Installing Latest Percona mysql on Debian 12

MySQL - Installing Latest Percona mysql on Debian 12

Disclaimer:
The information provided in this guide is for educational and informational purposes only. It is provided “as is” without any representations or warranties, express or implied. You are using this information at your own risk. The author assumes no responsibility for any loss, damage, or issues arising from the use or misuse of the content provided.


Preparations:

Debian: (if from minimal installation)
1. sudo apt update
2. sudo apt upgrade
3. sudo apt install gnupg2 lsb-release curl software-properties-common ufw
4. sudo ufw allow ssh
If there are any other ports you need to allow in before you enable the firewall use:
ufw allow <portnumber>
5. sudo ufw enable

Optional for POSIX compatibility:
6. sudo apt install net-tools 


Add Percona APT to Repository:

2. sudo dpkg -i percona-release_latest.generic_all.deb
3. sudo percona-release setup ps80
4. sudo apt update

Install Percona Server for MYSQL

1. sudo apt install percona-server-server

This will install the server and prompt to setup a new root password for MYSQL (not your system root user).

2. sudo systemctl enable mysql
3. sudo systemctl start mysql
4. sudo systemctl status mysql
5. Check status: sudo systemctl status mysql

Add User to MySql Group:

1. sudo usermod -aG mysql <username>

Example: sudo usermod -aG mysql alice

2. create /etc/mysql/certs for SSL certificates

sudo mkdir -p /etc/mysql/certs

3. change ownership to mysql

sudo chown -R mysql:mysql /etc/mysql

4. change permission to allow group to read and write /etc/mysql/certs

sudo chmod -R ug+rw /etc/mysql/certs


Network Access:

By default, MySQL on Debian binds to 127.0.0.1 (localhost). You must change it to listen on an external IP.

1. Create  /etc/mysql/mysql.conf.d/network-access.cnf

sudo nano  /etc/mysql/mysql.conf.d/network-access.cnf

2. Add the following:

[mysqld]
bind-address = 0.0.0.0

3. Restart: sudo systemctl restart mysql

4. confirm: sudo netstat -tnlp | grep 3306

5. Allow mysql port 3306 through firewall:

To allow 3306 for everyone in the network:  sudo ufw allow 3306/tcp

To allow specific host by IP:
1. If you added rule to allow everyone, delete it:  sudo ufw delete allow 3306/tcp
2. sudo ufw allow from <IPADDRESS> to any port 3306 proto tcp
Example, using 192.168.100.2:  sudo ufw allow from 192.168.100.2 to any port 3306 proto tcp

Secure the installation

1. sudo mysql_secure_installation


Add Admin user (other than root):

1. Select username to add.

NOTE:  Our example user is "sqladmin", replace this with your own.

2. mysql -u root -p
Enter your password for mysql user, root.  (NOTE this is not your system root user).

This should enter the MYSQL console/prompt:  mysql>

3. Add the user.

NOTE: replace <password> with actual new password for the user.

mysql> CREATE USER 'sqladmin'@'localhost' IDENTIFIED BY '<password>';

mysql> GRANT ALL PRIVILEGES ON *.* TO 'sqladmin'@'localhost' WITH GRANT OPTION;

mysql> FLUSH PRIVILEGES;

4. If you have more admins to add, repeat steps 1-3 for each SQL user.

5. Logout of MYSQL: 

mysql> quit
[Optional] Create a test  database:

1. Select the name of your database.  For this example we'll use 'testdb'

2. Login to mysql:  mysql -u testuser -p

3. Create your database:

mysql> CREATE DATABASE testdb;
mysql> quit

4. At this point, you've setup your first database.  For the rest, refer to MySQL guides. 


    • Related Articles

    • MySQL - How to Clone All Data from DONOR MySQL server to another using MySQL Clone Plugin

      Disclaimer: The information provided in this guide is for educational and informational purposes only. It is provided “as is” without any representations or warranties, express or implied. You are using this information at your own risk. The author ...
    • MySQL - Enable SSL connection between MySQL hosts using self-signed SSL

      Disclaimer: The information provided in this guide is for educational and informational purposes only. It is provided “as is” without any representations or warranties, express or implied. You are using this information at your own risk. The author ...
    • MySQL - Common Command Syntaxes

      Disclaimer: The information provided in this guide is for educational and informational purposes only. It is provided “as is” without any representations or warranties, express or implied. You are using this information at your own risk. The author ...
    • MySQL - Setup multi-threaded replication

      Disclaimer: The information provided in this guide is for educational and informational purposes only. It is provided “as is” without any representations or warranties, express or implied. You are using this information at your own risk. The author ...
    • MySQL - How to use mysqldump

      Disclaimer: The information provided in this guide is for educational and informational purposes only. It is provided “as is” without any representations or warranties, express or implied. You are using this information at your own risk. The author ...