Performance optimization of mysql source installation

1. Download the two source files mysql-5.5.24.tar.gz and cmake-2.8.4.tar.gz
2. Install cmake first
tar -zxv -f cmake-2.8.4.tar.gz
cd cmake-2.8.4
./configure
make
make install

3. Create the mysql installer directory and data file directory
mkdir -p /usr/local/mysql //install mysql path
mkdir -p /usr/local/mysql/data //Store the database

4. Create user and mysql user group
groupadd mysql
useradd -r -g mysql mysql

5. Unzip the mysql source code and install the mysql source code with cmake
tar -zxv -f mysql-5.5.24.tar.gz
cd mysql-5.5.24.tar.gz
cmake
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_DATADIR=/usr/local/mysql/data
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DEXTRA_CHARSETS=all
-DENABLED_LOCAL_INFILE=1
-DWITH_ARCHIVE_STOREAGE_ENGINE=1
-DWITH_BLACKHOLE_STOREAGE_ENGINE=1
-DWITH_EXAMPLE_STOREAGE_ENGINE=1
-DWITH_FEDERATED_STOREAGE_ENGINE=1
-DWITH_PARTITION_STOREAGE_ENGINE=1
make
make install

Parameter list meaning
Parameter description:
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql //Installation directory
-DINSTALL_DATADIR=/usr/local/mysql/data //Database storage directory
-DDEFAULT_CHARSET=utf8 //Use utf8 characters
-DDEFAULT_COLLATION=utf8_general_ci //check character
-DEXTRA_CHARSETS=all //Install all extended character sets
-DENABLED_LOCAL_INFILE=1 //Allow data to be imported from local

When recompiling, old object files and cache information need to be cleared.
make clean
rm -f CMakeCache.txt
rm -rf /etc/my.cnf

6. Set directory permissions
cd /usr/local/mysql
chown -R root:mysql . //Set the owner of all files in the current directory to root and the group to mysql
chown -R mysql:mysql data

7. Create the my.cnf file and initialize the database
[root@localhost mysql]#cp support-files/my-medium.cnf /etc/my.cnf //Add the mysql startup service to the system service
[root@ rhel5 mysql]#./scripts/mysql_install_db  --user=mysql

8. Set environment variables
[root@ localhost mysql]#cd ~
[root@ localhost  mysql]#vi .bash_profile
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib
[root@ localhost mysql]source /root./bash_profile

9. Start mysql
[root@ localhostl]#cd /usr/local/mysql/
[root@localhost mysql]#./bin/mysql_safe --user=mysql & //Start MySQL, but can't stop the startup log in /usr/local/mysql/data/localhost.err
//Close the MySQL service
[root@localhost mysql]# mysqladmin -u root -p shutdown //The root user of MySQL has not yet configured a password, so it is empty. When you need to enter a password, just hit the Enter key.

So far, mysql has been successfully installed.

Next , we will add the startup of mysql to the services of the system,
such as operating mysql startup and shutdown.
service mysql.server start  
service mysql.server stop
service mysql.server restart
//There is a service not recognized by mysql.server, maybe mysql has not been added to the system service
 cp support-files/mysql.server /etc/init.d/mysql //Add the mysql startup service to the system service

Note: The main thing is to copy mysql.server to /etc/init.d and name it mysql. In some systems, mysql.server is in /usr/local/mysql/share/mysql/mysql.server, while in this system, mysql.server is in /usr/local/mysql/support-files/mysql.server .
Then use #service mysql start to start mysql.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326643273&siteId=291194637