Article From:

I. Inspection before installation
  1.1 Check Linux system version

[root@localhost ~]# cat /etc/system-release

  1.2 Check if MySQL is installed

[root@localhost ~]# rpm -qa | grep mysql


   If there is a MySQL installation file, the version information of the MySQL installation will be displayed
   For example: mysql-connector-odbc-5.2.5-6.el7.x86_64
   Uninstall installed MySQL and uninstall MySQL commands as follows:

[root@localhost ~]# rpm -e --nodeps mysql-connector-odbc-5.2.5-6.el7.x86_64


   Delete all files under the / var / lib / MySQL folder.
   Attention to details:
   Check if there is a MariaDB database in the system. If there is one, it must be uninstalled. Otherwise, it may conflict with mysql.
   Check if MariaDB is installed:


[root@localhost ~]# rpm -qa | grep mariadb
DeleteSystem CTL stop MariaDBRpm-qa | grep MariaDBRpm-e -- nodeps mariadb-5.5.52-1.el7.x86_64Rpm-e -- nodeps mariadb-server-5.5.52-1.el7.x86_64Rpm-e -- nodeps mariadb-libs-5.5.52-1.el7.x86_64


Installation of MySQL
  3.1 Unzip the installation package and move to the MySQL directory
    Unzip mysql’s GZ installation package:

[root@localhost apps]# tar -zvxf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz -C /usr/local/mysql
/usr/local Create folders under the directory to store mysql: [root@localhost~] # mkdir/usr/local/mysql


  3.2 Adding System Users
    Add MySQL groups and MySQL users:

Add MySQL group: [root@localhost~] group add MySQLAdd MySQL user: [root@localhost~] useradd-r-g MySQL mySQL


  3.3 Install MySQL

Enter the installation MySQL software directory: [root@localhost~] cd/usr/local/mysql/Installation profile: [root@localhost mysql] CP. / support- files/my-default.cnf/etc/my.cnf (prompt for overwriting, enter "y" consent)Modify my.cnf: [root@localhost mysql] vim/etc/My.cnf



# Setting the default character set for MySQL clientDefault-character-set = utf8Socket=/var/lib/mysql/mysql.sock[mysqld]#skip-name-ResolveSetting Port 3306Port = 3306Socket=/var/lib/mysql/mysql.sock# Set up the installation directory of MySQLBasedir=/usr/locaL/mysql# Set up the storage directory of MySQL database dataDatadir=/usr/local/mysql/dataMaximum number of connections allowedMax_connections = 200# Server Enabler uuuuuuuuuuuuThe character set used defaults to 8-bit coded Latin1 character setCharacter-set-server = utf8Default storage engine to be used when creating new tablesDefault-storage-engine = INNODB#lower_case_table_name=1Max_allowed_packet=16M# Initially login MySQL with no password# skip-grant-tables



Create a data folder: [root@localhost mysql] mkdir. / dataModify the current directory owner to be MySQL user: [root@localhost mysql] chown -R mysql: mysql. /Initialize mysqld: [root@localhost mysql]#. / bin/mysqld -- initialize -- user = MySQL -- basedir=/usr/local/mysql/ - datadir=/usr/local/mysql/data/Start mysqld: [root@localhost mysql] service mysqLD start


    If normal, the installation is successful

    If the report is wrong,

# 2018-09-08T01:42:11.940420Z mysqld_safe Logging to '/var/log/mysqld/my57_3307.log'.
2018-09-08T01:42:11.949380Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.
[1]+ Exit 1 /usr/local/mysql57/bin/mysqld_safe --defaults-file=/dbdata/mysql/my57_3307/my57_3307.cnf --ledir=/usr/local/mysql57/bin


Terms of settlement:

1、Edit the mysqld_safe file under the MySQL installation directory bin

[root@test2 ~]# vim /usr/local/mysql/bin/mysqld_safe


2、Find the following code

# Check that directory for $safe_mysql_unix_port exists
mysql_unix_port_dir=`dirname $safe_mysql_unix_port`
if [ ! -d $mysql_unix_port_dir ]
mkdir $mysql_unix_port_dir
chown $user $mysql_unix_port_dir
chmod 755 $mysql_unix_port_dir
# Here's the original configuration for Version 5.7: Modify it to the three lines above# log_error "Directory'$mysql_unix_port_dir'for UNIX socket file don't exist'tS. "Exit 1Fi


After saving, restart successfully


Leave a Reply

Your email address will not be published. Required fields are marked *