MySQL Installation and Deployment
It is recommended to use MySQL version 8.0.
Opening Specified Ports or Disabling Firewall
View the ports that are already open:
firewall-cmd --list-ports
Open a specified port (e.g., port 3306 for MySQL):
firewall-cmd --zone=public --add-port=3306/tcp --permanent
Reload the firewall configuration:
firewall-cmd --reload
Confirm the opened ports:
firewall-cmd --list-ports
If needed, you can stop the firewall:
systemctl stop firewalld
Check the firewall status:
systemctl status firewalld
Basic Environment Preparation
Create a user and group for MySQL:
groupadd mysql useradd -r -g mysql -s /sbin/nologin mysql
Install dependencies for MySQL:
yum install -y libncurses* libaio* lrzsz*
Extract the MySQL installation package:
tar -xvf mysql-8.0.28-linux-glibc2.12-x86_64.tar -C /usr/local/
Rename the extracted directory:
mv mysql-8.0.28-linux-glibc2.12-x86_64/ mysql
Create required directories:
cd /usr/local/mysql/ mkdir data
Change directory ownership:
chown -R mysql:mysql /usr/local/mysql/
Deploy MySQL Service
Initialize the database:
/usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --initialize
Edit
my.cnf
configuration: Create/Edit the configuration file/etc/my.cnf
and add the following content:[mysqld] basedir=/usr/local/mysql datadir=/usr/local/mysql/data socket=/usr/local/mysql/data/mysql.sock bind-address = 0.0.0.0 user=root port=3306 log-bin=mysql-bin server-id=1 max_connections=2048 character-set-server=utf8 default-storage-engine=INNODB [client] socket=/usr/local/mysql/data/mysql.sock
Configure environment variables:
echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile source /etc/profile
Configure startup script:
cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld chmod +x /etc/rc.d/init.d/mysqld cat > /lib/systemd/system/mysqld.service <<EOF [Unit] Description=mysqld After=network.target [Service] Type=forking ExecStart=/etc/rc.d/init.d/mysqld start ExecReload=/etc/rc.d/init.d/mysqld restart ExecStop=/etc/rc.d/init.d/mysqld stop PrivateTmp=true [Install] WantedBy=multi-user.target EOF
Reload systemd configuration:
systemctl daemon-reload
Set MySQL to start on boot:
systemctl enable mysqld
Start MySQL:
systemctl start mysqld
Check if MySQL port is active:
netstat -tunlp | grep 3306
Configure Password for Remote Connection
Enter the printed password to log in to MySQL:
mysql -u root -p
After logging in, change the root password:
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Check user information:
select user, host, ssl_type from mysql.user; use mysql;
Update the host field to
%
to allow remote connections:update user set host = '%' where user = 'root';
Refresh privileges:
flush privileges;
Adding Archive Platform Fields
Log in to MySQL:
mysql -u root -p
Create a database:
create database filing;
Add data from the provided SQL file:
use filing; source /usr/local/filing.sql;
Check the added tables:
use filing; show tables;
As always, ensure that you adapt paths, filenames, and other specifics to match your system's configuration.