Objective
If the reader is using search engines (Baidu, Google) to search for "Linux installation MySQL" to find here, but also a new, then please read the preface and other words carefully. If it is a veteran, please search directly for what you want and jump to read.
This headline shows our purpose, that is to specify the operating system (Linux) to install the software we need (MySQL), but there are three aspects of the error.
- Error One: There is no clear operating system which is the distribution of Linux. In fact, the different Linux distributions are different, reflected in the choice of software version, the kernel version is different and so on. Therefore, there may be differences in the installation of different distributions.
- Error Two: There is no explicit version of MySQL. This is a serious matter for software version selection. If there is a large version of the MySQL version that is required for the project, it may not work correctly, and instability may occur if a non-GA version is selected.
- Error Three: There is no explicit way to install MySQL. For the Linux operating system, there are basically installation package installation, binary installation, the source code installation of the three installation methods. The installation packages that need to be downloaded are different for different installations, and the installation process is different.
It is the presence of these ambiguity that leads to a large number of different descriptions in the many related articles that are being queried.
Installation Requirements
- Operating system: CentOS 7.5.1804
- MySQL version: MySQL 8.0.11
- Installation method: Binary installation, installation package name: mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz
If the actual installation provides a different environment and needs, the following text is only suitable for use as a reference. (Of course, for the veteran, the operating system version of the difference is very small, MySQL version is very small difference, is the premise of binary installation, the key to install only a few command lines)
installation process
Step 1: Turn off SELinux
- Check the SELinux open state
shell> getenforce Enforcing (Enforcing表示selinux处于开启状态)
- Temporarily close SELinux
shell> setenforce 0
- Check again to confirm close
shell> getenforce Permissive (Permissive表示selinux处于开启状态,但是放任一切行为,这被认作是事实上的关闭状态)
-
Permanently close SELinux
shell> vim /etc/sysconfig/selinux...SELINUX=disabled...
Step 1 Summary : SELinux can cause many software installation exceptions, usually by shutting them down directly. Its closing method has a temporary shutdown and a permanent shutdown. The so-called temporary and permanent difference is whether the server can maintain its modified state after the restart.
Step 2: Turn off the firewall
- Check firewall status
shell> systemctl status firewalld ...Active: active (running)...
- Temporarily shut down the firewall
shell> systemctl stop firewalld
- Check firewall status
shell> systemctl status firewalld...Active: inactive (dead)...
- Permanently shut down the firewall
shell> systemctl disable firewalld
Step 2 Summary : The significance of shutting down the firewall is to prevent the database from being accessed by the external network because the port is not reachable. However, the correct use of the firewall can be guaranteed to open the firewall and ensure that the database is properly accessed, not to expand here.
Step 3: Install dependencies
- Install Libaio
shell> yum install-y libaio
Step 3 Summary : Yum Install command is idempotent operation, Installed on the first use, other times when used will automatically check whether installed and as the Update software processing, so you can use it boldly. Dependency loss is one of the main reasons for software installation failure, so this step can not only be omitted, but also due to the specific operating system environment and increased operations.
Step 4: Create MySQL users and groups
shell> groupadd mysqlshell> ~]# useradd-r-G mysql-s/bin/false MySQL
Summary of Step 4 : Create a non-logged-in MySQL user and MySQL group for the management of post-installation permissions.
Step 5: Unpack the installation package
shell> mkdir/applicationshell> cd/application//to place the installation package under this directory through the FTP tool shell> tar zxf mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz shell> lsmysql-8.0.11-linux-glibc2.12-x86_64 mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz
Step 5 Summary : Essentially, the installation package is extracted to the/application directory.
Step 6: Make a soft connection
shell> ln-s/application/mysql-8.0.11-linux-glibc2.12-x86_64/usr/local/mysql
Step 7: Delete old configuration information
shell> rm-rf/etc/my.cnf/etc/my.cnf.d/
Step 8: Establish new configuration information
shell> vim/etc/my.cnf
[Client]
Port = 3306
Socket =/tmp/mysql.sock
[Mysqld]
user = MySQL
Port = 3306
Basedir =/usr/local/mysql
DataDir =/data/mysql/
Socket =/tmp/mysql.sock
Pid-file = Db.pid
Character-set-server = Utf8mb4
**步骤8总结**:配置信息是用好MySQL的关键。---步骤9:初始化
shell>/usr/local/mysql/bin/mysqld--initialize--user=mysql
**步骤9总结**:初始化会读取默认配置文件(/etc/my.cnf),注意该过程的输出中有临时密码。---步骤10:安全增强
Shell>/usr/local/mysql/bin/mysql_ssl_rsa_setup
---步骤11:启动
Shell>/usr/local/mysql/bin/mysqld_safe--user=mysql &
---步骤12:初次使用需修改密码
mysql> alter user ' root ' @ ' localhost ' identified by ' 123456 ';
步骤13:关闭
Shell>/usr/local/mysql/bin/mysqladmin-u root-p shutdown
Linux installation MySQL