解压缩版

时间:2020-02-01 10:56来源:江苏十一选五手机版数据库
从官网下载mysql-5.6.12-linux-glibc2.5-x86_64.tar.gz 1.环境 1、系统CentOS 7 2、数据库Mysql 5.7 创建mysql用户 2.准备工作 1、从MySQL官网上下载压缩包到本地 运行环境 CentOS 7 下载地址: 我下载的版本

从官网下载mysql-5.6.12-linux-glibc2.5-x86_64.tar.gz

1.环境

1、系统CentOS 7

2、数据库Mysql 5.7

创建mysql用户

2.准备工作

1、从MySQL官网上下载压缩包到本地

运行环境 CentOS 7

下载地址:

我下载的版本是: mysql-5.7.20-linux-glibc2.12-x86_64.tar

图片 1

从MySQL官网上下载压缩包到本地

2、上传到把下载好的文件上传到Linux服务器上

我把下载的文件放在/usr/local下 (个人喜好放在这里,如果怕操作有问题最好和我步骤一模一样)

图片 2

上传到把下载好的文件上传到Linux服务器上

3、创建mysql组和用户

进入Linux创建mysql组和用户、我这个是新的干净的Linux系统,没任何安装剩余的残留痕迹,下面我直接创建MySQL组和用户

命令如下:

cat /etc/group | grep mysql

cat /etc/passwd | grep mysql

groupadd mysql

useradd -r -g mysql mysql

图片 3

创建mysql组和用户

(useradd -r -g mysql mysql :参数表示mysql用户是系统用户,不可用于登录系统)

[root@Master home]# useradd mysql[root@Master data]# echo 'mysql'|passwd --stdin mysql

3.开始安装MySQL

1、进入/usr/local/目录中中解压 MySQL安装包

解压命令:tar xvf mysql-5.7.20-linux-glibc2.12-x86_64.tar

解压完毕后你会发现有mysql-test-5.7.20-linux-glibc2.12-x86_64.tar.gz这个解压包

图片 4

进入/usr/local/目录中中解压 MySQL安装包

再次对mysql-test-5.7.20-linux-glibc2.12-x86_64.tar.gz 解压,这个包是我们真正要用MySQL的包,因为名字太长 我对解压后的文件重命名了。

解压命令:tar -zxvf mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz

图片 5

mysql-test-5.7.20-linux-glibc2.12-x86_64.tar.gz 解压

重命名命令:mv mysql-5.7.20-linux-glibc2.12-x86_64 mysql 

解压后的文件都在mysql文件夹里面

2、更改所属的组和用户

更改所属的用户命令:chown -R mysql mysql/

更改所属的组户命令:chgrp -R mysql mysql/

图片 6

更改所属的组和用户

3、安装和初始化MySQL数据库

进入 mysql目录

执行命令:bin/mysql_install_db--user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/

图片 7

安装和初始化MySQL数据库执行命令

4、在mysql目录下拷贝mysql.server文件到 /etc/init.d/mysqld

执行命令:cp -a ./support-files/mysql.server /etc/init.d/mysqld

图片 8

在mysql目录下拷贝mysql.server文件到 /etc/init.d/mysqld

更改用户 mysql 的密码 。

4.配置MySQL数据

1、编辑/etc/init.d/mysqld 添加数据库安装目录,和数据存放的地方。

basedir这个目录是数据库的根目录 也就是安装目录

datadir这个目录是数据存放的地方

编辑修改/etc/init.d/mysqld命令如下:vim /etc/init.d/mysqld

配置好这两个路径之后保存退出

图片 9

编辑/etc/init.d/mysqld 添加数据库安装目录,和数据存放的地方。

2、删除系统默认的MySQL配置文件/etc/my.cnf(这步很重要,我安装的时候犯的错误)

这个配置文件不知道怎么自动默认生成的,里面的配置是错误的反正删除它就对了

使用命令:rm -rf /etc/my.cnf

图片 10

删除系统默认的MySQL配置文件/etc/my.cnf

3、初始化MySQL

在mysql的bin目录下执行以下命令

使用命令:./mysqld_safe --user=mysql &

图片 11

初始化MySQL

4、启动MySQL

执行以下命令

使用命令:/etc/init.d/mysqld restart

但你看到:Starting MySQL. SUCCESS! 表示启动成功!

图片 12

启动MySQL

5、设置开机启动

执行以下命令:chkconfig --level35mysqld on

图片 13

设置开机启动

6、初始化密码设置

1、mysql5.7会生成一个初始化密码,而在之前的版本首次登陆不需要登录。

在bin执行以下命令:cat /root/.mysql_secret

执行完毕后你会看到生成一个随机密码,大家可以看到 tpmpkOPq-uRA 这个密码是我的shui'ji

图片 14

生成一个初始化密码

2、用初始化密码登录MySQL设置密码

在bin使用命令: ./mysql -uroot -p

输入刚刚随机生成的初始化密码 输入完毕后按回车,你会发现你已经登录进来了

图片 15

用初始化密码登录MySQL设置密码

3、写SQL 设置自己的密码 比如我的密码就叫root

在SQL中输入:SETPASSWORD = PASSWORD('root');

成功之后再flush一下

输入:flush privileges;

图片 16

设置自己的密码

4、添加远程访问 

在SQL中输入:use mysql;

再设置远程访问命令:update user set host = '%' where user = 'root';

图片 17

添加远程访问

使用 select host, user from user;查看状态

可以看到root有个% 通配符表示OK了。

图片 18

passwd: 所有的身份验证令牌已经成功更新。

5.重启MySQL

1、通过以上的配置已经完成了MySQL5.7的所有安装步骤,现在只需要重起一下MySQL服务即可使用MySQL数据库了。

使用命令:/etc/init.d/mysqld restart

看到以下内容 表示重启完成

图片 19

重启MySQL服务

2、使用远程Navicat测试MySQL数据库是否安装成功

远程登录MySQL 端口默认3306,看到以下提示MySQL数据表示全部安装成功

图片 20

创建mysql用户的原因

不用mysql用户会出现一下错误,尝试了很多次,添加mysql用户安装成功

*当然很多时候我们已经创建好别的用户,来完成日常的操作如果不创建mysql用户,修改mysql/bin目录下的mysqld_safe文件; //亲测成功

具体步骤:

[root@Master bin]# vim mysqld_safeuser='mysql' 修改为 user='hadoop' //自己的用户 后边步骤基本相同*[root@Slave1 data]# service mysql startStarting MySQL...... ERROR! The server quit without updating PID file (/home/hadoop/ruanJian/mysql/data/Slave1.Hadoop.pid).[root@Master data]#vim Slave1.Hadoop.err //查看日志文件160830 15:56:44 mysqld_safe Starting mysqld daemon with databases from /home/hadoop/ruanJian/mysql/data2016-08-30 15:56:49 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2016-08-30 15:56:49 1990 [ERROR] Fatal error: Can't change to run as user 'mysql' ; Please check that the user exists!2016-08-30 15:56:49 1990 [ERROR] Aborting2016-08-30 15:56:49 1990 [Note] Binlog end2016-08-30 15:56:49 1990 [Note] /home/hadoop/ruanJian/mysql/bin/mysqld: Shutdown complete160830 15:56:49 mysqld_safe mysqld from pid file /home/hadoop/ruanJian/mysql/data/Slave1.Hadoop.pid ended

在mysql用户下创建data目录并解压

[root@Master data]# tar -zxvf mysql-5.6.12-linux-glibc2.5-x86_64.tar.gz[root@Master data]# mv mysql-5.6.12-linux-glibc2.5-x86_64 mysql //重命名

设置权限

[root@Master data]# chown -R mysql:mysql mysql

切换用户并进入mysql/scripts 目录

[root@Master data]# su mysql[mysql@Master data]$ cd mysql/scripts/[mysql@Master scripts]$

安装(目录根据自己的mysql解压目录自行设置)

[mysql@Master scripts]$ ./mysql_install_db --user=mysql --basedir=/home/mysql/data/mysql --datadir=/home/mysql/data/mysql/data

输出信息

Installing MySQL system tables...2016-08-30 19:55:41 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2016-08-30 19:55:42 1354 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)2016-08-30 19:55:42 1354 [Warning] Buffered warning: Changed limits: table_cache: 431 (requested 2000)2016-08-30 19:55:42 1354 [Note] InnoDB: The InnoDB memory heap is disabled2016-08-30 19:55:42 1354 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins2016-08-30 19:55:42 1354 [Note] InnoDB: Compressed tables use zlib 1.2.32016-08-30 19:55:42 1354 [Note] InnoDB: Using Linux native AIO2016-08-30 19:55:42 1354 [Note] InnoDB: Not using CPU crc32 instructions2016-08-30 19:55:42 1354 [Note] InnoDB: Initializing buffer pool, size = 128.0M2016-08-30 19:55:42 1354 [Note] InnoDB: Completed initialization of buffer pool2016-08-30 19:55:42 1354 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!2016-08-30 19:55:42 1354 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB2016-08-30 19:55:42 1354 [Note] InnoDB: Database physically writes the file full: wait...2016-08-30 19:55:42 1354 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB2016-08-30 19:55:43 1354 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB2016-08-30 19:55:44 1354 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile02016-08-30 19:55:44 1354 [Warning] InnoDB: New log files created, LSN=457812016-08-30 19:55:44 1354 [Note] InnoDB: Doublewrite buffer not found: creating new2016-08-30 19:55:44 1354 [Note] InnoDB: Doublewrite buffer created2016-08-30 19:55:44 1354 [Note] InnoDB: 128 rollback segment(s) are active.2016-08-30 19:55:44 1354 [Warning] InnoDB: Creating foreign key constraint system tables.2016-08-30 19:55:44 1354 [Note] InnoDB: Foreign key constraint system tables created2016-08-30 19:55:44 1354 [Note] InnoDB: Creating tablespace and datafile system tables.2016-08-30 19:55:44 1354 [Note] InnoDB: Tablespace and datafile system tables created.2016-08-30 19:55:44 1354 [Note] InnoDB: Waiting for purge to start2016-08-30 19:55:44 1354 [Note] InnoDB: 5.6.12 started; log sequence number 02016-08-30 19:55:44 1354 [Note] Binlog end2016-08-30 19:55:44 1354 [Note] InnoDB: FTS optimize thread exiting.2016-08-30 19:55:44 1354 [Note] InnoDB: Starting shutdown...2016-08-30 19:55:46 1354 [Note] InnoDB: Shutdown completed; log sequence number 1625977OKFilling help tables...2016-08-30 19:55:46 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2016-08-30 19:55:46 1377 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)2016-08-30 19:55:46 1377 [Warning] Buffered warning: Changed limits: table_cache: 431 (requested 2000)2016-08-30 19:55:46 1377 [Note] InnoDB: The InnoDB memory heap is disabled2016-08-30 19:55:46 1377 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins2016-08-30 19:55:46 1377 [Note] InnoDB: Compressed tables use zlib 1.2.32016-08-30 19:55:46 1377 [Note] InnoDB: Using Linux native AIO2016-08-30 19:55:46 1377 [Note] InnoDB: Not using CPU crc32 instructions2016-08-30 19:55:46 1377 [Note] InnoDB: Initializing buffer pool, size = 128.0M2016-08-30 19:55:46 1377 [Note] InnoDB: Completed initialization of buffer pool2016-08-30 19:55:46 1377 [Note] InnoDB: Highest supported file format is Barracuda.2016-08-30 19:55:46 1377 [Note] InnoDB: 128 rollback segment(s) are active.2016-08-30 19:55:46 1377 [Note] InnoDB: Waiting for purge to start2016-08-30 19:55:46 1377 [Note] InnoDB: 5.6.12 started; log sequence number 16259772016-08-30 19:55:46 1377 [Note] Binlog end2016-08-30 19:55:46 1377 [Note] InnoDB: FTS optimize thread exiting.2016-08-30 19:55:46 1377 [Note] InnoDB: Starting shutdown...2016-08-30 19:55:48 1377 [Note] InnoDB: Shutdown completed; log sequence number 1625987OKTo start mysqld at boot time you have to copysupport-files/mysql.server to the right place for your systemPLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !To do so, start the server, then issue the following commands:/home/mysql/data/mysql/bin/mysqladmin -u root password 'new-password'/home/mysql/data/mysql/bin/mysqladmin -u root -h Master.Hadoop password 'new-password'Alternatively you can run:/home/mysql/data/mysql/bin/mysql_secure_installationwhich will also give you the option of removing the testdatabases and anonymous user created by default. This isstrongly recommended for production servers.See the manual for more instructions.You can start the MySQL daemon with:cd . ; /home/mysql/data/mysql/bin/mysqld_safe &You can test the MySQL daemon with mysql-test-run.plcd mysql-test ; perl mysql-test-run.plPlease report any problems with the ./bin/mysqlbug script!The latest information about MySQL is available on the web at MySQL by buying support/licenses at  default config file was created as /home/mysql/data/mysql/my.cnf andwill be used by default by the server when you start it.You may edit this file to change server settingsWARNING: Default config file /etc/my.cnf exists on the systemThis file will be read by default by the MySQL serverIf you do not want to use this, either remove it, or use the--defaults-file argument to mysqld_safe when starting the server

配置文件

[mysql@Master scripts]$ cd ../support-files/[root@Master support-files]# cp my-default.cnf /etc/my.cnf[root@Master support-files]# cp mysql.server /etc/init.d/mysql[root@Master support-files]# vim /etc/init.d/mysql //修改mysql文件

添加以下两行

basedir=/home/mysql/data/mysqldatadir=/home/mysql/data/mysql/data

配置环境变量

[root@Master support-files]# vim /etc/profile#set mysql environmentexport MYSQL_HOME=/home/mysql/data/mysqlexport PATH=$MYSQL_HOME/bin:$PATH

配置mysql服务开机自动启动

[root@Master bin]# chkconfig --add mysql //添加mysql[root@Master bin]# chkconfig mysql on //设置开机启动

启动mysql

[root@Master support-files]# service mysql startenv: /etc/init.d/mysql: 权限不够 //如果出现这个提示 执行以下命令重新启动[root@Master support-files]# chmod a+wrx /etc/init.d/mysql[root@Master support-files]# service mysql startStarting MySQL.. SUCCESS! //启动成功

设置root登录密码

[root@Master ~]# cd /home/mysql/data/mysql/bin/ //进去mysql的bin目录[root@Master bin]# ./mysqladmin -u root password 'password' //'password' 为自己设置的密码引号非必须[root@Master bin]# ./mysqladmin -u root password mysql[root@Master bin]# mysql -u root -pEnter password: Welcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 4Server version: 5.6.12 MySQL Community Server (GPL)Copyright (c) 2000, 2013, 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

以上所述是小编给大家介绍的Linux下安装mysql-5.6.12-linux-glibc2.5-x86_64.tar.gz,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

编辑:江苏十一选五手机版数据库 本文来源:解压缩版

关键词: