源码编译安装mysql-5.7.14
1.下载并上传 mysql-5.7.14.tar.gz
tar -zxf msql-5.7.14.tar.gz
2.安装依赖包
yum -y install gcc gcc-c++ ncurses ncurses-devel cmake
3.下载Boost库
wget http://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz
4.添加用户
groupadd mysql useradd -r -g mysql -s /bin/false mysql
5.预编译
cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.7.14 -DMYSQL_DATADIR=/application/mysql-5.7.14/data -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/software/boost_1_59_0 -DMYSQL_UNIX_ADDR=/application/mysql-5.7.14/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_LOCAL_INFILE=ON -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 -DWITHOUT_PARTITION_STORAGE_ENGINE=1 -DWITH_FAST_MUTEXES=1 -DWITH_ZLIB=bundled -DENABLED_LOCAL_INFILE=1 -DWITH_READLINE=1 -DWITH_EMBEDDED_SERVER=1 -DWITH_DEBUG=0
6.编译安装
make make install
7.修改 /etc/my.cnf
[mysqld] datadir=/application/mysql/data socket=/application/mysql/tmp/mysql.sock user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 character_set_server=utf8
8.修改权限
chown -R mysql:mysql mysql-5.7.14/
9.建立数据库目录
mkdir data chown mysql:mysql data
10.初始化
bin/mysqld --initialize --user=mysql --basedir=/application/mysql --datadir=/application/mysql/data
11.设置加密连接
bin/mysql_ssl_rsa_setup
12.加入系统服务
cp support-files/mysql.server /etc/init.d/mysqld 修改 mysqld 文件里的 basedir datadir 属性 chkconfig mysqld on # 设置开机自启动 chkconfig --list | grep mysqld
13.启动 重启 停止
service mysqld start service mysqld restart service mysqld stop
14.登录并修改初始密码
SET PASSWORD FOR "root"@"localhost"=PASSWORD("newpassword");
安装中遇到的问题
Starting MySQL... ERROR! The server quit without updating PID file (/application/mysql/Rong.pid).1.查看错误日志 /var/log/mysqld.log 检查错误原因
[ERROR] Fatal error: Can"t open and lock privilege tables: Table "mysql.user" doesn"t exist
2.原因:在进行初始化数据库权限表的时候默认创建的权限表在默认目录/usr/local/mysql/var下面,而实际是在 /application/mysql/data 3.通过需改 /etc/my.cnf 下 --datadir参数来解决问题
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。
- 上一篇: mysql编译安装优化
- 下一篇: 编写mysql插件