您的位置:首页 > 运维架构 > Linux

centos7 二进制安装mysql 5.7.16版本

2017-06-15 16:03 363 查看
1下载解压mysql安装包

[root@localhost mysql]# tar xvf mysql-5.7.16-linux-glibc2.5-i686.tar.gz

对解压的文件重命名

[root@localhost mysql]#mv mysql-5.7.16-linux-glibc2.5-i686 mysql-5.7.16

2我这里在usr目录下创建mysql文件夹

[root@master mysql]# pwd

/usr/mysql

3.[root@master mysql]# 在mysql目录下创建 data,logs,pid文件夹

[root@master mysql]# ls

boost mysql5.7

data mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz

logs mysql-test-5.7.16-linux-glibc2.5-x86_64.tar.gz pids

4、创建mysql的用户组和用户,并对mysql目录设置用户组和用户

[root@master mysql]# groupadd mysql

[root@master mysql]# useradd mysql -g mysql

5、添加用户组权限

[root@localhost mysql]# chown -R mysql .

[root@localhost mysql]# chgrp -R mysql .

6、安装mysql

[root@master mysql]# ls

mysql5.7

mysql-5.7.16 这是我解压后重命名的名字

data mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz

logs mysql-test-5.7.16-linux-glibc2.5-x86_64.tar.gz

make pids

[root@master mysql]# cd mysql-5.7.16/

[root@master mysql-5.7.16]# ls

bin COPYING docs include lib man README share support-files

[root@master mysql-5.7.16]# cd bin/

[root@master bin]# ls

innochecksum mysql_config_editor mysqlshow

lz4_decompress mysqld mysqlslap

myisamchk mysqld-debug mysql_ssl_rsa_setup

myisam_ftdump mysqld_multi mysqltest_embedded

myisamlog mysqld_safe mysql_tzinfo_to_sql

myisampack mysqldump mysql_upgrade

my_print_defaults mysqldumpslow mysqlxtest

mysql mysql_embedded perror

mysqladmin mysqlimport replace

mysqlbinlog mysql_install_db resolveip

mysqlcheck mysql_plugin resolve_stack_dump

mysql_client_test_embedded mysqlpump zlib_decompress

mysql_config mysql_secure_installation

进入mysql源文件的bin目录下执行 yum install libaio安装插件

[root@master bin]# yum install libaio

执行命令

[root@master bin]# ./mysql_install_db –user=mysql –basedir=/usr/mysql/mysql5.7/ –datadir=/usr/mysql/data

注意:这个命令会报错:

2017-06-15 13:49:16 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld –initialize

2017-06-15 13:49:18 [ERROR] The bootstrap log isn’t empty:

2017-06-15 13:49:18 [ERROR] 2017-06-15T05:49:16.141037Z 0 [Warning] –bootstrap is deprecated. Please consider using –initialize instead

2017-06-15T05:49:16.141501Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)

2017-06-15T05:49:16.141505Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)

2017-06-15T05:49:16.141678Z 0 [ERROR] Can’t read from messagefile ‘/usr/share/mysql/english/errmsg.sys’

这个错误原因:“”bootstrap is deprecated. Please consider using –initialize instead“”大致意思是启动方式已经启用:mysql_install_db。

在mysql官网得知新方式

./mysqld –user=mysql –basedir=/usr/mysql/mysql5.7/ –datadir=/usr/mysql/data

使用mysqld来启动:

[root@master bin]# ./mysqld –initialize –user=mysql –basedir=/usr/mysql/mysql-5.7.16 –datadir=/usr/mysql/data

[root@master bin]# ./mysqld –initialize –user=mysql –basedir=/usr/mysql/mysql-5.7.16 –datadir=/usr/mysql/data

2017-06-15T07:37:19.261129Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use –explicit_defaults_for_timestamp server option (see documentation for more details).

2017-06-15T07:37:19.261176Z 0 [Warning] ‘NO_ZERO_DATE’, ‘NO_ZERO_IN_DATE’ and ‘ERROR_FOR_DIVISION_BY_ZERO’ sql modes should be used with strict mode. They will be merged with strict mode in a future release.

2017-06-15T07:37:19.261180Z 0 [Warning] ‘NO_AUTO_CREATE_USER’ sql mode was not set.

2017-06-15T07:37:19.578311Z 0 [Warning] InnoDB: New log files created, LSN=45790

2017-06-15T07:37:19.641818Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

2017-06-15T07:37:19.705611Z 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: 76730c2f-519d-11e7-b762-000c29629ecb.

2017-06-15T07:37:19.706501Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed’ cannot be opened.

2017-06-15T07:37:19.706935Z 1 [Note] A temporary password is generated for root@localhost: kkgeQvjh;2lV

临时生成的密码kkgeQvjh;2lV

以上步骤安装成功

7、配置文件

[root@master mysql-5.7.16]# ls

bin COPYING docs include lib man README share support-files

[root@master mysql-5.7.16]# cd support-files/

[root@master support-files]# ls

`1 magic my-default.cnf mysqld_multi.server mysql-log-rotate mysql.server

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

cp:是否覆盖”/etc/my.cnf”? yes

[root@master support-files]# cp mysql.server /etc/init.d/mysql

[root@master support-files]# vi /etc/i

idmapd.conf inputrc ipsec.conf iscsi/

init.d/ ipa/ ipsec.d/ issue

inittab iproute2/ ipsec.secrets issue.net

[root@master support-files]# vi /etc/init.d/mysql

basedir=/usr/mysql/mysql5.7/

datadir=/usr/mysql/data

8、配置环境变量

[root@master ~]# vi .bash_profile

.bash_profile

if [ -f ~/.bashrc ]; then

. ~/.bashrc

fi

PATH=PATH:HOME/bin

export MYSQL_HOME=”/usr/mysql/mysql-5.7.16”

export PATH=”PATH:MYSQL_HOME/bin”

9.添加开机启动服务

chkconfig –add mysql

chkconfig mysql on

10。启动报错

启动报错了,原来是编辑/etc/init.d/mysql 文件出错了,修改为下面

vim /etc/init.d/mysql

basedir=/home/mysql/mysql-5.7.16

datadir=/home/mysql/data

修改之后

service mysql start

[root@master ~]# service mysql start

Starting MySQL. SUCCESS!

[root@master ~]#

[root@localhost mysql]#chkconfig –list mysqld

mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off

重启系统,mysqld就会自动启动了。

*检查是否启动

[root@localhost mysql]#netstat -anp|grep mysqld

tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2365/mysqld

unix 2 [ ACC ] STREAM LISTENING 14396 2365/mysqld /tmp/mysql.sock

12、修改密码: ./mysqladmin -u root -p password “新密码”

[root@master bin]# ./mysqladmin -u root -p password 123456

Enter password:

mysqladmin: [Warning] Using a password on the command line interface can be insecure.

Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.

登录

[root@master bin]# ./mysql -uroot -p

Enter password:

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

Your MySQL connection id is 24

Server version: 5.7.16 MySQL Community Server (GPL)

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> GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘123456’ WITH GRANT OPTION;

Query OK, 0 rows affected, 1 warning (0.00 sec)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mysql centos