Compile and install Mysql:
1. Create a data directory. (Default is in the mysql installation directory)
1. Create the directory /mydata/data
[Note: Any directory created under the mysql data directory will be recognized as a database]
2 .Create an independent partition /dev/sdaX (based on the actual situation, it is recommended to use LVM logical volume)
3. Mount the newly created partition to /mydata
4. Edit the automatic mounting at boot
vim /etc/fstab
Add something like The following lines:
Device Mount point File system defaults 0 0
2. Create user: User used by Mysql to run
1. groupadd -g 3306 mysql
2. useradd -u 3306 -g mysql -M -s /sbin/nologin mysql
Three. Give the mysql user all permissions to the data directory
chown -R mysql:mysql /mydata
Four. Decompress and configure Mysql
1.tar xf mysql-5.5.15-linux2.6-i686.tar.gz -C / usr/local
2.cd /usr/local
3.ln -sv mysql-5.5.15-linux2.6-i686 mysql
4.cd mysql
5.chown -R mysql:mysql .
Initialize Mysql:
6 .scripts/mysql_install_db --user=mysql --datadir=/mydata/data
7.chown -R root .
5. Configure service startup:
Prepare startup script:
8.cp support-files/mysql.server /etc /init.d/mysqld
Join the service queue
9.chkconfig --add mysqld
Set up automatic startup at boot
10.chkconfig mysqld on
Copy the configuration file:
11.cp support-files/my-large.cnf /etc/ my.cnf
12.vim /etc/my.cnf
Add the following content under the [mysqld] field
datadir = /mydata/data
Change thread_concurrency = 8 to thread_concurrency = 2
Start the service:
13.service mysqld start
[Note: If startup fails, please check the files ending with ".err" in the "data directory"]
6. Prepare header files, library files, and PATH variables (not necessary, but files that depend on mysql will be found in the default directory Related files)
#Library file:
vim /etc/ld.so.conf.d/mysql.conf
Add:/usr/local/mysql/lib --> Save and exit
ldconfig (-v Display execution results)
#Header file:
ln -sv /usr/local/mysql/include /usr/include/mysql
#PATH
vim /etc/profile
Add: PATH=$PATH:/usr/local/mysql/bin ( It is recommended to add it above the "export" line)
source /etc/profile
#MAN (It doesn’t matter if you don’t want to configure it)
vim /etc/man.config
Add: MANPATH /usr/local/mysql/man