Rate This Document
Findability
Accuracy
Completeness
Readability

Running Percona

After installing Percona, configure and start the Percona database. The operations include modifying the configuration file, setting environment variables, initializing the database, and starting and logging in to the database.

  1. Modify the configuration file.
    1. Edit the my.cnf file and change the file paths (including the software installation path basedir and data path datadir) based on the actual situation.
      1
      2
      rm -f /etc/my.cnf
      echo -e "[mysqld_safe]\nlog-error=/data/percona/log/mysql.log\npid-file=/data/percona/run/mysqld.pid\n[mysqldump]\nquick\n[mysql]\nno-auto-rehash\nsocket=/data/percona/run/mysql.sock\n[client]\ndefault-character-set=utf8\n[mysqld]\nbasedir=/usr/local/percona\ntmpdir=/data/percona/tmp\ndatadir=/data/percona/data\ndefault_authentication_plugin=mysql_native_password\nport=3306\nuser=mysql\n" > /etc/my.cnf
      
    2. Check that the my.cnf file is correctly modified.
      1
      cat /etc/my.cnf
      

    3. Change the group and user of the /etc/my.cnf file to mysql:mysql.
      1
      chown mysql:mysql /etc/my.cnf
      
  2. Configure environment variables.
    1. After the compilation and installation are complete, add the path of the Percona binary file to the PATH environment variable.

      In the command, /usr/local/percona/bin is the absolute path of the bin files in the Percona Server software installation directory.

      1
      echo export PATH=$PATH:/usr/local/percona/bin >> /etc/profile
      
    2. Make the environment variable settings take effect.
      1
      source /etc/profile
      
  3. If you use RPM packages from the mirror site to install Percona, follow this step to avoid database initialization failure. If you compile the source code to install Percona, skip this step.
    1. Download the rpm-bug.zip package and upload it to the /home directory on the server.

      Download URL: https://mirrors.huaweicloud.com/kunpeng/archive/kunpeng_solution/database/patch/rpm-bug.zip

    2. Decompress rpm-bug.zip.
      1
      2
      cd /home/
      unzip rpm-bug.zip
      
    3. Go to the directory where the package is decompressed and save the files in the directory to the corresponding library file directory. When a message is displayed asking whether to rewrite the file, enter y and press Enter.
      1
      2
      3
      4
      5
      6
      cd rpm-bug
      cp libatomic.so.1 /usr/lib64/
      cp libstdc++.so.6.0.24 /lib64/
      rm /lib64/libstdc++.so.6
      ln -s /lib64/libstdc++.so.6.0.24 /lib64/libstdc++.so.6
      cp libaio.so.1.0.1 /usr/lib64/libaio.so.1
      
  4. Initialize the database.
    1
    /usr/local/percona/bin/mysqld --defaults-file=/etc/my.cnf --initialize --basedir=/usr/local/percona --datadir=/data/percona/data
    

    je50.Yn&swR< highlighted in the second last line in the figure is the initial password that is automatically generated. Keep it secure. It will be used in 6.

  5. Start the database.
    1. Start the Percona service as user mysql, and run the following commands and press Enter.
      1
      2
      su - mysql
      /usr/local/percona/bin/mysqld_safe &
      

      • The mysqld_safe script will monitor the running status of the MySQL server after the MySQL server is started, and restarts the MySQL server when it breaks down.
      • Start MySQL as user mysql if it is the first time to start the database service. If you start MySQL as user root, a message will be displayed indicating that the mysql.log file is missing. If you start the database as user mysql, a mysql.log file will be generated in the /data/percona/log directory. No error will be displayed if you start the database as user root again.
    2. Check the Percona process. When mysqld_safe is started, mysqld is also started.
      ps -ef | grep mysql

  6. Log in to the database as user mysql.
    1
    /usr/local/percona/bin/mysql -uroot -p
    

    The password is je50.Yn&swR<, which is the initial password generated in 4. Pay attention to the special characters.

  7. Configure the database accounts.
    1. Change the login password of local user root. In this example, the password is 123456.
      1
      alter user 'root'@'localhost' identified by "123456";
      
    2. Create a user root for all domains and allow user root to access from other servers.
      1
      create user 'root'@'%' identified by '123456';
      
    3. Grant the root users the same access permissions as the local root user.
      1
      2
      grant all privileges on *.* to 'root'@'%';
      flush privileges;
      

  8. Optional: Exit the database.
    \q

    or

    1
    exit