mysql 5.7 二进制安装

直接进入安装的话题,mysql5.7 已经 出来很久了,安装一下mysql 数据库


首先根据自己的系统,我的系统centos6.8  64位,

1首先下载 二进制安装包。

cd /usr/local/src/
wget  http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz  


2解压 安装

tar  zxvf  mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz 
mv mysql-5.7.18-linux-glibc2.5-x86_64  /usr/local/mysql
cd /usr/local/mysql/

3添加mysql 用户,并且创建 mysql 的datadir 

useradd -M -s /sbin/nologin  mysql 
mkdir -p /data/mysql
chown mysql /data/mysql

4 初始化mysql

./bin/mysqld   --initialize --user=mysql --datadir=/data/mysql
2017-07-17T21:16:04.187478Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-07-17T21:16:05.146566Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-07-17T21:16:05.273795Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-07-17T21:16:05.347727Z 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: 24d52603-6b35-11e7-9a99-000c29cd9738.
2017-07-17T21:16:05.355372Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-07-17T21:16:05.359803Z 1 [Note] A temporary password is generated for root@localhost: 2t>Jutc2isnV
注意 mysql 5.7  上面就是密码了, 是随机生成的密码。


如果遇到错误:
./bin/mysqld   --initialize --user=mysql --datadir=/data/mysql
./bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or    directory
解决方案:
 yum install   -y   libaio.x86_64  libaio-devel.x86_64


5 拷贝 配置文件,以及启动脚本

 cp support-files/my-default.cnf  /etc/my.cnf  
 vim /etc/my.cnf //编辑或者修改
# These are commonly set, remove the # and set as required.
  basedir = /usr/local/mysql
  datadir = /data/mysql
  port = 3306
  socket = /tmp/mysql.sock

提供一个简单的配置 my.cnf
[mysqld]
port            = 3306
socket          = /tmp/mysql.sock
datadir         = /data/mysql
default-storage-engine = InnoDB
#skip-locking
explicit_defaults_for_timestamp = true


# connection
#skip-name-resolve
#skip-networking
max_connections = 1024
max_connect_errors = 10000000
wait_timeout = 15
sql_mode = NO_ENGINE_SUBSTITUTION

# character -default
character_set_server=utf8

# buffer & cache
back_log = 300
key_buffer_size = 256M
max_allowed_packet = 32M
sort_buffer_size = 8M
read_buffer_size = 4M
join_buffer_size = 4M
#record_buffer = 2M
read_rnd_buffer_size = 2M
thread_cache_size = 128
tmp_table_size = 128M
query_cache_size = 0
query_cache_type = 0
max_heap_table_size = 96M

拷贝启动 脚本

cp support-files/mysql.server /etc/init.d/mysqld
vi /etc/init.d/mysqld   //修改
basedir=/usr/local/mysql
datadir=/data/mysql

6 加入到开机启动项

chkconfig  --add  mysqld
chkconfig  mysql on
/etc/init.d/mysqld  start  

7 连接mysql 

mysql  -uroot -p'2t>Jutc2isnV'   
进入 mysql后 第一件事情,就是要修改 root 密码,否则会报错
第一次进入的时候
mysql>  set password=password('123456');


8 如果忘记了密码,也没有关系 有办法,编辑配置文件
vi /etc/my.cnf
在[mysqld]下面增加一行
skip-grant-tables
重启  /etc/init.d/mysqld restart
这个时候就能免密登陆了。

/usr/local/mysql/bin/mysql  -uroot
mysql> use mysql;
mysql> update user set authentication_string=password('newpassword') where user='root';
mysql> flush privileges;

退出来后,更改my.cnf,去掉刚加的 skip-grant-tables重启 /etc/init.d/mysqld restart


在mysql5.7 ,对mysql.user  表  密码字段换成了 authentication_string     认证字符串. 这和5.6 稍有不同。


参考文档
http://www.cnblogs.com/gaojupeng/p/5727069.html
http://blog.csdn.net/kk185800961/article/details/53170055








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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值