centos编译安装mysql

groupadd mysql #添加mysql组
useradd -g mysql -s /sbin/nologin mysql #创建用户mysql并加入到mysql组,不允许mysql用户直接登录系统
mkdir -p /data/mysql #创建MySQL数据库存放目录
chown -R mysql:mysql /data/mysql #设置权限

tar -zxf mysql-5.6.30.tar.gz
cd mysql-5.6.30
cmake . -DCMAKE_INSTALL_PREFIX=/web/mysql -DMYSQL_DATADIR=/web/mysql/data -DWITH_INNODB_MEMCACHED=ON
make&&make install                                #(红色这里可以直接复制成shell脚本安装)

cd /web/mysql
初始化
./scripts/mysql_install_db --user=mysql #生成mysql系统数据库

加入自启动
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld #把Mysql加入系统启动
chkconfig mysqld on #加入开机启动

装完MySQL修改my.cnf
mv /etc/my.cnf /etc/my.cnf.bak    #(mysql默认先读/etc/my.cnf,所以改下名字,不用这个文件)
使用mysql安装路径下的my.cnf
datadir=/data/mysql     #(数据库路径)  

添加环境变量  /etc/profile  末行  source /etc/profile生效
PATH=/web/mysql/bin:$PATH
export PATH

service mysqld start
此时输入MySQL可直接进入
不进入mysql
mysqladmin -u root -p password ’123’ 设置密码

进入MySQL
update user set password='' where user='root';  修改密码  ’’为空是空密码。。 ’123’ 为密码是123

service mysqld restart #重启

备注: cmake 编译mysql 时报错

CMake Error at cmake/readline.cmake:85 (MESSAGE):
  Curses library not found.  Please install appropriate package,

      remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and

derivates it is ncurses-devel.
Call Stack (most recent call first):
  cmake/readline.cmake:128 (FIND_CURSES)
  cmake/readline.cmake:202 (MYSQL_USE_BUNDLED_EDITLINE)
  CMakeLists.txt:409 (MYSQL_CHECK_EDITLINE)

-- Configuring incomplete, errors occurred!

该报错原因是未安装ncurses-devel,安装

#yum -y install ncurses-devel
 
删除CMakeCache.txt
 
locate  CMakeCache.txt                          #使用locate时 报错,执行命令updatedb
# rm -rf /usr/local/src/cmake-2.8.8/Tests/Complex/Cache/CMakeCache.txt
# rm -rf /usr/local/src/cmake-2.8.8/Tests/ComplexOneConfig/Cache/CMakeCache.txt
# rm -rf /usr/local/src/cmake-2.8.8/Tests/ComplexRelativePaths/Cache/CMakeCache.txt
# rm -rf /usr/local/src/mysql-5.6.25/CMakeCache.txt
 
然后重新编译
上一篇:RTSP协议转换RTMP直播协议


下一篇:h5直播开发之旅总结