Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

CentOS6.9 system compilation and installation MySQL5.7.16 tutorial

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the CentOS6.9 system compilation and installation MySQL5.7.16 tutorial, which involves things, learned from the theoretical knowledge, there are many books, literature for your reference, from a practical point of view, accumulated years of practical experience can be shared with you.

CentOS6.9 compilation and installation of MySQL5.7.16

Deployment environment:

System CentOS6.9,mysql5.7.16,boost library

The system has 2GB of memory

1. Install the dependency package. Install cmake,6.9 using yum. The default yum is derived from the

Yum-y install gcc-c++ cmake bison-devel ncurses-devel

2. The user who created the mysql:

Useradd-U-s / sbin/nologin mysql

3. Create the necessary folders and modify their directory user owners:

Mkdir-pv / usr/local/mysql/etc

Mkdir-pv / data/ {boost/boost_1_59_0,mysql/ {data,log}}

Chown-R mysql:mysql / usr/local/mysql/

Chown-R mysql:mysql / data/mysql/

4. Copy the boots library to the boost directory

Cp / tmp/boost/boost_1_59_0/* / data/boost/boost_1_59_0

Chown-R mysql:mysql / data/boost/

5. Compile and install mysql5.7

Cd / tmp

Tar xf mysql-5.7.16.tar.gz

Cd mysql-5.7.16

Cmake\

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql\

-DMYSQL_DATADIR=/data/mysql/data\

-DSYSCONFDIR=/usr/local/mysql/etc\

-DWITH_MYISAM_STORAGE_ENGINE=1\

-DWITH_INNOBASE_STORAGE_ENGINE=1\

-DWITH_MEMORY_STORAGE_ENGINE=1\

-DWITH_READLINE=1\

-DMYSQL_UNIX_ADDR=/data/mysql/log/mysql.sock\

-DMYSQL_TCP_PORT=3306\

-DENABLED_LOCAL_INFILE=1\

-DWITH_PARTITION_STORAGE_ENGINE=1\

-DEXTRA_CHARSETS=all\

-DDEFAULT_CHARSET=utf8\

-DDEFAULT_COLLATION=utf8_general_ci\

-DWITH_BOOST=/data/boost/boost_1_59_0

Make & & make install

It takes a long time

Chown-R mysql:mysql / usr/local/mysql

6. Configuration file my.cnf

[client]

Port = 3306

Socket = / data/mysql/log/mysql.sock

[mysql]

Default-character-set = utf8

[mysqld]

# file

Datadir = / data/mysql/data

Basedir = / usr/local/mysql

Pid-file = / data/mysql/log/mysqld.pid

Log_error = / data/mysql/log/mysql.err

Port = 3306

Socket=/data/mysql/mysql.sock

User=mysql

Character_set_server = utf8

Character_set_server = utf8

Slow_query_log = 1

Slow_query_log_file = / data/mysql/log/slowq.log

Long_query_time = 1

Log-bin=/data/mysql/log/mysql-bin.log

# temp

Max_tmp_tables = 64

Tmp_table_size = 512m

Slave_load_tmpdir = / data/mysql/log

Tmpdir = / data/mysql/log

# session

Back_log = 512

Skip-name-resolve

Max_allowed_packet = 32m

Max_connections = 16000

Max_connect_errors = 10000

Wait_timeout = 28800

Table_open_cache = 216,

Thread_cache_size = 128,

Query_cache_type = 0

Query_cache_size = 0

Key_buffer_size = 128m

Myisam_sort_buffer_size = 16m

Read_buffer_size = 16m

Read_rnd_buffer_size = 16m

Sort_buffer_size = 16m

Join_buffer_size = 16m

# innodb

Default_storage_engine = InnoDB

Innodb_data_home_dir = / data/mysql/data

Innodb_data_file_path = ibdata1:256M:autoextend

Innodb_log_group_home_dir = / data/mysql/log

Innodb_log_files_in_group = 4

Innodb_log_file_size = 256m

Innodb_log_buffer_size = 8m

Innodb_flush_log_at_trx_commit = 2

Innodb_flush_method = O_DIRECT

Innodb_lock_wait_timeout = 50

# innodb_thread_concurrency = 24 16

Innodb_buffer_pool_size = 1G

Innodb_io_capacity = 1500

Innodb_use_native_aio = 1

Innodb_file_per_table = 1

Innodb_open_files = 3000

# others

Memlock = 1

Performance_schema = 0

# replication

Server-id = 150

Binlog_format = row

Expire_logs_days = 7

Relay_log = / data/mysql/log/relay-bin

# replicate_ignore_db = mysql

# slave_skip_errors = 1062

Log_slave_updates = 1

Skip-slave-start

Read_only = 0

Sync_binlog = 1

[mysqldump]

Default-character-set = utf8

[mysqld-5.7]

Innodb_buffer_pool_dump_pct = 40

Innodb_undo_log_truncate = 1

Innodb_undo_tablespaces = 3

Innodb_max_undo_log_size = 1G

Innodb_purge_rseg_truncate_frequency = 128,

Binlog_gtid_simple_recovery=1

Log_timestamps=system

Show_compatibility_56=on

Sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'

7. Initialize the database

The version used mysql_install_db before 5.7.6.

Mysqld used after version 5.7.6-- initialize

# official website tagging # #

Shell > bin/mysql_install_db-- user=mysql # MySQL 5.7.5

Shell > bin/mysqld-- initialize-- user=mysql # MySQL 5.7.6 and up

Shell > bin/mysql_ssl_rsa_setup # MySQL 5.7.6 and up

# official website tagging # #

/ usr/local/mysql/bin/mysqld-initialize-user=mysql-datadir=/data/mysql/data-basedir=/usr/local/mysql

There may be an error that there is not enough memory. Just adjust the buffer size by yourself.

/ usr/local/mysql/bin/mysql_ssl_rsa_setup

Did not print the log, the temporary password can not be used, had to crack, there is a way.

8. Start the database

Vim / usr/local/mysql/support-files/mysql.server

Plus absolute path

Basedir=/usr/local/mysql

Datadir=/data/mysql/data

Cp / usr/local/mysql/support-files/mysql.server / etc/init.d/mysqld

Service mysqld start

9. Configure environment variables

Vim / etc/profile

Export PATH=/usr/local/mysql/bin:$PATH

Source / etc/profile

10. Check the mysql temporary password. I don't need this item. It doesn't work. I cracked it directly.

Cat / root/.mysql_secret

Mysql-uroot-p`cat / root/.mysql_ secret`

If you can get in, basically that's it, and you can use it normally.

* * unable to log in normally, unable to log in with a temporary password * *

11. Crack the password

Mysqld_safe-defaults-file=/usr/local/mysql/etc/my.cnf-skip-grant-tables-skip-networking&

Update mysql.user set authentication_string=password ('123456') where user='root'

Find the process number and kill the mysql process

Ps aux | grep mysql

Kill-9 pid

Service mysqld start

11.2. Log in to mysql

Mysql-u root-p 'password'

Prompt to change the password:

Mysql > alter user root@localhost identified by '123456'

Read the above CentOS6.9 system compilation and installation MySQL5.7.16 tutorial introduction, hoping to give you some help in practical application. Due to the limited space in this article, there will inevitably be deficiencies and areas that need to be supplemented. You can continue to pay attention to the industry information section and will update your industry news and knowledge regularly. If you need more professional answers, you can contact us on the official website for 24-hour pre-sales and after-sales to help you answer questions at any time.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report