Home  >  Article  >  Database  >  编译完mysql后实现自启动

编译完mysql后实现自启动

WBOY
WBOYOriginal
2016-06-07 15:39:391005browse

二:编译安装配置mysql ###################安装cmake################### 若想编译安装mysql必须借助跨平台编译器cmake。 [root@yong ~]# yum -y install cmake ###################解压缩mysql################# [root@yong ~]# tar xf mysql-5.5.33.tar.g

二:编译安装配置mysql

###################安装cmake################### 
若想编译安装mysql必须借助跨平台编译器cmake。 
[root@yong ~]# yum -y install cmake 
###################解压缩mysql################# 
[root@yong ~]# tar xf mysql-5.5.33.tar.gz 
###################创建程序运行用户############ 
[root@yong ~]# groupadd -r mysql 
[root@yong ~]# useradd -g mysql -r mysql 
###################创建数据存放目录############ 
建议:真实环境下尽量使用逻辑卷存放数据!! 
[root@yong ~]# mkdir -pv /mydata/data 
[root@yong ~]# chown -R mysql.mysql /mydata/data 
###################编译mysql###################

编译选项了解参考:http://www.linuxidc.com/Linux/2013-09/90349.htm

[root@yong ~]# cd mysql-5.5.33 
[root@yong mysql-5.5.33]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mydata/data -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci 
####################安装mysql################ 
[root@yong mysql-5.5.33]# make && make install 
####################更改属组################# 
[root@yong ~]# cd /usr/local/mysql/ 
[root@yong mysql]# chown -R :mysql * 
###################初始化数据库############## 
[root@yong mysql]# scripts/mysql_install_db --user=mysql --datadir=/mydata/data/ 
###################创建配置文件############## 
[root@yong mysql]# cp support-files/my-large.cnf /etc/my.cnf 
###################编辑配置文件############## 
[root@yong mysql]# cd /etc/ 
[root@yong etc]# vim my.cnf 
datadir = /mydata/data                  #指定mysql数据文件的存放位置 
###################创建执行脚本############## 
[root@yong mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld 
[root@yong mysql]# chmod +x /etc/rc.d/init.d/mysqld    #执行权限 
##################添加服务################## 
[root@yong mysql]# chkconfig --add mysqld 
#################启动服务################### 
[root@yong mysql]# service mysqld start 
#################设置环境变量############### 
[root@yong mysql]# vim /etc/profile.d/mysql.sh 
export PATH=/usr/local/mysql/bin:$PATH              #添加 
[root@yong mysql]# . /etc/profile.d/mysql.sh 
################创建登录密码############### 
[root@yong mysql]# mysqladmin -u root password mypass 
[root@yong mysql]# mysql -uroot –pmypass 
###############指定访问权限################ 
mysql> grant all privileges on *.* to root@'172.16.%.%' identified by 'mypass'; 
mysql> flush privileges;            重读授权表

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn