千家信息网

源码编译安装mysql-5.7.14

发表于:2024-11-23 作者:千家信息网编辑
千家信息网最后更新 2024年11月23日,1.下载并上传 mysql-5.7.14.tar.gz view plain copytar -zxf msql-5.7.14.tar.gz2.安装依赖包 view plain copyyum -y
千家信息网最后更新 2024年11月23日源码编译安装mysql-5.7.14

1.下载并上传 mysql-5.7.14.tar.gz view plain copy

  1. tar -zxf msql-5.7.14.tar.gz


2.安装依赖包 view plain copy

  1. yum -y install gcc gcc-c++ ncurses ncurses-devel cmake


3.下载Boost库 view plain copy

  1. wget http://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz


4.添加用户 view plain copy

  1. groupadd mysql

  2. useradd -r -g mysql -s /bin/false mysql


5.预编译 view plain copy

  1. cmake . \

  2. -DCMAKE_INSTALL_PREFIX=/application/mysql-5.7.14 \

  3. -DMYSQL_DATADIR=/application/mysql-5.7.14/data \

  4. -DDOWNLOAD_BOOST=1 \

  5. -DWITH_BOOST=/software/boost_1_59_0 \

  6. -DMYSQL_UNIX_ADDR=/application/mysql-5.7.14/tmp/mysql.sock \

  7. -DDEFAULT_CHARSET=utf8 \

  8. -DDEFAULT_COLLATION=utf8_general_ci \

  9. -DENABLED_LOCAL_INFILE=ON \

  10. -DWITH_INNOBASE_STORAGE_ENGINE=1 \

  11. -DWITH_FEDERATED_STORAGE_ENGINE=1 \

  12. -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \

  13. -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \

  14. -DWITHOUT_PARTITION_STORAGE_ENGINE=1 \

  15. -DWITH_FAST_MUTEXES=1 \

  16. -DWITH_ZLIB=bundled \

  17. -DENABLED_LOCAL_INFILE=1 \

  18. -DWITH_READLINE=1 \

  19. -DWITH_EMBEDDED_SERVER=1 \

  20. -DWITH_DEBUG=0

6.编译安装view plain copy

  1. make

  2. make install

7.修改 /etc/my.cnf view plain copy

  1. [mysqld]

  2. datadir=/application/mysql/data

  3. socket=/application/mysql/tmp/mysql.sock

  4. user=mysql

  5. # Disabling symbolic-links is recommended to prevent assorted security risks

  6. symbolic-links=0

  7. character_set_server=utf8

8.修改权限 view plain copy

  1. chown -R mysql:mysql mysql-5.7.14/


9.建立数据库目录 view plain copy

  1. mkdir data

  2. chown mysql:mysql data

10.初始化view plain copy

  1. bin/mysqld --initialize --user=mysql --basedir=/application/mysql --datadir=/application/mysql/data

11.设置加密连接 view plain copy

  1. bin/mysql_ssl_rsa_setup


12.加入系统服务view plain copy

  1. cp support-files/mysql.server /etc/init.d/mysqld

  2. 修改 mysqld 文件里的 basedir datadir 属性

  3. chkconfig mysqld on # 设置开机自启动

  4. chkconfig --list | grep mysqld

13.启动 重启 停止 view plain copy

  1. service mysqld start

  2. service mysqld restart

  3. service mysqld stop


14.登录并修改初始密码 copy

  1. SET PASSWORD FOR 'root'@'localhost'=PASSWORD('newpassword');


安装中遇到的问题 view pcopy

  1. Starting MySQL... ERROR! The server quit without updating PID file (/application/mysql/Rong.pid).

1.查看错误日志 /var/log/mysqld.log 检查错误原因 view plain copy

  1. [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参数来解决问题


0