Binary Compilation and Installation of MySql centos7 under Linux

  • 2021-06-28 14:33:49
  • OfStack

//At that time, I was faking this for an afternoon, so I took a note and wrote it down.

//If there are any questions, we can discuss them together (qq: 2970911340, Mailbox)+@qq.com), which is my first blogging practice

1. An cmake Tool

# yum install -y cmake

2. Create mysql users

#useradd -s /sbin/nologin mysql  //设置为非登陆用户(安全)

3. Create a data directory, which is used for libraries, tables, logs, etc. generated during database initialization. Do not store things directly in this directory


# mkdir -p /mysql/data   // The directory name is arbitrary (it should be set later), but the remaining space in the partition where the directory is located cannot be less than 1g (Not very clear) 
# chown mysql.mysql /mysql/ -R  //  Set the directory's owner group to mysql

4. Install development packages needed for compilation, etc.


# yum install ncurses-devel openssl-devel gcc* -y

5. Unzip the mysql2 binary package and compile it


# cd /packet   //cd  reach   Under the directory where the package is stored 
# tar xvf mysql-5.6.22.tar.gz
# cd  mysql-5.6.22
// Start compiling directly, note: 1 Be sure to enter the decompressed mysql Editing in the bag   Then?  cmake  meet 1 Bulk parameters   Yes 1 Some can be omitted 
#cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mysql/data -DDEFAULT_CHARSET=utf8 -DEXTRA_CHARSETS=all -DDEFAULT_COLLATION=utf8_general_ci -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_SSL=bundled
// -DCMAKE_INSTALL_PREFIX=/usr/local/mysql // Specify installation directory 
//-DMYSQL_DATADIR=/mysql/data  // Specify the data directory, the one created above 
// Others are omitted. 

6. Error Resolution (1 Generally speaking, above is not an error)


 # rm -rf CMakeCache.txt 
// When compilation errors occur  1 Be sure to delete first  CMakeCache.txt  Recompile, this file will be automatically generated when compiled a bit like   "Accounting books   "Record compiled 1 Some information. 

// Error Daquan Temporarily 1 Update later. 

7. Installation


# make -j 4  // -j 4  Use 4 Kernel compilation because it takes a long time to compile so give it a few more u
# make install

8. Initialization


 # yum install -y perl-Data-Dumper   // Will prompt to install this 
 # /usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/mysql/data/ --basedir=/usr/local/mysql
// After initialization, you can  /mysql/data/  See the generated base libraries, logs, etc. in the directory 
 
 //  inside  client21.err ( host name .err) Will record  mysql Service Start   restart   Log on Close , You can view this log if there is a problem with startup 
# tail -50 /mysql/data/client21.err

9. Start Configuration, Start


# cp /usr/local/mysql/mysql-test/include/default_my.cnf /etc/my.cnf  // This file is mysql Configuration files for services 
# cat > /etc/my.cnf  // Delete everything else or you will have problems later , You can also add it yourself 1 Some options in 
# /usr/local/mysql/bin/mysqld_safe --user=mysql & // Put in Background Start , No  '&' The current terminal will be obsolete , You can try it 

//Of course there may be a headache in the middle, followed by time to follow the new one...

eg: Check your ideas for tips, address of error logs, and where to start

1. Is selinux closed//setenforce 0 temporarily closed

2. Is initialization normal

3. Is the data path'datadir'in the cp/etc/my.cf configuration file correct

10. Define the command as a system command (you can ignore this step)


 # vim /etc/profile.d/mysql.sh
   export PATH=/usr/local/mysql/bin:$PATH  // Just add this 1 Line is OK 
# source /etc/profile.d/mysql.sh

11. Set up startup


# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
# chkconfig --add mysqld *  // take mysqld add to chkconfig Managed startup 
# chkconfig --list | grep mysqld  * // See mysqld Start on or off at each runlevel 
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off

And once set up, it can be controlled directly with systemctl restart | start mysqld, (stop is no longer used, I don't know what to do first with'pkill mysqld')

12. Native Test Access, download mysql client (not service) locally


# yum install -y mysql      // This is what you put on mariadb Client , Experience will be better than mine mysql good 1 spot   In fact, they are all 1 Sample 
# mysql     // Direct Entry  , test 1 Is there a problem below 

//If you can read and write the instructions correctly, very good!

summary


Related articles: