Installation environment: CentOS7 64-bit MINI version Official source code compilation and installation document: http://dev.mysql.com/doc/refman/5.7/en/source-installation.html 1. System Installation Conditions Official documentation: http://dev.mysql.com/doc/refman/5.7/en/source-installation.html 1>cmake MySQL uses the cmake cross-platform tool to precompile source code, which is used to set the compilation parameters of MySQL. Such as: installation directory, data storage directory, character encoding, sorting rules, etc. Just install the latest version. 2> make3.75 The MySQL source code is written in C and C++. Use make to compile and build the source code under Linux. You must install make 3.75 or above. 3> gcc4.4.6 GCC is a C language compiler under Linux. MySQL source code compilation is completely written in C and C++. It is required to install GCC4.4.6 or above. 4> Boost1.59.0 The MySQL source code uses the C++ Boost library, which requires that you install boost 1.59.0 or later. 5> bison2.1 C/C++ parser for Linux 6> ncurses Character terminal processing library So before installation, you need to install the relevant dependent libraries: shell> sudo yum install -y cmake,make,gcc,gcc-c++,bison, ncurses,ncurses-devel Download the Boost 1.59.0 source code and unzip it to the /usr/local/ directory: shell> wget -O https://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz shell> tar -zxvf boost_1_59_0.tar.gz -C /usr/local/ 2. Download MySQL source code Download the mysql source code from github shell> cd /opt shell> git clone https://github.com/mysql/mysql-server.git shell> ls mysql-server If the git client is not installed, run yum install -y git to install it. shell> git branch -r origin/5.5 origin/5.6 origin/5.7 origin/HEAD -> origin/5.7 origin/cluster-7.2 origin/cluster-7.3 origin/cluster-7.4 origin/cluster-7.5 The current branch defaults to version 5.7. If you want to install other versions, just switch to the corresponding branch. For example, if you want to install version 5.6: git checkout 5.6. Here we take the installation of version 5.7 as an example. Sohu mirror download address: 3. Installation 1> Add mysql user shell> cd /opt/mysql-server shell> groupadd mysql #Add mysql user group shell> useradd -r -g mysql -s /bin/false mysql #Add mysql user 2> Configure mysql precompilation parameters 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 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 `grep processor /proc/cpuinfo | wc -l` shell> make install The -j parameter specifies the number of threads during compilation based on the number of CPU cores, which can speed up compilation. The default is 1 thread compilation. After testing, on a single-core CPU and 1G of memory, it takes nearly 1 hour to compile. 4> Initialize the system database shell> cd /usr/local/mysql shell> chown -R mysql:mysql . # Note: For versions prior to MySQL 5.7.6, execute this script to initialize the system database shell> ./bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data # Initial system database script for versions after 5.7.6 (this article uses this method to initialize) shell> ./bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data shell> ./bin/mysql_ssl_rsa_setup shell> chown -R root . shell> chown -R mysql data Note: If you use the --initialize parameter to initialize the system database, a temporary password for the root user will be generated in the ~/.mysql_secret file and printed out in the initialization log, as shown in the red circle in the following figure: 5. Configuration file and parameter optimization shell> cp support-files/my-default.cnf /etc/my.cnf shell> vim /etc/my.cnf [client] port=3306 socket=/usr/local/mysql/mysql.sock [mysqld] character-set-server=utf8 collation-server=utf8_general_ci skip-external-locking skip-name-resolve user=mysql port=3306 basedir=/usr/local/mysql datadir=/usr/local/mysql/data tmpdir=/usr/local/mysql/temp # server_id = ..... socket=/usr/local/mysql/mysql.sock log-error=/usr/local/mysql/logs/mysql_error.log pid-file=/usr/local/mysql/mysql.pid open_files_limit=10240 back_log=600 max_connections=500 max_connect_errors=6000 wait_timeout=605800 #open_tables=600 #table_cache = 650 #opened_tables = 630 max_allowed_packet=32M sort_buffer_size=4M join_buffer_size=4M thread_cache_size=300 query_cache_type=1 query_cache_size=256M query_cache_limit=2M query_cache_min_res_unit=16k tmp_table_size=256M max_heap_table_size=256M key_buffer_size=256M read_buffer_size=1M read_rnd_buffer_size=16M bulk_insert_buffer_size=64M lower_case_table_names=1 default-storage-engine=INNODB innodb_buffer_pool_size=2G innodb_log_buffer_size=32M innodb_log_file_size=128M innodb_flush_method=O_DIRECT ##################### thread_concurrency=32 long_query_time=2 slow-query-log=on slow-query-log-file=/usr/local/mysql/logs/mysql-slow.log [mysqldump] quick max_allowed_packet=32M [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid 6. Configure MySQL service shell> cp support-files/mysql.server /etc/init.d/mysqld shell> chkconfig --add mysqld # Add to system services shell> chkconfig mysqld on # Start at boot 7. Start the 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 variables shell> vim /etc/profile shell> export PATH=/usr/local/mysql/bin:$PATH shell> source /etc/profile 4. Other matters needing attention If the compilation fails midway, you need to delete the cache file of the pre-compilation configuration parameters generated by cmake and the file generated after make compilation, and then recompile. shell> cd /opt/mysql-server shell> rm -f CMakeCache.txt shell> make clean The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Example of using Dockerfile to build an nginx image
>>: jQuery realizes the shuttle box effect
Table of contents Precautions Necessary condition...
Table of contents When setting up a MySQL master-...
animation Define an animation: /*Set a keyframe t...
I'll record the problems I encountered during...
Preface In web applications, in order to save tra...
recommend: Navicat for MySQL 15 Registration and ...
Preface: I heard a long time ago that MySQL 8.0 s...
Table of contents MySQL Truncate usage 1. Truncat...
Table of contents 10,000 pieces of data were lost...
//grammar: @media mediatype and | not | only (med...
1. What are the formats of lines? You can see you...
Achieve resultsRequirements/Functionality: How to...
Performance For example: HTML: <div class=&quo...
When using XAML layout, sometimes in order to make...
Written in front Often, after we install Nginx ba...