centos 6.8安装mysql-5.7.24

 

一、centos 6 安装mysql5.7.24

1、卸载linux自带的mysql

[root@localhost /]# rpm -qa | grep mysql 查看old mysql
[root@localhost /]# rpm -e --nodeps mysql-libs-5.1.52.x86_64 卸载mysql
删除相关目录
whereis mysql 或者
find / -name mysql (厉害)

2、下载tar包并解压

 tar  -zxvf  mysql-5.7.24-linux。。。

 mv  /usr/local/mysql-5.7.24...    /usr/local/mysql  重命名

 在mysql根目录下新建data文件夹

3、修改配置文件

  cd mysql/support-files
  cp mysql.server /etc/init.d/mysql
  vim /etc/init.d/mysql

basedir=/usr/local/mysql
datadir=/usr/local/mysql/data

   cd /etc

   vim my.cnf    (替换成如下) 

[client]
port=3306
default-character-set=utf8

[mysqld]
port=3306
character-set-server=utf8
default_storage_engine=InnoDB
datadir = /usr/local/mysql-5.7.24/data
log-error = /usr/local/mysql-5.7.24/data/error.log
pid-file=/usr/local/mysql-5.7.24/data/mysql.pid
user=root
tmpdir=/tmp
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

4、初始化

./mysqld --initialize --user=用户 --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

或者(这个未测试)
在mysql目录下的scripts目录中
./mysql_install_db --user=用户--basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/mysql.pid --tmpdir=/tmp

  执行完毕后会自动生成默认的密码在执行记录中,注意复制出来

如果没有看到随机密码,先去vi /etc/my.cnf 加上

skip-grant-tables

然后mysql直接登陆

update user set authentication_string=password('root') where user='root';

最后再去掉

 

 

5、启动mysql服务

  service mysql start

登录
mysql  -uroot  -p
enter password: 

6、设置密码、远程访问和开机自启

设置密码
set password=password('新密码');

远程访问
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '访问密码';
flush privileges;


添加mysql服务到自启服务
chkconfig --add mysql

设置开机自启
chkconfig mysql on

查看列表
chkconfig --list

7、设置环境变量,记得生效一下

8、防火墙和端口也搞一搞

9、遇到的错误

遇到错误1
Starting MySQL.Logging to '/usr/local/mysql-5.7.24/data/node2.err'.
The server quit without updating PID file (/usr/local/mysql[失败]4/data/node2.pid).

修改/etc/my.cnf
[client]
port=3306
default-character-set=utf8

[mysqld]
port=3306
character-set-server=utf8
default_storage_engine=InnoDB
datadir = /usr/local/mysql-5.7.24/data
log-error = /usr/local/mysql-5.7.24/data/error.log
pid-file=/usr/local/mysql-5.7.24/data/mysql.pid
user=root
tmpdir=/tmp
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

-----------------------------------------------------------------------------------------
遇到错误2
./mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory
执行以下命令
yum -y install numactl.x86_64

-----------------------------------------------------------------------------------------
遇到错误3
./mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
执行以下命令
yum -y install libaio

参考:https://www.cnblogs.com/hsbt2333/p/9915616.html

 

二、安装redis

Linux redis 安装
1. 安装c运行环境
   执行命令: yum install gcc-c++(需要联网)
2. 进入目录解压tar包到user下的local 
   执行命令: tar -xvf redis-3.0.6.tar.gz -C /usr/local/
3. 进入redis-3.0.6 
   执行命令: make(编译)
4. 执行命令: make PREFIX=/usr/local/redis install(安装到usr/local/redis文件夹)
5. 执行命令:  ./redis-server(进入redis/bin启动)
6. 端口号为:6379
        出现大箱子 安装成功

        在根目录下 执行以下命令:
/sbin/iptables -I INPUT -p tcp --dport 6379 -j ACCEPT 开启防火墙信任端口
        /etc/rc.d/init.d/iptables save 永久保存

        可以修改配置文件启动redis后台运行

复制usr/local/redis-3.0.6/redis.conf到redis/bin  

        进入bin执行命令 vim redis.conf打开 修改daemonize  no改为yes

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值