1. Download the installation package MySQL official: Https://dev.mysql.com/downloads/mysql/ MySQL 5.7 Official Installation Documentation: https://dev.mysql.com/doc/refman/5.7 /en/binary-installation.html 2. Installing the dependency package MySQL relies on the Libaio library. If this library is not installed locally, data Catalog initialization and subsequent server boot steps will fail. Please use the appropriate Package Manager to install the device. For example, on a Yum-based system:shell> Yum search libaio shell> yum install libaio 3. Create a MySQL user and group shell> Groupadd Mysqlshell> Useradd-r-G mysql-s/bin/false mysql 4. Extract to the specified directory shell> TAR-ZXVF Mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz-c/usr/localshell> cd/usr/localshell> MV mysql-5.7.21-linux-glibc2.12-x86_64 mysql 5. Configuration database catalog Data Directory:/usr/local/mysql/data parameter file my.cnf:/usr/local/ mysql/etc/my.cnf error log log-error:/usr/local/mysql/log/mysql_error.log binary log log-bin:/usr/local/mysql/ log/mysql_bin.log slow query log slow_query_log_file://usr/local/mysql/log/mysql_slow_query.log socket socket file:/ Usr/local/mysql/run/mysql.sock pid file:/usr/local/mysql/run/mysql.pid shell> mkdir-p/usr/local /mysql/{data,log,etc,run}shell> Chown-R mysql:mysql/usr/local/mysql shell> chmod 750/usr/local/mysql/{data,log,etc,run} 6. Configuring my.cnf files in/usr /local/mysql/etc/Create the My.cnf file, add the following parameters, additional parameters are configured as needed [client]port = 3306socket =/usr/local/mysql/run/mysql.sock [ Mysqld]port = 3306socket =/usr/local/mysql/run/mysql.sockpid_file =/usr/local/mysql/run/mysql.piddatadir =/usr/ Local/mysql/datadefault_storage_engine = Innodbmax_allowed_packet = 128mmax_connections = 2048open_files_limit = 65535 skip-name-resolvelower_case_table_names=1 character-set-server = Utf8mb4collation-server = utf8mb4_ unicode_ciinit_connect= ' SET NAMES utf8mb4 ' innodb_buffer_pool_size = 128minnodb_log_file_size = 128minnodb_file_per_table = 1innodb_flush_log_at_trx_commit = 0 key_buffer_size = 16M log-error =/usr /local/mysql/log/mysql_error.loglog-bin =/usr/local/mysql/log/mysql_bin.logslow_query_log = 1slow_query_log_file = /usr/local/mysql/log/mysql_slow_query.loglong_query_time = 5 tmp_table_size = 16mmax_heap_table_size = 16mquery_cache_type = 0query_cache_size = 0 server-id=1 7. Set temporary password grep ' temporary Password '/usr/local/mysql/log/mysql_error.log 8. Initialize/USR/LOCAL/MYSQL/BIN/MYSQLD--user=mysql--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data-- Initialize 9. Turn mysqld settings on for auto-start cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysqldchkconfig--add mysqld 10. Copy configuration file my.cnf cp/usr/local/mysql/etc/my.cnf/etc/my.cnf (overwrite with hint) 11. Start the MySQL serviceservice MySQL start 12. Enter Mysqlcd/usr/local/mysql/bin./mysql-u root-p (temporary password)13. Change password reset password set PASSWORD for ' root ' @localhost =password (' admin '); #对应的换成你自己的密码即可14, open Remote permissions grant all privileges on * * to ' new user name ' @ '% ' identified by ' new password '; flush privileges; 15. Configure the environment variable Vim/etc/profileexport Path=/usr/local/mysql/bin: $PATHSource/etc/profile
mysql5.7.21 Source Installation