This article describes how to install mysql5.7.16 from source code in centos7 environment. Share with you for your reference, the details are as follows: 1. Download the source package Download mysql source package http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.16.tar.gz 2. Installation Agreement: Username: mysql 3. Installation Preparation 1. Add users > useradd -s /sbin/nologin mysql 2. Create a directory > mkdir /data/mysql 3. Change the directory owner and owner > chown -R mysql:mysql /data/mysql 4. Install the files required for editing > yum install gcc gcc-c++ cmake bison-devel ncurses-devel libaio libaio-devel (*MySQL 5.7.5 and above versions require boost to be installed) > yum install boost boost-devel 5. Unzip the source package > tar -xf mysql-5.7.16.tar.gz 4. Compile and install > cd /data/mysql-5.7.16 >cmake \ -DMYSQL_USER=mysql \ -DCMAKE_INSTALL_PREFIX=/data/mysql \ -DMYSQL_DATADIR=/data/mysql/data \ -DSYSCONFDIR=/data/mysql \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DINSTALL_PLUGINDIR=/data/mysql/plugin \ -DWITH_READLINE=1 \ -DMYSQL_UNIX_ADDR=/data/mysql/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 \ -DDOWNLOAD_BOOST=1 \ -DWITH_BOOST=/usr/local/boost (*Note, if an error occurs, delete CMakeCache.txt and re-run the configuration) The explanation of the above parameters is as follows: #mysql username -DMYSQL_USER=mysql #Installation path -DCMAKE_INSTALL_PREFIX=/data/mysql #Data file storage location -DMYSQL_DATADIR=/data/mysql/data #my.cnf path -DSYSCONFDIR=/data/mysql #Support MyIASM engine - DWITH_MYISAM_STORAGE_ENGINE=1 #Support InnoDB engine - DWITH_INNOBASE_STORAGE_ENGINE=1 #Support Memory Engine - DWITH_MEMORY_STORAGE_ENGINE=1 #Plugin file and configuration path-DINSTALL_PLUGINDIR=/data/mysql/plugin #Shortcut key function (I haven't used it) -DWITH_READLINE=1 #Connect to the database socket path -DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock #Port - DMYSQL_TCP_PORT=3306 #Allow importing data from local - DENABLED_LOCAL_INFILE=1 #Install support for database partitioning - DWITH_PARTITION_STORAGE_ENGINE=1 #Install all character sets -DEXTRA_CHARSETS=all #Default character - DDEFAULT_CHARSET=utf8 #Check character -DDEFAULT_COLLATION=utf8_general_ci # will automatically download boost -DDOWNLOAD_BOOST=1 #Specify the boost directory -DWITH_BOOST=/usr/local/boost Compile and install > make && make install Copy the configuration file > cp /data/mysql/support-files/my-default.cnf /data/mysql/my.cnf Initialize the database > /data/mysql/bin/mysqld \ --defaults-file=/data/mysql/my.cnf \ --initialize \ --user=mysql \ --basedir=/data/mysql \ --datadir=/data/mysql/data \ If the following message appears:
Please make sure that If the following message appears:
Please ensure that your datadir directory is empty and delete any files if they exist. The MySQL 5.7 version will randomly generate a root password when installed with --initialize, so be sure to save it. If you want to generate an empty password, use the Change the owner of the mysql directory > chown -R mysql:mysql /data/mysql 5. Configure the MySQL configuration file my.cnf Since we set the configuration file directory of MySQL to /data/mysql when compiling and installing it, delete /etc/my.cnf . So as not to be affected. > rm -rf /etc/my.cnf > vi /data/mysql/my.cnf The configuration is as follows: [client] default-character-set = utf8 port = 3306 socket = /data/mysql/mysql.sock [mysql] default-character-set = utf8 [mysqld] skip-name-resolve basedir = /data/mysql datadir = /data/mysql/data port = 3306 server_id = 10 socket = /data/mysql/mysql.sock character-set-server = utf8 max_connections = 200 default-storage-engine = INNODB log-bin=mysql-bin Add startup for mysql > cp /data/mysql/support-files/mysql.server /etc/init.d/mysqld > chmod 755 /etc/init.d/mysqld > chkconfig --add mysqld Start mysql service > service mysqld start Add environment variables for mysql > echo "export PATH=/data/mysql/bin/:$PATH" >> /etc/profile > source /etc/profile Log in to mysql with the password saved above to change the root password >mysql -uroot -p > set password=password('123456'); > alter user 'root'@'localhost' password expire never; > flush privileges; Readers who are interested in more MySQL-related content can check out the following topics on this site: "MySQL query skills", "MySQL common functions summary", "MySQL log operation skills", "MySQL transaction operation skills summary", "MySQL stored procedure skills" and "MySQL database lock related skills summary" I hope this article will be helpful to everyone's MySQL database design. You may also be interested in:
|
<<: Share MySql8.0.19 installation pit record
>>: An article to understand the use of proxies in JavaScript
I have previously written an article about recurs...
In a complex table structure, some cells span mul...
There are many tags and elements in the HTML head ...
Description: Set a timer to replace the content of...
Sometimes we save a lot of duplicate data in the ...
Table of contents 1. How to create an array in Ja...
Table of contents Written in front Environment de...
closure service nginx stop systemctl stop nginx s...
1. Still use PHP script to execute. Command line ...
1. MYSQL index Index: A data structure that helps...
js array is probably familiar to everyone, becaus...
This article uses examples to illustrate the comm...
1. Advantages and Disadvantages of Indexes Advant...
Table of contents 1. Usage 1. Basic usage 2. The ...
Related reading: Solve the problem that the servi...