I. Preparations
The first is file preparation. ke, because I didn't use the FTP environment to store tool files, I used xftp to copy and paste MySQL's common binary format files, whether it is mobile storage mounting or other, the purpose is to put this stuff into the Linux server. The used local file is “mysql-5.5.33-linux2.6-x86_64.tar.gz. You can download the file from www.mysql.com or other image websites.
650) This. width = 650; "style =" background-image: none; border-right-0px; margin: 0px; padding-left: 0px; padding-Right: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201407/29/2784219_1406599850iQis.png "width =" 1026 "Height =" 577 "/>
Ii. Start Configuration
1. set a data storage path for MySQL. It is best to mount the data, which facilitates the expansion of the data in the later stage. If you are too lazy to mount the data, I directly created/mydata/MySQL/data in the root directory and created the System user MySQL;
Set the owner and group of/mydata/MySQL/data to MySQL:
# mkdir -p /mydata/mysql/data# useradd -r mysql# chown -R mysql.mysql /mydata/mysql/data
After the operation is completed, check whether the operation is correct. Marco will often remind us to perform this operation;
Check ing:
650) This. width = 650; "style =" background-image: none; border-right-0px; margin: 0px; padding-left: 0px; padding-Right: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201407/29/2784219_1406599850G77U.png "width =" 450 "Height =" 105 "/>
2. decompress the file to usr/local;
# Tar xf mysql-5.5.33-linux2.6-x86_64.tar.gz-C/usr/local/* parameter-C specifies the decompression path */
After decompression, check whether port 3306 is occupied. If it is occupied, close it;
650) This. width = 650; "style =" background-image: none; border-right-0px; margin: 0px; padding-left: 0px; padding-Right: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201407/29/2784219_1406599850tbhL.png "width =" 566 "Height =" 183 "/>
Usually, MySQL programs are stored in the/usr/local/MySQL directory. However, we do not recommend you change the file name here. Just create a file name link;
# Ln-SV mysql-5.5.33-linux2.6-x86_64/MySQL/* Create File Link */
650) this.width=650;" style="background-image: none; border-right- 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://img1.51cto.com/attachment/201407/29/2784219_1406599851TAjS.png" width="712" height="120" />
3. Modify the file owner and group
Note: The data owner and group in MySQL must be mysql. The owner and group of other files are root and MySQL. Because we have another data file path, therefore, the owner and group of/usr/local/MySQL are changed to root and MySQL;
650) This. width = 650; "style =" background-image: none; border-right-0px; margin: 0px; padding-left: 0px; padding-Right: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201407/29/2784219_1406599851jlIG.png "width =" 438 "Height =" 281 "/>
# Chown-r root. MySQL/usr/local/MySQL/* change owner and group */
After modification, check that the owner and group of files in the MySQL directory are changed. Do not change the owner and group of MySQL;
650) This. width = 650; "style =" background-image: none; border-right-0px; padding-left: 0px; padding-Right: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201407/29/2784219_1406599911CuUT.png "width =" 450 "Height =" 279 "/>
4. copy the my-large.cnf under support-files to/etc and change the file name to my. CNF, by viewing my-huge.cnf, my-large.cnf, my-medium.cnf, my-small.cnf files compare Linux server memory size select the corresponding file;
# cp my-large.cnf /etc/my.cnf
Here, you will be prompted whether to overwrite data. Note that backup files need to be used in the production environment for similar modification, deletion, and overwrite operations to facilitate timely recovery in case of problems;
650) This. width = 650; "style =" background-image: none; border-right-0px; margin: 0px; padding-left: 0px; padding-Right: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201407/29/2784219_1406599911uxZQ.png "width =" 427 "Height =" 38 "/>
Then modify the/etc/My. CNF file, and add the red part after the following content to complete the modification.
# Try Number of CPU's * 2 for thread_concurrency
Thread_concurrency = 8/* Number of concurrent threads, which is twice the number of physical cores or the same as the number of physical cores */
Datadir =/mydata/MySQL/Data
Copy mysql. Server under support-files to/etc/rc. d/init. d/, change the file name to mysqld, and add mysqld to the service list;
# Cp/usr/local/MySQL/support-files/MySQL. server/etc/rc. d/init. d/mysqld # chkconfig -- add mysqld/* Add mysqld to the service list */
View
# chkconfig --list mysqld
5. Then run the service,
# service mysqld star
650) This. width = 650; "style =" background-image: none; border-right-0px; margin: 0px; padding-left: 0px; padding-Right: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201407/29/2784219_1406599912hIg2.png "width =" 813 "Height =" 54 "/>
An error is reported because the configuration file/usr/local/MySQL/data/localhost. localdomain. PID is not updated.
Check the path. The PID file is not found in it,
650) This. width = 650; "style =" background-image: none; border-right-0px; margin: 0px; padding-left: 0px; padding-Right: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201407/29/2784219_1406599912fIit.png "width =" 345 "Height =" 39 "/>
Here we can see the error log localhost. localdomain. Err, which tells us that various tables do not exist, so it cannot be started. In this case, we need to manually initialize them once;
First, clear the/usr/local/MySQL/data/directory,
# rm -rf /usr/local/mysql/data/*
Then run the initialization script file, file path/usr/local/MySQL/scripts/mysql_install_db
#/Usr/local/MySQL/scripts/mysql_install_db -- help/* View Script help */
Here we need to use parameters
-- User = Specify the MySQL user name
-- Datadir specifies the data directory
# Scripts/mysql_install_db -- user = MySQL -- datadir =/mydata/MySQL/data/* initialization */
Prompt successful
650) This. width = 650; "style =" background-image: none; border-right-0px; margin: 0px; padding-left: 0px; padding-Right: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201407/29/2784219_1406599913L21n.png "width =" 641 "Height =" 523 "/>
After initialization, you can see that a new file has been generated under/mydata/MySQL/data,
650) This. width = 650; "style =" background-image: none; border-right-0px; margin: 0px; padding-left: 0px; padding-Right: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201407/29/2784219_1406599913oXTL.png "width =" 610 "Height =" 44 "/>
Start the MySQL service again!
650) This. width = 650; "style =" background-image: none; border-right-0px; margin: 0px; padding-left: 0px; padding-Right: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201407/29/2784219_1406599913NpMr.png "width =" 321 "Height =" 55 "/>
In this case, you can check that port 3306 is listened on, indicating that MySQL is successfully started;
650) This. width = 650; "style =" background-image: none; border-right-0px; margin: 0px; padding-left: 0px; padding-Right: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201407/29/2784219_1406599914Pf6Z.png "width =" 768 "Height =" 195 "/>
6. When the client is connected, a prompt is displayed because the PATH environment variable is not set,
650) This. width = 650; "style =" background-image: none; border-right-0px; margin: 0px; padding-left: 0px; padding-Right: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201407/29/2784219_1406599914RMFn.png "width =" 249 "Height =" 40 "/>
Let's set it up,
# vim /etc/profile.d/mysql.sh
Edit the following content and save it:
export PATH=/usr/local/mysql/bin:$PATH
Execute the script once and try to connect to the client!
650) This. width = 650; "style =" background-image: none; border-right-0px; margin: 0px; padding-left: 0px; padding-Right: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201407/29/2784219_1406599914RrSM.png "width =" 563 "Height =" 248 "/>