Linux system installation mysql

There are two installation methods for linux to install mysql service:

①Source code installation, the advantage is that the installation package is relatively small, only more than ten M, the disadvantage is that the installation depends on many libraries, the installation and compilation time is long, and the installation steps are complex and error-prone;

②Using the official compiled binary file to install, the advantage is that the installation speed is fast and the installation steps are simple. The disadvantage is that the installation package is very large, about 300M. The following describes how to install mysql using the official compiled binary package for linux.

Tools/Materials

  • mysql-5.6.17-linux-glibc2.5-i686.tar.gz
  • mysql-5.6.17-linux-glibc2.5-x86_64.tar.gz
  • Linux system, both 32-bit and 64-bit

method/step

  1. Go to the mysql official website to download the mysql-compiled binary installation package, select linux-generic in the Select Platform: option on the download page, and then pull the page to the bottom, download Linux - Generic (glibc 2.5) (x86, 64-bit) for 64-bit systems, 32-bit system download Linux - Generic (glibc 2.5) (x86, 32-bit)

    Linux system installation mysql
    Linux system installation mysql
  2. Unzip the 32-bit installation package:

    Enter the directory where the installation package is located and execute the command: tar mysql-5.6.17-linux-glibc2.5-i686.tar.gz

    Linux system installation mysql
  3. Copy the decompressed mysql directory to the system's local software directory:

    Execute the command: cp mysql-5.6.17-linux-glibc2.5-i686 /usr/local/mysql -r

    Note: Do not add / at the end of the directory

    Linux system installation mysql
  4. Add the system mysql group and mysql user:

    Execute commands: groupadd mysql and useradd -r -g mysql mysql

    Linux system installation mysql
    Linux system installation mysql
  5. Install the database:

    Enter the directory where the mysql software is installed: execute the command cd /usr/local/mysql

    Change the owner of the current directory to the mysql user: execute the command chown -R mysql:mysql ./

    Install the database: execute the command ./scripts/mysql_install_db --user=mysql

    Change the owner of the current directory to the root user: execute the command chown -R root:root ./

    Change the owner of the current data directory to the mysql user: execute the command chown -R mysql:mysql data

    To this database installation is complete

    Linux system installation mysql
  6. Start the mysql service and add the startup mysql service:

    Add startup startup: execute the command cp support-files/mysql.server /etc/init.d/mysql, and put the startup script in the startup initialization directory

    Start the mysql service: execute the command service mysql start

    Execute the command: ps -ef|grep mysql and see that the mysql service indicates that the startup is successful, as shown in the figure

    Linux system installation mysql
  7. Modify the root user password of mysql, the initial root password is empty:

    Execute the command: ./bin/mysqladmin -u root password 'password'

    Linux system installation mysql
  8. Put the mysql client in the default path:

    ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql

    Note: It is recommended to use the soft chain in the past, do not copy the package file directly, it is convenient for the system to install multiple versions of mysql

    Linux system installation mysql

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325668920&siteId=291194637