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
Autotrash is a command line program that automate...
There are two solutions: One is CSS, using backgro...
I have been playing around with charts for a whil...
To understand what this means, we must first know ...
Preface Every time I use the terminal to create a...
MySQL is a relational database management system....
In the previous article, we used Docker to build ...
Bugs As shown in the figure, I started to copy th...
Table of contents Introduction Architecture Advan...
1. Problem Description For security reasons, the ...
In web page production, displaying and hiding ele...
1. Prepare the Docker environment 2. Search for f...
Mysql 8.0 installation problems and password rese...
Ideas: An outer box sets the background; an inner...
RocketMQ is a distributed, queue-based messaging ...