mysql5.7源码安装

1. 下载源码安装包(tar包)

http://dev.mysql.com/downloads/mysql/5.7.html#downloads 
mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

2. 检查库文件是否存在,如有则删除。(没有可以忽略这一步)
[root@cherry ~]# rpm -qa | grep mysql
mysql-libs-5.1.71-1.el6.x86_64
 
附:
#  停止服务
/etc/init.d/mysqld stop
#  停止并删除开机启动
chkconfig mysqld off
chkconfig --del mysqld
 
[root@cherry ~]# rpm -e mysql-libs-5.1.71-1.el6.x86_64 –nodeps   //-nodeps删除依赖包
[root@cherry ~]# rpm -qa | grep mysql
[root@cherry ~]#whereis mysql
[root@cherry ~]#find / -name mysql
[root@cherry ~]#rm –rf  (mysql文件目录)
#  删除MySQL目录
rm -rf /usr/local/mysql
rm -f /etc/my.cnf
rm -f /etc/init.d/mysqld
rm -f /root/.mysql_secret
#  删除用户和用户组
userdel -r mysql
 
3. 检查mysql组和用户是否存在,如无创建。
[root@cherry ~]# cat /etc/group | grep mysql
[root@cherry ~]# cat /etc/passwd | grep mysql
 
// useradd -r参数表示mysql用户是系统用户,不可用于登录系统。
[root@cherry ~]# groupadd mysql
[root@cherry ~]# useradd -r -g mysql mysql
4. 解压TAR包,更改所属的组和用户
[root@cherry zkpk]# cd /usr/local/
[root@cherry local]# tar -xf mysql-5.7.14-linux-glibc2.5-x86_64.tar.gz 
[root@cherry local]# mv mysql-5.7.14-linux-glibc2.5-x86_64 mysql
[root@cherry local]# ll
[root@cherry local]# rm mysql-5.7.14-linux-glibc2.5-x86_64.tar.gz rm: remove regular file `mysql-5.7.14-linux-glibc2.5-x86_64.tar.gz'? y 
[root@cherry local]# chown -R mysql:mysql mysql/
[root@cherry local]# cd mysql/
5. 安装和初始化数据库

配置OS

sudo vim /etc/security/limits.conf
mysql hard nofile 65535
mysql soft nofile 65535

安装与初始化DB

[root@cherry mysql]# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/

017-03-28T02:43:47.866001Z0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use--explicit_defaults_for_timestamp server option (see documentation for moredetails).

2017-03-28T02:43:48.202955Z0 [Warning] InnoDB: New log files created, LSN=45790

2017-03-28T02:43:48.259895Z0 [Warning] InnoDB: Creating foreign key constraint system tables.

2017-03-28T02:43:48.571472Z0 [Warning] No existing UUID has been found, so we assume that this is thefirst time that this server has been started. Generating a new UUID:5ec2fc90-1360-11e7-b088-a4badb3ee178.

2017-03-28T02:43:48.572194Z0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed'cannot be opened.

2017-03-28T02:43:48.574027Z1 [Note] A temporarypassword is generated for root@localhost: -;!E6Xa?eq1K     //初始密码

 

如果改变默认安装路径,则需要 
1. /etc/my.cnf
、/etc/init.d/mysqld中修改: 
basedir=’/apps/mysql’ datadir=’/apps/mysql/data’ 
2. 创建ln: 
mkdir -p /usr/local/mysql/bin

 

[root@cherry mysql]# cp -a ./support-files/my-default.cnf /etc/my.cnf
[root@cherry mysql]# cp -a ./support-files/mysql.server  /etc/init.d/mysqld
[root@cherry mysql]# cd bin/
[root@cherry bin]# ./mysqld_safe --user=mysql &     //产生mysql.socklocaldomain.err
[1] 2966
[root@cherry bin]# 2016-08-19T17:24:36.174662Z mysqld_safe Logging to '/usr/local/mysql/data/cherry.err'.
2016-08-19T17:24:36.207209Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
 
[root@cherry bin]# 

[root@cherry bin]# /etc/init.d/mysqld restart

Shutting down MySQL..2016-08-19T17:25:18.416810Z mysqld_safe mysqld from pid file /usr/local/mysql/data/cherry.pid ended [ OK ] Starting MySQL. [ OK ] [1]+ Done ./mysqld_safe--user=mysql

[root@cherry bin]#

 

设置开机启动

[root@cherry bin]# chkconfig --level 35 mysqld on
6. 初始化密码
[root@cherry bin]# cat /root/.mysql_secret 
# Password setfor user 'root@localhost' at 2016-08-2001:18:44
eqW;ehX;>-YG
[root@cherry bin]# ./mysql -uroot -p
Enter password: 
mysql> SET PASSWORD = PASSWORD('123456');
mysql> flush privileges;    
[root@ cherry bin]# ./mysqladmin –uroot –p password
 
7. 添加远程访问权限
mysql> use mysql; 
mysql> update user set host = '%' where user = 'root';
mysql> select host, user from user;
+-----------+-----------+
| host      | user      |
+-----------+-----------+
| %         | root      |
| localhost | mysql.sys |
+-----------+-----------+
//重启生效
/etc/init.d/mysqld restart
[root@cherry mysql]# vim /etc/my.cnf 
[mysqld]
character-set-server=utf8 //重启生效 
/etc/init.d/mysqld restart
9. linux下mysql配置文件my.cnf详解

http://www.cnblogs.com/captain_jack/archive/2010/10/12/1848496.html   


10添加系统路径(环境变量)
# vim /etc/profile
添加:
export PATH=/usr/local/mysql/bin:$PATH

 

11配置mysql自动启动
# chmod755 /etc/init.d/mysql
# chkconfig --add mysql
# chkconfig --level 345 mysql on

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值