centos下源码编译安装MySQL

时间:2022-02-07 21:45:15

解压下载的软件压缩包  tar xzvf mysql-5.1.63.tar.gz

进入解压的目录  cd mysql-5.1.63/

安装需要的依赖包  yum install gcc gcc-c++ ncurses-devel -y

配置安装路径 ./configure --prefix=/usr/local/mysql --enable-shared --enable-assembler

编译 安装 make && make install

对数据库目录进行权限设置  chown -R mysql.mysql /usr/local/mysql

建立配置文件   cp share/mysql/my-medium.cnf /etc/my.cnf

初始化数据库 /usr/local/mysql/bin/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql/

添加为系统服务  cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld

        chkconfig --add mysqld

        chkconfig --level 35 mysqld on

启动MySQL服务  service mysql start

进入mysql 数据库 /usr/local/mysql/bin/mysql