[MySQL] Database -- MySQL installation

This tutorial mainly explains how to compile and install MySQL 5.6.14 under CentOS 6.5!

1. Uninstall the old version:

Use the following command to check if MySQL server is installed

[sql]  view plain  copy
 
  1. <span style="font-family:'Microsoft YaHei';font-size:16px;">[root@localhost ~]# rpm -qa | grep mysql  
  2. mysql-libs-5.1.73-7.el6.x86_64</span>  

Uninstall it if any using the command below

[sql]  view plain  copy
 
  1. <span style="font-family:'Microsoft YaHei';font-size:16px;">rpm -e --nodeps mysql_libs</span>  

2. Install MySQL:

[cpp]  view plain  copy
 
  1. <span style= "font-family:'Microsoft YaHei';font-size:16px;">Install the packages needed to compile the code  
  2. yum -y install make gcc-c++www.006665.cn   cmake bison-devel ncurses-devel  
  3. Unzip the MySQL package  
  4. tar -zxvf mysql-5.6.14.tar.gz  
  5. cd mysql-5.6.14  
  6. Compile and install  
  7. cmake -DCMAKE_INSTALL_PREFIX=/usr/local /www.wanmeiyuele.cn mysql -DMYSQL_DATADIR=/usr/local/mysql/data -  
  8. DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1-DWITH_INNOBASE_STORAGE_ENGINE=1-  
  9. DWITH_MEMORY_STORAGE_ENGINE=1-DWITH_READLINE=1-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -  
  10. DMYSQL_TCP_www.baohuayule.com  PORT=3306-DENABLED_LOCAL_INFILE=1-DWITH_PARTITION_STORAGE_ENGINE=1-  
  11. DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci  
  12. compile and install  
  13. make && make install</span>  

The process is a little long, please be patient. . .

3. Configure MySQL:

Create MySQL groups and accounts

[sql]  view plain  copy
 
  1. <span style="font-family:'Microsoft YaHei';font-size:16px;">groupadd mysql  
  2. useradd -g mysql mysql</span>  

edit permission:

[sql]  view plain  copy
 
  1. <span style="font-family:'Microsoft YaHei';font-size:16px;">chown -R mysql:mysql /usr/local/mysql</span>  

Initialize the configuration, enter the installation path (execute the following instructions), execute the initialization configuration script, and create the database and tables that come with the system

[sql]  view plain  copy
 
  1. <span style="font-family:'Microsoft YaHei';font-size:16px;">cd /usr/local/mysql  
  2. scripts/mysql_install_db --basedir=/www.leyou1178.cn usr/local/mysql--datadir=/usr/local/mysql/data --user=mysql</span>  

We will use the configuration file /usr/local/mysql/my.cnf in the future. In order to prevent interference, we will rename my.cnf under etc.

[sql]  view plain  copy
 
  1. <span style="font-family:'Microsoft YaHei';font-size:16px;">mv /etc/my.cnf /etc/my.cnf.bak</span>  

4. Start MySQL

Add a service, copy the service script to the init.d directory, and set it to start on boot

[sql]  view plain  copy
 
  1. <span style= "font-family:'Microsoft YaHei';font-size:16px;"> Execute under /usr/local/mysql  
  2. cp support-files/mysql.server /etc/init.d/mysql  
  3. chkconfig mysql on  
  4. service mysql start --start  MySQL</span>  

start mysql client

[sql]  view plain  copy
 
  1. <span style="font-family:'Microsoft YaHei';font-size:16px;">cd /usr/local/mysql/bin  
  2. ./mysql -uroot -p www.baohuayule.cn </span>  

The entire MySQL configuration is completed, I wish you a happy use~

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324688547&siteId=291194637