mysql5.7安装配置
2024-06-28 16:01:03
供稿:网友
通过源码在linux上安装MySQL最新稳定版本:mysql-5.7.17为了方便安装过程中不受boost依赖的影响,直接从官网下载mysql-boost-5.7.17.tar.gz版本。(官方解释,编译过程中需要boost,但实际没有用到。)安装目录:启动脚本:/etc/init.d/mysqld程序根目录:/usr/local/mysql数据目录:/data/mysql安装过程1.安装依赖#yum install -y cmake gcc-c++* make ncurses-devel2.创建mysql用户#groupadd mysql#useradd -r -g mysql -s /bin/false mysql3.下载mysql-boost-5.7.17.tar.gz,上传到服务器#tar xzf mysql-5.7.17.tar.gz #cd mysql-5.7.17#mkdir bld#cd bld/#cmake .. -DWITH_BOOST=../boost/ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql #在此指定参数后减少很多后面启动过程中的操作#make#make install使用默认的配置文件#cd /usr/local/mysql/support-files#cp my-default.cnf ../my.cnf编译过程中出错,清除临时文件重新编译:#make clean#rm CMakeCache.txt4.安装完后把可执行文件路径加到系统环境变量:环境变量#echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile#source /etc/profile5.初始化数据库#mkdir /data/mysql#chown -R mysql.mysql /data/mysql#mysqld --defaults-file=/usr/local/mysql/my.cnf --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/mysql/mysql5.7初始化后会随机生成一个密码,会直接打到屏幕上。6.启动复制启动脚本:#cd /usr/local/mysql/support-files#cp mysql.server /etc/init.d/mysql直接启动#mysqld_safe --user=mysql &或#/etc/init.d/mysqld start启动后调用安全脚本,实现:更改root密码,删除测试库,禁止root远程登录#mysql_secure_installation 部分配置(没有优化的)[client]port=3306socket=/tmp/mysql.sockcharacter_set_client= utf8[mysqld]basedir = /usr/local/mysqldatadir = /data/mysqlport = 3306socket = /tmp/mysql.sockcharacter-set-server = utf8read_buffer_size=131072#innodbinnodb_data_file_path=ibdata1:100M:autoextend#binlogserver_id=1log-bin=mysql-binsql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES[mysqldump]quickmax_allowed_packet=32M[mysql][myisamchk]