Required software: mysql-5.1.34.tar.tar
Execute before compilation: CFLAGS="-O3 -m64" CXX=gcc CXXFLAGS="-O3 -m64 -felide-constructors -fno-exceptions -fno-rtti" (Note: If it is an Inter processor, improve performance by 1%)
Compilation parameters: ./configure --prefix=/usr/local/mysql/ --enable-thread-safe-client --with-server-suffix= - -with-extra-charsets=none --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --with-plugins=max --disable-shared --without-debug - -enable-assembler
Compilation parameter description:
--enable-thread-safe-client //Compile the client in thread mode
--with-server-suffix= //Add a suffix name to MySQL and log in with mysql You can see it after the version number (I don’t know how to use it)
--with-extra-charsets=none //Character set related, setting it to none should also improve performance
--with-client-ldflags= -all-static--with-mysqld-ldflags=-all-static //Static compile mysql client and server (performance can be improved by 5-10%)
--with-plugins=max //Add support for innodb and partition Support
--disable-shared //Close shared libraries
--without-debug //Remove debug mode (performance can be improved)
--enable-assembler //Allow assembly mode to improve performance
#Then proceed according to the number of CPUs Compile
make –j4
make install
#Add user
groupadd mysql && useradd -g mysql mysql
#Create directory
mkdir /usr/local/mysql/data && mkdir /usr/local/mysql/run && mkdir /usr/ local/mysql/log && mkdir /usr/local/mysql/var
#Change the owner of the mysql directory. After the operation, you can view the permissions of /usr/local/mysql through ls -l
Chgrp mysql -R /usr/local/mysql
chown mysql -R /usr/local/mysql
#Add PATH (to use the mysql command anytime, anywhere)
echo "PATH="/usr/local/mysql/bin:$PATH"" >> /etc/ profile && export PATH="/usr/local/mysql/bin:$PATH"
#strip executable file (I don’t know what this is for)
strip /usr/local/mysql/libexec/mysqld
# Add LIB PATH (this is included when compiling the server application layer code)
echo "/usr/local/mysql/lib" >> /etc/ld.so.conf && ldconfig
#cp the my.cnf file Go to the /etc directory
cp ./support-files/my-huge.cnf /etc/my.cnf
#Comment out skip-federated in /etc/my.cnf (this is for other unnecessary troubles)
#Modify my.cnf (in the [mysqld] group)
datadir=/db/mysql
#Create a database storage path (the benefit of having the data directory independent is also to improve performance)
mkdir /db
chown mysql:mysql /db –R
#Initialize the Mysql table (initialize the table as mysql, otherwise the mysql server cannot be started)
su - mysql -c "mysql_install_db"
#Start mysql
/usr/local/mysql/bin/mysqld_safe &
#If not If an error is reported, mysql is already running, check whether mysql is running
Ps –aux| grep mysql
#Copy the mysql startup script to /sbin for the convenience of future startup (purely my personal preference)
Cp /mysql package directory/support-files/ mysql.server /sbin/
Chmod +x /sbin/mysql.server (you can use mysql.server start /stop in the future)
At this point, mysql has been installed.
The above is the summary of MYSQL learning (1): the content of MYSQL installation. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!