MySQL 5.7.21 how to install Part 2 in Linux platform
This article mainly introduces MySQL 5.7.21 how to install Part 2 in the Linux platform, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
1. Directory planning directory name parameter name path address installation directory basedir/usr/local/mysql data file directory datadir/data/mysql/data temporary file directory tmpdir/data/mysql/tmpsocket file directory socket/data/mysql/data/mysql.sockbin log file directory log_bin/datalog/mysql/binlogrelay log file directory relay_log/datalog/mysql/relaylog2. MySQL 5.7download
Currently, GA of the MySQL community provides downloads of 5 and 8.
Since most systems still use version 5 at present
The version of 5 is used here.
Note that the following is installed according to version 5.7.21, which is the same as 5.25
MySQL Community Server 5.7.25
3. New users and directories
/ usr/sbin/groupadd-g 105 mysql
/ usr/sbin/useradd-u 105-g mysql mysql
Echo "mysql123" | passwd mysql-- stdin
4. Create a new directory mkdir-p / data/mysql/softwaremkdir-p / usr/local/mysqlmkdir-p / data/mysql/datamkdir-p / datalog/mysql/binlogmkdir-p / datalog/mysql/relaylogchown-R mysql:mysql / usr/local/mysqlmkdir-p / data/mysql/tmpchown-R mysql:mysql / data/mysqlchown-R mysql:mysql / datalog/mysql/
5. Configure the environment variable su-mysqlvim ~ / .bash_profileexport MYSQL_HOME=/usr/local/mysqlexport PATH=$HOME/bin:$MYSQL_HOME/bin:$PATHexport LD_LIBRARY_PATH=$MYSQL_HOME/lib:$LD_LIBRARY_PATHsource ~ / .bash_profile
6. Establish a configuration file
We set up / etc/my.cnf here
[mysql] user = password = [mysqld] #-MySQL Basic Setting-#server-id = 1723161113port = 3306user = mysqlpid-file = mysql.pidcharacter_set_server = utf8mb4default_storage_engine = InnoDBskip_name_resolve = 1lower_case_table_names = 1explicit_defaults_for_timestamp = 1open_files_limit = 65535max_connections = 1000max_connect_errors = 100000basedir = / usr/local/mysqldatadir = / data/mysql/datatmpdir = / data/mysql/tmpsocket = / data/mysql/data/mysql.sockquery_cache_type = query_cache_size = join_buffer_size = 64Mtmp_table_size = 64Mmax_allowed_packet = 32Mread_buffer_size = 16Mread_rnd_buffer_size = 32Msort_buffer_size = 32M#-MySQL Log Setting-#log_error = mysql- Error.loglog_bin = / datalog/mysql/binlog/mysql-bin.logslow_query_log_file = mysql-slow.logrelay_log = / datalog/mysql/relaylog/mysql-relay.loglog_slave_updates = 1sync_binlog = 1relay_log_recovery = 1binlog_format = rowexpire_logs_days = 14slow_query_log = 1long_query_time = 2log_queries_not_using_indexes = 1log_throttle_queries_not_using_indexes = 10log_slow_admin_statements = 1log_slow_slave_statements = 1min_examined_row_limit = 1000#-MySQL Replication Setting-#slave_skip_errors = ddl_exist_errorsmaster_info_repository = TABLErelay_log_info_repository = TABLEgtid_mode = onenforce_gtid_consistency = 1binlog_rows_query_log_events = 1#-MySQL InnoDB Setting- -# innodb_page_size = 16384innodb_buffer_pool_size = 25600Minnodb_data_file_path = ibdata1:1G:autoextendinnodb_buffer_pool_instances = 8innodb_file_per_table = 1innodb_buffer_pool_load_at_startup = 1innodb_buffer_pool_dump_at_shutdown = 1innodb_flush_log_at_trx_commit = 1innodb_lock_wait_timeout = 5innodb_io_capacity = 800innodb_io_capacity_max = 2000innodb_flush_method = O _ DIRECTinnodb_file_format = Barracudainnodb_file_format_max = Barracudainnodb_undo_logs = 128innodb_undo_tablespaces = 3innodb_flush_neighbors = 1innodb_log_file_size = 2Ginnodb_log_buffer_size = 16777216innodb_print_all_deadlocks = 1innodb_strict_mode = 1innodb_sort_buffer_size = 67108864#-MySQL semi Replication Setting-##plugin_dir = / usr/local / mysql/lib/plugin#plugin_load = "rpl_semi_sync_master=semisync_master.so Rpl_semi_sync_slave=semisync_slave.so "# loose_rpl_semi_sync_master_enabled = 1#loose_rpl_semi_sync_slave_enabled = 1#loose_rpl_semi_sync_master_timeout = 5000
Modify my.cnf permissions
Chown mysql:mysql / etc/my.cnf
7. Dependency package inspection libaio-0.3.107-10.el6.x86_64libaio-devel-0.3.107-10.el6.x86_64lvm2-2.02.143-7.el6_8.1.x86_64
8. Uninstall previous version
If you have a previous version of MySQL, you need to download it first
If there is only lib library, you can not move it.
RedHat Enterprise Linux 6 for]
# rpm-qa | grep-I mysqlmysql-libs-5.1.71-1.el6.x86_64qt-mysql-4.6.2-26.el6_4.x86_64mysql-5.1.71-1.el6.x86_64mysql-server-5.1.71-1.el6.x86_64#yum remove mysql-5.1.71-1.el6.x86_64qt-mysql-4.6.2-26.el6: 4.x86: 64mysql-libs-5.1.71-1. El6.x86_64 mysql-server-5.1.71-1.el6.x86_64
[RedHat Enterprise Linux 7 applies]
# rpm-qa | grep-I mariadb*mariadb-server-5.5.52-1.el7.x86_64mariadb-libs-5.5.52-1.el7.x86_64mariadb-embedded-5.5.52-1.el7.x86_64mariadb-test-5.5.52-1.el7.x86_64mariadb-bench-5.5.52-1.el7.x86_64mariadb-5.5.52-1.el7.x86_64mariadb-devel-5.5.52-1.el7.x86room64mariabb- Embedded-devel-5.5.52-1.el7.x86_64# yum remove-y mariadb*
9. Extract the installation file su-mysqltar xzvf mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz-C / usr/local/mysql/-- strip-components=1
9.2 configure the service file
Here, copy the value of the mysql.server file to the init.d directory so that it can be started and stopped as a service
Cp / usr/local/mysql/support-files/mysql.server / etc/init.d/mysqld
Here are the following modifications
Vim / etc/init.d/mysqldbasedir=/usr/local/mysqldatadir=/data/mysql/datalockdir='/data/mysql/data'mysqld_pid_file_path=/data/mysql/data/mysql.pid
10. Initialize the database
Next we initialize the MySQL
# su-mysql$cd / usr/local/mysql$/usr/local/mysql/bin/mysqld-defaults-file=/etc/my.cnf-initialize-user=mysql
You can check the progress through the error file during initialization.
Tail-f / data/mysql/data/mysql-error.log
11. Start the database $/ usr/local/mysql/bin/mysqld_safe-defaults-file=/etc/my.cnf-user=mysql & $netstat-lntp | grep mysqld
Later, you can start and stop the database using the following command
Service mysqld stop
Service mysqld start
Service mysqld restart
Set MySQL self-startup
Chkconfig mysqld on
twelve。 Connect to the database
The default password is in the error file
Cat / data/mysql/data/mysql-error.log | grep password
Use the following command to connect
Mysql-S / data/mysql/data/mysql.sock-uroot-ppassword
Thank you for reading this article carefully. I hope the article "MySQL 5.7.21 how to install Part 2 in Linux platform" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!