CentOS 安装mysql5.7 不使用yum安装

**

去mysql官网下载mysql5.7最新版本

**
官网链接: http://dev.mysql.com/downloads/mysql/

可以使用迅雷下载后ftp传到Linux下面,也可wget下载,如果有需要迅雷现在的请自行下载;
下载地址:http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.15-linux-glibc2.5-x86_64.tar.gz
下面为大家讲解一下wget下载安装。

1.下载mysql-5.7.15-linux-glibc2.5-x86_64.tar.gz

[root@centos01 ~]# wget http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.15-linux-glibc2.5-x86_64.tar.gz

2.解压mysql-5.7.15-linux-glibc2.5-x86_64.tar.gz

[root@centos01 ~]# tar -zvxf mysql-5.7.15-linux-glibc2.5-x86_64.tar.gz

3.将解压在root目录下的mysql-5.7.15-linux-glibc2.5-x86_64移动到/home/mysql

[root@centos01 ~]# mv mysql-5.7.15-linux-glibc2.5-x86_64 /home/mysql

5.在mysql下面创建data数据库文件目录

[root@centos01 ~]# cd /home
[root@centos01 home]# mkdir mysql/data

6.创建mysql的用户组和用户,并对mysql目录设置用户组和用户

[root@centos01 home]# groupadd mysql
[root@centos01 home]# useradd mysql -g mysql
[root@centos01 home]# cd mysql
[root@centos01 home]# pwd
/home/mysql
[root@centos01 mysql]# chown -R mysql .
[root@centos01 mysql]# chgrp -R mysql .

7.初始化mysql并启动mysql服务
由于 mysql5.7新特性, mysql_install_db 已经不再推荐使用了,建议改成 mysqld –initialize 完成实例初始化。

[root@centos01 mysql]# cd /bin
[root@centos01 bin]# ./mysqld --user=mysql --basedir=/home/mysql --datadir=/home/mysql/data --initialize

输出信息如下:

2016-10-07T03:02:46.996421Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-10-07T03:02:48.559028Z 0 [Warning] InnoDB: New log files created, LSN=45790
2016-10-07T03:02:48.958787Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-10-07T03:02:49.138262Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 878aaa95-8c3a-11e6-936f-40a8f020a848.
2016-10-07T03:02:49.185261Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2016-10-07T03:02:49.186379Z 1 [Note] A temporary password is generated for root@localhost: dq4q&eYjPNRT

初始化成功。
牢记上面的随机密码, 如上dq4q&eYjPNRT, 下面我们修改密码时需要用到。

ps:如果输出如下信息则表示初始化失败,需要给/tmp文件夹777权限。

2016-10-07T03:00:48.057660Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
mysqld: Can't create/write to file '/tmp/ibXXFZrR' (Errcode: 13 - Permission denied)
2016-10-07T03:00:48.066391Z 0 [ERROR] InnoDB: Unable to create temporary file; errno: 13
2016-10-07T03:00:48.066411Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2016-10-07T03:00:48.066424Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2016-10-07T03:00:48.066431Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2016-10-07T03:00:48.066440Z 0 [ERROR] Failed to initialize plugins.
2016-10-07T03:00:48.066447Z 0 [ERROR] Aborting

8.检测下是否能启动mysql服务

[root@centos01 bin]# cd /home/mysql
./support-files/mysql.server start
[root@centos01 mysql]# ./support-files/mysql.server start

安装出现如下信息

./support-files/mysql.server: line 271: cd: /usr/local/mysql: No such file or directory
Starting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)

需要修改support-files下mysql.server文件

[root@centos01 mysql]# cd support-files/
[root@centos01 support-files]# vim mysql.server

将66-73行/usr/local/修改为/home/
然后重新开启mysq

[root@centos01 support-files]# ./mysql.server start
Starting MySQL. SUCCESS!

到这里MySQL就启动成功了!

[root@centos01 mysql]# cd bin
[root@centos01 bin]# ./mysql -uroot -p
Enter password:
这个也就是刚才的那个密码:dq4q&eYjPNRT

出现以下信息表示登录成功了。

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.15

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

8.修改密码

set password=password('youpassword');
Query OK, 0 rows affected, 1 warning (0.00 sec)

9.设定远程登录mysql。在Linux下为了安全,默认是不允许mysql本机以外的机器访问mysql数据库服务,因此需要重新授权root。方便远程访问。

mysql>  use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select Host,User from user;
+-----------+-----------+
| Host      | User      |
+-----------+-----------+
| localhost | mysql.sys |
| localhost | root      |
+-----------+-----------+
2 rows in set (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO root@'%' identified by 'youpassword';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

授权语句最后的‘youpassword’是mysql数据库root用户的新密码。

10.非必要的步骤,如果远程连不上,估计是防火墙的问题,关闭试试:

 [root@centos01 bin]#  service iptables stop
iptables: Setting chains to policy ACCEPT: filter  [  OK  ]
iptables: Flushing firewall rules:                 [  OK  ]
iptables: Unloading modules:                       [  OK  ]

11.配置mysql服务开机自动启动

拷贝启动文件到/etc/init.d/下并重命令为mysqld

[root@centos01 ~]# cp /home/mysql/support-files/mysql.server /etc/init.d/mysqld

增加执行权限

[root@centos01 ~]# chmod 755 /etc/init.d/mysqld

检查自启动项列表中没有mysqld这个,如果没有就添加mysqld:

[root@centos01 ~]# chkconfig --list mysqld
service mysqld supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add mysqld')
[root@centos01 ~]# chkconfig --add mysqld

设置MySQL在345等级自动启动

[root@centos01 ~]# chkconfig --level 345 mysqld on

或用这个命令设置开机启动

[root@centos01 ~]# chkconfig mysqld on

12、 mysql服务的启动/重启/停止
启动mysql服务

[root@centos01 ~]# service mysqld start

重启mysql服务

 [root@centos01 ~]# service mysqld restart

停止mysql服务

[root@centos01 ~]# service mysqld stop

到此就安装配置成功!

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值