CentOS6.5系统搭建mysql服务器

环境:CentOS 6.5 x86_64-minimal

1 安装编译mysql的包

yum remove mysql-server mysql -y

yum -y install gcc gcc-c++ ncurses-devel zlib-devel bison cmake openssl-devel perl

2 创建mysql用户和目录

useradd mysql

mkdir -p /usr/local/mysql

mkdir -p /db/mysql/data


3 编译安装mysql

cd ~

wget -c http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.10.tar.gz

tar -xzvf mysql-5.6.10.tar.gz

cd mysql-5.6.10

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/db/mysql/data -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306

make && make install


4 配置MYSQL

 修改mysql目录的权限

chown -R mysql:mysql /usr/local/mysql/

chown -R mysql:mysql /db/mysql/data/

 初始化mysql

\cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf

cd /usr/local/mysql

scripts/mysql_install_db --user=mysql --datadir=/db/mysql/data

添加环境变量

cd ~

echo "PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:\$PATH" >> /etc/profile

echo "export PATH" >> /etc/profile

source /etc/profile


设置MYSQL开机启动

\cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

chkconfig --add mysqld

chkconfig mysqld on

启动mysql

service mysqld start

设置mysql密码

mysqladmin -u root password ‘123456‘


导入开发的库文件

# ln -sv /usr/local/mysql/include/ /usr/include/mysql #软连接到系统库中
# vim /etc/ld.so.conf.d/mysql.conf #编辑这个文件, 并且添加如下路径
 
/usr/local/mysql-5.5.40/lib
 
# ldconfig #重新加载库文件
# ldconfig -p | grep mysql #让我们来检查下是不是加载好了
    libmysqlclient_r.so.16 (libc6,x86-64) => /usr/lib64/mysql/libmysqlclient_r.so.16
    libmysqlclient.so.18 (libc6,x86-64) => /usr/local/mysql-5.5.40/lib/libmysqlclient.so.18
    libmysqlclient.so.16 (libc6,x86-64) => /usr/lib64/mysql/libmysqlclient.so.16
    libmysqlclient.so (libc6,x86-64) => /usr/local/mysql-5.5.40/lib/libmysqlclient.so

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。