centos、suse源码安装mysql5.7

Only good-looking people will see!!!

下载mysql5.7源码包:
https://pan.baidu.com/s/15Zd6HfMGN6k1REehpZnqzg
提取码:80v0

基础环境:(suse: #zypper install libaio)

#yum install libaio

mysql专用用户组和用户:

#groupadd mysql
#useradd -r mysql -g mysql -s /bin/false

解压mysql源码包

 #tar -xzvf  mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz

使用常用安装目录

#mv mysql-5.7.16-linux-glibc2.5-x86_64 /usr/local/mysql

安装:

#cd /usr/local/mysql
# mkdir mysql-files
# chown -R  mysql.mysql  /usr/local/mysql
# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data  (注意这步会出现初始密码,记得复制保留;如果出现错误,删除本地data再次执行一次)
# bin/mysql_ssl_rsa_setup --datadir=/usr/local/mysql/data
# chown -R root . (有个点,表示当前目录)
# chown -R mysql data mysql-files
手动添加配置文件:
建立MySQL配置文件my.cnf(如果有,请备份)

# vim /etc/my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
log-error=/var/log/mysql/mysql_error.log

#mkdir /var/log/mysql
#chmod -R 755  /var/log/mysql 
安装完成配置启动mysql:

#cp support-files/mysql.server /etc/init.d/mysqld (也可以support-files/mysql.server  start 启动)
chmod +x   /etc/init.d/mysqld
# chkconfig --add mysqld
# chkconfig mysqld on
# service mysqld start  (若要设置开机启动:将该命令添加在到/etc/rc.local或/etc/rc.d/rc.local)
Starting MySQL.Logging to '/usr/local/mysql/data/mysql2.err'.
SUCCESS! (成功)
如果报错:mysql is neither service nor target!?
执行:systemctl unmask mysql.service
     service mysql start
(如何增加一个开机启动服务:
1.服务脚本必须存放在/etc/ini.d/目录下;
2.chkconfig --add 脚本名字
    在chkconfig工具服务列表中增加此服务,此时服务会被在/etc/rc.d/rcN.d中赋予K/S入口了;
3.chkconfig  mysqld  on
    修改服务的默认启动等级。
4.将启动命令添加在到/etc/rc.local或/etc/rc.d/rc.loca)

进入mysql

# bin/mysql -uroot -p'之前复制的密码'
改密码:
mysql> set password=password('YEyin@127');  
(5.7要求密码必须复杂些)

优化进入mysql

#vim /etc/profile
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin/
export PATH

#source /etc/profile
这样在哪个目录下都可以:
#mysql -uroot -p

mysq配置``模板:
cat /etc/my.cnf

log_bin=mysql-bin           #打开binlog日志
enforce_gtid_consistency=ON #打开gtid
gtid_mode=ON                #打开gtid 开启gtid复制
log-slave-updates=1         #允许从库变为主库
expire_logs_days=5 binglog  #日志存在时间
server-id=1000101           #
relay-log=mysqld-relay-bin #中继日志文件名
report-host=172.17.199.20 
report-port=3306
slow_query_log=on #慢查询日志打开
slow-query-log-file=slow_query.txt #慢查询日志指定位置
long_query_time=1 #慢查询超时时间
innodb_lock_wait_timeout=600 #innodb事务锁超时时间
innodb_buffer_pool_size=20G #缓冲池大小设置为内存的80%,这个大了可以减少数据库相同数据io的次数,保护磁盘和数据库
character-set-server=utf8
innodb_open_files=65535
max_connections=2048
slave-parallel-workers=4 sql 线程转变为control线程,并行复制,提高效率

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值