Mysql-5.7二进制免编译安装

来源:互联网 发布:unity 软件位置 编辑:程序博客网 时间:2024/05/24 23:14

Mysql_5.7和Mysql_5.6差异较大

Mysql_5.7安装步骤

1.在/usr/local/src目录,下载MySQL64位的包并解压

[root@dl-001 src]# wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz[root@dl-001 src]# tar zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

2.把解压完的数据移动到/usr/local/mysql,并进入该目录下

[root@dl-001 src]# mv mysql-5.7.17-linux-glibc2.5-x86_64 /usr/local/mysql[root@dl-001 src]# cd /usr/local/mysql

3.创建Mysql用户,并创建目录/data/mysql用来存储数据及更改属性

[root@dl-001 mysql]# useradd mysql       [root@dl-001 mysql]# mkdir -p /data/mysql[root@dl-001 mysql]# chown -R mysql /data/mysql

4.初始化

[root@dl-001 mysql]# bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/// 完成之后有个提示  A temporary password is generated for root@localhost: 7xYgMS,i(pne 。  后面是 root 密码。

5.cp配置文件地址

[root@dl-001 mysql]# cp support-files/mysql.server /etc/init.d/mysqld[root@dl-001 mysql]# cp support-files/my-default.cnf /etc/my.cnf

6.更改配置文件

[root@dl-001 mysql]# vim /etc/init.d/mysqldbasedir=/usr/local/mysqldatadir=/data/mysql[root@dl-001 mysql]# vim /etc/my.cnfbasedir = /usr/local/mysqldatadir = /data/mysqlport = 3306socket = /tmp/mysql.sock

7.启动

[root@dl-001 mysql]# /etc/init.d/mysqld start

设置密码

//使用初始化密码登录,进入后直接设置密码,一定要设置一下新密码[root@dl-001 mysql]# /usr/local/mysql/bin/mysql -uroot -p'3A)¥#LkcFP'mysql: [Warning] Using a password on the command line interface can be insecure.Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 3Server version: 5.7.17Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> set password = password('12#¥%6');   //设置密码Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> quit     //退出Bye

在知道初始化密码的情况下设置密码

vi /etc/my.cnf在[mysqld]下面增加一行skip-grant-tables重启  /etc/init.d/mysqld restart/usr/local/mysql/bin/mysql -uroot mysql> update user set authentication_string=password('123333') where user='root';退出来后,更改my.cnf,去掉刚加的 skip-grant-tables重启 /etc/init.d/mysqld restart此时就可以使用新的密码了。