欢迎光临
我们一直在努力

centos6.7 64位环境下部署MySQL-5.7.13

本站教程收集整理的这篇文章主要介绍了centos6.7 64位环境下部署MySQL-5.7.13,本站教程本站觉得挺不错的,现在分享给大家,也给大家做个参考。

系统环境:

@H_403_9@[root@localhost ~]# cat /etc/redhat-release

@H_403_9@CentOS release 6.7 (Final)

@H_403_9@[root@localhost tools]# uname -a

@H_403_9@Linux localhost 2.6.32-573.22.1.el6.x86_64 #1 SMP Wed Mar 23 03:35:39 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

@H_403_9@[root@localhost tools]#

软件准备:

@H_403_9@[root@localhost tools]# pwd

@H_403_9@/opt/tools

@H_403_9@[root@localhost tools]# ll

@H_403_9@@R_349_10586@l 674208

@H_403_9@-rw-r–r– 1 root root 639864682 Jul 22 17:47 MysqL-5.7.13-linux-glibc2.5-x86_64.tar.gz

@H_403_9@-rw-r–r– 1 root root 50516207 May 25 12:01 MysqL-5.7.13.tar.gz

解压安装:

@H_403_9@[root@localhost tools]# tar xf MysqL-5.7.13-linux-glibc2.5-x86_64.tar.gz

@H_403_9@@R_349_10586@l 674212

@H_403_9@drwxr-xr-x 9 7161 wheel 4096 May 25 15:04 MysqL-5.7.13-linux-glibc2.5-x86_64

@H_403_9@-rw-r–r– 1 root root 50516207 May 25 12:01 MysqL-5.7.13.tar.gz

@H_403_9@[root@localhost tools]#

@H_403_9@[root@localhost tools]# mv MysqL-5.7.13-linux-glibc2.5-x86_64 /usr/local/MysqL

初始化操作(生成初始密码):

@H_403_9@[root@localhost MysqL]# ./bin/MysqLd –initialize –user=MysqL –basedir=/usr/local/MysqL –datadir=/data/MysqL/data

@H_403_9@2016-07-22T09:58:15.001776Z 0 [Warning] InnoDB: New log files created,LSN=45790

@H_403_9@2016-07-22T09:58:15.062066Z 0 [Warning] InnoDB: CreaTing foreign key consTraint system tables.

@H_403_9@2016-07-22T09:58:15.073009Z 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: cebfb8a6-4ff2-11e6-8c8d-005056a01a07.

@H_403_9@2016-07-22T09:58:15.074370Z 0 [Warning] Gtid table is not ready to be used. Table ‘Mysql.gtid_executed’ cAnnot be opened.

@H_403_9@2016-07-22T09:58:15.075736Z 1 [Note] A temporary password is generated for root@localhost: k_1ljzVh3<-,

@H_403_9@[root@localhost MysqL]#

PS:MysqL5.7新特性:由上面可以看出, MysqL_inst@R_607_10636@db 已经不再推荐使用了,建议改成 MysqLd –initialize 完成实例初始化。

@H_403_9@

加入MysqL为系统服务:

@H_403_9@[root@localhost MysqL]# cp support-files/Mysql.server /etc/init.d/MysqLd

@H_403_9@[root@localhost MysqL]# chkconfig MysqLd on

@H_403_9@[root@localhost MysqL]# chkconfig –list|grep MysqLd

@H_403_9@mysqLd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

@H_403_9@[root@localhost MysqL]#chmod 755 /etc/init.d/MysqLd

@H_462_39@mysqL服务启动、重启、停止

@H_403_9@[root@localhost MysqL]# serivce MysqLd start

@H_403_9@[root@localhost MysqL]# serivce MysqLd stop

@H_403_9@[root@localhost MysqL]# serivce MysqLd restart

@H_403_9@[root@localhost MysqL]#

设置环境变量:

@H_403_9@[root@localhost MysqL]# vim /etc/profile

@H_403_9@export PATH=/usr/local/MysqL/bin:$PATH

@H_403_9@[root@localhost MysqL]#

检查MysqL是否能开启

[root@localhost MysqL]# cd /usr/local/MysqL

[root@localhost MysqL]# cd support-files/

[root@localhost support-files]# ./Mysql.server start

StarTing Mysql.. succesS!

@H_403_9@若改用了, 则在启动服务时会出现如下错误:

@H_403_9@# ./support-files/Mysql.server start

@H_403_9@./support-files/Mysql.server: line 276: cd: /usr/local/MysqL: No such file or directory

@H_403_9@StarTing MysqL ERROR! Couldn’t find MysqL server (/usr/local/MysqL/bin/MysqLd_safE)

@H_403_9@这时候我们需要修改/support-files/Mysql.server文件的basedir和datadir目录路径为我们正确的MysqL的basedir和datadir路径, 如下:

@H_403_9@# vim support-files/Mysql.server

@H_403_9@————————–

@H_403_9@…

@H_403_9@basedir=/usr/local/MysqL

@H_403_9@datadir=/data/MysqL/data

@H_403_9@# ./support-files/Mysql.server start

@H_403_9@StarTing Mysql.. succesS!

@H_403_9@创建配置文件

将默认生成的my.cnf备份

# mv /etc/my.cnf /etc/my.cnf.bak

[root@localhost support-files]# cp my-default.cnf /etc/my.cnf

初始化MysqL用户root的密码

先将MysqL服务停止

# service MysqLd stop

进入MysqL安装目录, 执行:

# cd /usr/local/MysqL

# ./bin/MysqLd_safe –skip-grant-tables –skip-networking&香港vps

[1] 6225

[root@localhost MysqL]# 151110 02:46:08 MysqLd_safe Logging to ‘/data/MysqL/data/localhost.localdomain.err’.

151110 02:46:08 MysqLd_safe StarTing MysqLd daemon with databases from /data/MysqL/data

另外打开一个终端(p.s. 如果是ssh连接登录的,另外创建一个ssh连接即可), 执行操作如下:

# MysqL -u root MysqL

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A


Welcome to the MysqL monitor. Commands end with ; or \g.

Your MysqL connection id is 2

Server version: 5.7.13 MysqL Community Server (GPL)

Copyright (C) 2000,2015,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.

@H_29_1@mysqL> use MysqL;

Database changed

@H_29_1@mysqL> updatE user SET password=passworD(‘123456′) WHERE user=’root’;

ERROR 1054 (42S22): UnkNown column ‘password’ in ‘field list’

@H_29_1@mysqL> update user set authentication_String = passworD(‘123456’) where user = ‘root’;

Query OK,1 row affected,1 warning (0.02 seC)

Rows matched: 1 Changed: 1 Warnings: 1

@H_29_1@mysqL> flush privileges;

Query OK,0 rows affected (0.00 seC)

@H_29_1@mysqL> \s

@H_29_1@mysqL Ver 14.14 DiStrib 5.7.13,for linux-glibc2.5 (x86_64) using EditLine wrapper

Connection id: 62

Current database:

Current user: root@localhost

SSL: Not in use

Current pager: stdout

Using outfile: ”

Using delimiter: ;

Server version: 5.7.13-log MysqL Community Server (GPL)

Protocol version: 10

Connection: Localhost via UNIX socket

Server characterset: utf8

Db characterset: utf8

Client characterset: utf8

Conn. characterset: utf8

UNIX socket: /data/AEData/MysqL/data/Mysql.sock

Uptime: 46 min 54 sec

Threads: 6 Questions: 6846 Slow queries: 0 Opens: 257 Flush tables: 1 Open tables: 201 Queries per second avg: 2.432

————–

@H_29_1@mysqL>

到此, 设置完MysqL用户root的密码且确保MysqL编码集是utf8,注意上面, 新版本的Mysql.user表里的密码字段是authentication_String

@H_710_2@mysqL远程授权

格式如下:

@H_29_1@mysqL> grant all [privileges] on db_name.table_name to ‘username’@’host’ identified by ‘password’;

示例如下:

@H_29_1@mysqL> grant all privileges on *.* to ‘root’@’%’ identified by ‘123456’;

Query OK,0 rows affected,1 warning (0.04 seC)

@H_29_1@mysqL> FLUSH PRIVILEGES;

Query OK,0 rows affected (0.00 seC)

@H_29_1@mysqL>

或用

@H_29_1@mysqL> grant all on *.* to ‘root’@’%’ identified by ‘123456’;

到此, 完成了MysqL的安装 及配置!!!

参考案例:http://blog.csdn.net/cryHelyxx/article/details/49757217

本站总结

以上是本站教程为你收集整理的centos6.7 64位环境下部署MySQL-5.7.13全部内容,希望文章能够帮你解决centos6.7 64位环境下部署MySQL-5.7.13所遇到的程序开发问题。

如果觉得本站教程网站内容还不错,欢迎将本站教程推荐给好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。