Linux下安装-配置-mysql-5.7.13

来源:互联网 发布:数据仿真软件 编辑:程序博客网 时间:2024/06/06 06:38

当前linux版本 AliCloud Linux 4.4.6-3  


{     具体路径自行修改     }

1.准备安装包mysql-5.7.13   (官网地址:    http://dev.mysql.com/downloads/mysql/   )(低版本的不知道还有没有)


2. 添加一个mysql组 (命令)

[root@localhost ~]# groupadd mysql


3.添加一个用户mysql
[root@localhost ~]# useradd -g mysql mysql


4.解压tar包(文件 在/usr/tmp中解压)

[root@localhost tmp]# tar -xzvf mysql-5.7.13.tar.gz


5 然后 重命名 解压后的包  ,命名为mysql

[root@localhost tmp]# mv mysql-5.7.13 mysql


6. 查看tmp临时包 移动 mysql包到usr/local 中

[root@localhost tmp]# mv /mysql /usr/loca/


7. cd进入mysql中 给这个包授权 给mysql用户

[root@localhost tmp]# cd /usr/local/mysql

[root@localhostmysql]# chown –R mysql .

[root@localhostmysql]# chgrp –R mysql .


8. 配置参数 ( basedir 为mysql 的路径, datadir 为mysql的 data 包,里面存放着mysql自己的包)

[root@localhost mysql]# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql


9.记住临时密码(最后的密码)

2017-01-05T05:07:26.637535Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-01-05T05:07:28.754579Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-01-05T05:07:28.962679Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-01-05T05:07:29.080754Z 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: db1cd080-d304-11e6-91bb-00163e047c4a.
2017-01-05T05:07:29.083708Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-01-05T05:07:29.086486Z 1 [Note] A temporary password is generated for root@localhost:
K07xmF?pX%Gh


    然后执行

[root@localhost mysql]# #bin/mysql_ssl_rsa_setup --datadir=/data/mysql


10.  cd到当前 /support-files 下 ,复制两个文件 到 etc 和/etc/init.d/ 下


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

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


13. 修改basedir=  自己的路径     修改datadir= 自己的路径 

(本人:  basedir=/usr/local/mysql              bindir=/usr/local/mysql/bin)

[root@localhost support-files]# vim /etc/init.d/mysql 


14. 启动mysql  (如果不行可以使用命令: service mysql start  启动) 

[root@localhost mysql]# bin/mysqld_safe --user=mysql &   

15. 登录(输入临时密码 注意大小写),登录后提示欢迎语, 

[root@localhost mysql]# bin/mysql --user=root -p
Enter password: 

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

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.

16.在 sqlplus 命令行下修改密码 

mysql>set password=password('123456');

授权

mysql>grant all privileges on *.* to root@'%' identified by '123456';

刷新

mysql>flush privileges;


mysql>use mysql;

mysql>select host,user from user;

................................查看完毕 此后随意........................




0 0
原创粉丝点击