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

Mysql5.7 source code installation

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Install dependency packages

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

Download the appropriate source package

Cd / root/oneinstack/src

Wget http://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz

Wget http://cdn.mysql.com/Downloads/MySQL-5.7/mysql-5.7.11.tar.gz

Add mysql user

Useradd-M-s / sbin/nologin mysql

Pre-compilation

Tar xzf boost_1_59_0.tar.gz

Tar xzf mysql-5.7.11.tar.gz

Mkdir-p / data/mysql

Cd mysql-5.7.11

Cmake. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql\

-DMYSQL_DATADIR=/data/mysql\

-DDOWNLOAD_BOOST=1\ # the Boost library is required since MySQL 5.7.5

-DWITH_BOOST=../boost_1_59_0\

-DSYSCONFDIR=/etc\

-DWITH_INNOBASE_STORAGE_ENGINE=1\

-DWITH_PARTITION_STORAGE_ENGINE=1\

-DWITH_FEDERATED_STORAGE_ENGINE=1\

-DWITH_BLACKHOLE_STORAGE_ENGINE=1\

-DWITH_MYISAM_STORAGE_ENGINE=1\

-DENABLED_LOCAL_INFILE=1\

-DENABLE_DTRACE=0\

-DDEFAULT_CHARSET=utf8mb4\

-DDEFAULT_COLLATION=utf8mb4_general_ci\

-DWITH_EMBEDDED_SERVER=1

Cmake. -DCMAKE_INSTALL_PREFIX=/srv/mysql5713\

-DMYSQL_DATADIR=/srv/mysql5713/data\

-DMYSQL_UNIX_ADDR=/srv/mysql5713/tmp/mysql.sock\

-DDEFAULT_CHARSET=utf8\

-DDEFAULT_COLLATION=utf8_general_ci\

-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii\

-DENABLED_LOCAL_INFILE=ON\

-DWITH_INNOBASE_STORAGE_ENGINE=1\

-DWITH_FEDERATER_STORAGE_ENGINE=1\

-DWITH_BLACKHOLE_STORAGE_ENGINE=1\

-DWITH_EXAMPLE_STORAGE_ENGINE=1\

-DWITH_PARTITION_STORAGE_ENGINE=1\

-DWITH_FAST_MUTEXES=1\

-DWITH_ZLIB=bundled\

-DENABLED_LOCAL_INFILE=1\

-DWITH_READLINE=1\

-DWITH_EMBEDDED_SERVER=1\

-DWITH_DEBUG=0\

-DWITH_BOOST=/srv/mysql/boost_1_59_0

Compilation and installation

Make

Make install

Startup script, setting boot self-startup

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

Chmod + x / etc/init.d/mysqld

Chkconfig-add mysqld

Chkconfig mysqld on

/ etc/my.cnf, for reference only

Vim / etc/my.cnf

[client]

Port = 3306

Socket = / tmp/mysql.sock

Default-character-set = utf8mb4

[mysqld]

Port = 3306

Socket = / tmp/mysql.sock

Basedir = / usr/local/mysql

Datadir = / data/mysql

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

User = mysql

Bind-address = 0.0.0.0

Server-id = 1

Init-connect = 'SET NAMES utf8mb4'

Character-set-server = utf8mb4

# skip-name-resolve

# skip-networking

Back_log = 300

Max_connections = 1000

Max_connect_errors = 6000

Open_files_limit = 65535

Table_open_cache = 128,

Max_allowed_packet = 4m

Binlog_cache_size = 1m

Max_heap_table_size = 8m

Tmp_table_size = 16m

Read_buffer_size = 2m

Read_rnd_buffer_size = 8m

Sort_buffer_size = 8m

Join_buffer_size = 8m

Key_buffer_size = 4m

Thread_cache_size = 8

Query_cache_type = 1

Query_cache_size = 8m

Query_cache_limit = 2m

Ft_min_word_len = 4

Log_bin = mysql-bin

Binlog_format = mixed

Expire_logs_days = 30

Log_error = / data/mysql/mysql-error.log

Slow_query_log = 1

Long_query_time = 1

Slow_query_log_file = / data/mysql/mysql-slow.log

Performance_schema = 0

Explicit_defaults_for_timestamp

# lower_case_table_names = 1

Skip-external-locking

Default_storage_engine = InnoDB

# default-storage-engine = MyISAM

Innodb_file_per_table = 1

Innodb_open_files = 500,

Innodb_buffer_pool_size = 64m

Innodb_write_io_threads = 4

Innodb_read_io_threads = 4

Innodb_thread_concurrency = 0

Innodb_purge_threads = 1

Innodb_flush_log_at_trx_commit = 2

Innodb_log_buffer_size = 2m

Innodb_log_file_size = 32m

Innodb_log_files_in_group = 3

Innodb_max_dirty_pages_pct = 90

Innodb_lock_wait_timeout = 120

Bulk_insert_buffer_size = 8m

Myisam_sort_buffer_size = 8m

Myisam_max_sort_file_size = 10G

Myisam_repair_threads = 1

Interactive_timeout = 28800

Wait_timeout = 28800

[mysqldump]

Quick

Max_allowed_packet = 16m

[myisamchk]

Key_buffer_size = 8m

Sort_buffer_size = 8m

Read_buffer = 4m

Write_buffer = 4m

EOF

Initialize the database

The previous version of mysql_install_db is under mysql_basedir/script, 5.7under the mysql_install_db/bin directory, and has been abandoned

"--initialize" generates a random password (~ / .mysql_secret), while "--initialize-insecure" does not generate a password.

-- data files cannot be found in the datadir target directory

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

Start the database

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

Service mysql start

Chkconfig mysql on

Set database password

Dbrootpwd=oneinstack # Database root password

/ usr/local/mysql/bin/mysql-e "grant all privileges on *. * to root@'127.0.0.1' identified by\" $dbrootpwd\ "with grant option;"

/ usr/local/mysql/bin/mysql-e "grant all privileges on *. * to root@'localhost' identified by\" $dbrootpwd\ "with grant option;"

There is no Password field in the user table under the new version of mysql database, but the encrypted user password is stored in the authentication_string field.

Install 1 > add mysql user shell > cd / opt/mysql-servershell > groupadd mysql # add mysql user group shell > useradd-r-g mysql-s / bin/false mysql # add mysql user 2 > configure mysql precompilation parameter shell > cmake. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql\-DMYSQL_DATADIR=/usr/local/mysql/data\-DWITH_BOOST=/usr/local/boost_1_59_0\-DSYSCONFDIR=/etc\-DEFAULT_CHARSET=utf8mb4\-DDEFAULT_COLLATION=utf8mb4_general_ci\-DENABLED_LOCAL_INFILE=1\-DEXTRA_CHARSETS=all

-DCMAKE_INSTALL_PREFIX: installation path

-DMYSQL_DATADIR: data storage directory

-DWITH_BOOST:boost source code path

-DSYSCONFDIR:my.cnf configuration file directory

-DEFAULT_CHARSET: database default character encoding

-DDEFAULT_COLLATION: default collation

-DENABLED_LOCAL_INFILE: allow data to be imported from this file

-DEXTRA_CHARSETS: install all character sets

For more precompiled configuration parameters, please refer to the official mysql documentation: http://dev.mysql.com/doc/refman/5.7/en/source-configuration-options.html#cmake-general-options

3 > compile and install shell > make-j `shell / proc/cpuinfo | wc-l`shell > make install

The-j parameter specifies the number of threads at compile time based on the number of CPU cores, which can speed up compilation. The default is 1 thread compilation. After testing the memory of single-core CPU,1G, it takes nearly 1 hour to compile.

4 > initialize system database shell > cd / usr/local/mysqlshell > chown-R mysql:mysql. # Note: versions prior to MySQL 5.7.6 execute this script to initialize system database shell >. / bin/mysql_install_db-- user=mysql-- basedir=/usr/local/mysql-- datadir=/usr/local/mysql/data# version after 5.7.6 version of the initial system database script (initialized in this article) shell >. / bin/mysqld-- initialize-insecure-- user=mysql-- basedir=/usr/local/mysql-- datadir=/usr/local/mysql/datashell >. / bin/mysql_ssl_rsa_setupshell > chown-R root .shell > chown-R mysql data

5. Set configuration file shell > cp support-files/my-default.cnf / etc/my.cnf6, configure mysql service shell > cp support-files/mysql.server / etc/init.d/mysqldshell > chkconfig-- add mysqld # add to system service shell > chkconfig mysqld on # boot 7, start service shell > service mysqld start # start mysql service shell > service mysqld stop # stop mysql service shell > service mysqld restart # restart mysql service 8, Set the database password shell > / usr/local/mysql/bin/mysql-e "grant all privileges on *. * to root@'127.0.0.1' identified by" root "with grant option "shell > / usr/local/mysql/bin/mysql-e" grant all privileges on *. * to root@'localhost' identified by "root" with grant option; "# enable remote login (set host to%) / usr/local/mysql/bin/mysql-e" grant all privileges on *. * to root@'%' identified by "root" with grant option; "9, configure mysql environment variable shell > vim / etc/profileshell > export PATH=/usr/local/mysql/bin:$PATHshell > source / etc/profile other considerations

If the compilation fails, you need to delete the cache file of the precompiled configuration parameters generated by cmake and the file generated after make compilation, and then recompile.

Shell > cd / opt/mysql-servershell > rm-f CMakeCache.txtshell > make clean

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