2017-12-26--mysql(5.6.15),linux下安装使用

本文档的目的是,指导使用者安装、配置、还原所需要用到的mysql数据库。仅提供linux版本服务器的安装说明,且linux版本为64位的Centos6.4。同时,会提供的mysql安装包(MySQL-5.6.15-1.linux_glibc2.5.x86_64.rpm-bundle.tar)和还原数据库所需用到的sql脚本。

mysql安装提供的tar包,解压到/opt/mysql(实际使用可变换目录)目录下。解压后,会出现如下几个rpm包,我们只用到其中红色字体的两个rpm包。

[root@localhost mysql]# tar -xvf MySQL-5.6.15-1.linux_glibc2.5.x86_64.rpm-bundle.tar

MySQL-devel-5.6.15-1.linux_glibc2.5.x86_64.rpm

MySQL-embedded-5.6.15-1.linux_glibc2.5.x86_64.rpm

MySQL-test-5.6.15-1.linux_glibc2.5.x86_64.rpm

MySQL-server-5.6.15-1.linux_glibc2.5.x86_64.rpm

MySQL-shared-5.6.15-1.linux_glibc2.5.x86_64.rpm

MySQL-client-5.6.15-1.linux_glibc2.5.x86_64.rpm

MySQL-shared-compat-5.6.15-1.linux_glibc2.5.x86_64.rpm

安装步骤,如下说明:

一、检查环境,删除已有的旧版本

检查mysql,如已存在则需要删除。执行脚本如下

rpm -qa mysql

rpm -qa mysql-5.1.66-2.el6_3.x86_64

rpm -e mysql --nodeps;

检查mysql-server,如已存在则需要删除。执行脚本如下

rpm -qa mysql-server

mysql-server-5.1.66-2.el6_3.x86_64

rpm -e mysql-server --nodeps;

检查mysql- client,如已存在则需要删除。执行脚本如下

rpm -qa mysql-client

测试中发现没有安装,不用删除

检查mysql- libs,如已存在则需要删除。执行脚本如下

rpm -qa mysql-libs

mysql-libs-5.1.66-2.el6_3.x86_64

rpm -e mysql-libs --nodeps;

二、安装mysql服务器

安装mysql成功后,会为root随机生成一个密码,密码保存在\'/root/.mysql_secret\'文件内。

[root@localhost mysql]# rpm -ivh MySQL-server-5.6.15-1.linux_glibc2.5.x86_64.rpm

Preparing...                ########################################### [100%]

1:MySQL-server           ########################################### [100%]

2016-05-12 15:37:48 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2016-05-12 15:37:48 22636 [Note] InnoDB: The InnoDB memory heap is disabled

2016-05-12 15:37:48 22636 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2016-05-12 15:37:48 22636 [Note] InnoDB: Compressed tables use zlib 1.2.3

2016-05-12 15:37:48 22636 [Note] InnoDB: Using Linux native AIO

2016-05-12 15:37:48 22636 [Note] InnoDB: Using CPU crc32 instructions

2016-05-12 15:37:48 22636 [Note] InnoDB: Initializing buffer pool, size = 128.0M

2016-05-12 15:37:48 22636 [Note] InnoDB: Completed initialization of buffer pool

2016-05-12 15:37:48 22636 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!

2016-05-12 15:37:48 22636 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB

2016-05-12 15:37:48 22636 [Note] InnoDB: Database physically writes the file full: wait...

2016-05-12 15:37:48 22636 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB

2016-05-12 15:37:49 22636 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB

2016-05-12 15:37:50 22636 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0

2016-05-12 15:37:50 22636 [Warning] InnoDB: New log files created, LSN=45781

2016-05-12 15:37:50 22636 [Note] InnoDB: Doublewrite buffer not found: creating new

2016-05-12 15:37:50 22636 [Note] InnoDB: Doublewrite buffer created

2016-05-12 15:37:50 22636 [Note] InnoDB: 128 rollback segment(s) are active.

2016-05-12 15:37:50 22636 [Warning] InnoDB: Creating foreign key constraint system tables.

2016-05-12 15:37:50 22636 [Note] InnoDB: Foreign key constraint system tables created

2016-05-12 15:37:50 22636 [Note] InnoDB: Creating tablespace and datafile system tables.

2016-05-12 15:37:50 22636 [Note] InnoDB: Tablespace and datafile system tables created.

2016-05-12 15:37:50 22636 [Note] InnoDB: Waiting for purge to start

2016-05-12 15:37:50 22636 [Note] InnoDB: 5.6.15 started; log sequence number 0

A random root password has been set. You will find it in \'/root/.mysql_secret\'.

2016-05-12 15:37:57 22636 [Note] Binlog end

2016-05-12 15:37:57 22636 [Note] InnoDB: FTS optimize thread exiting.

2016-05-12 15:37:57 22636 [Note] InnoDB: Starting shutdown...

2016-05-12 15:37:58 22636 [Note] InnoDB: Shutdown completed; log sequence number 1625977

2016-05-12 15:37:58 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2016-05-12 15:37:58 22659 [Note] InnoDB: The InnoDB memory heap is disabled

2016-05-12 15:37:58 22659 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2016-05-12 15:37:58 22659 [Note] InnoDB: Compressed tables use zlib 1.2.3

2016-05-12 15:37:58 22659 [Note] InnoDB: Using Linux native AIO

2016-05-12 15:37:58 22659 [Note] InnoDB: Using CPU crc32 instructions

2016-05-12 15:37:58 22659 [Note] InnoDB: Initializing buffer pool, size = 128.0M

2016-05-12 15:37:58 22659 [Note] InnoDB: Completed initialization of buffer pool

2016-05-12 15:37:58 22659 [Note] InnoDB: Highest supported file format is Barracuda.

2016-05-12 15:37:58 22659 [Note] InnoDB: 128 rollback segment(s) are active.

2016-05-12 15:37:59 22659 [Note] InnoDB: Waiting for purge to start

2016-05-12 15:37:59 22659 [Note] InnoDB: 5.6.15 started; log sequence number 1625977

2016-05-12 15:37:59 22659 [Note] Binlog end

2016-05-12 15:37:59 22659 [Note] InnoDB: FTS optimize thread exiting.

2016-05-12 15:37:59 22659 [Note] InnoDB: Starting shutdown...

2016-05-12 15:38:01 22659 [Note] InnoDB: Shutdown completed; log sequence number 1625987

A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !

You will find that password in \'/root/.mysql_secret\'.

You must change that password on your first connect,

no other statement but \'SET PASSWORD\' will be accepted.

See the manual for the semantics of the \'password expired\' flag.

Also, the account for the anonymous user has been removed.

In addition, you can run:

/usr/bin/mysql_secure_installation

which will also give you the option of removing the test database.

This is strongly recommended for production servers.

See the manual for more instructions.

Please report any problems with the /usr/bin/mysqlbug script!

The latest information about MySQL is available on the web at

Support MySQL by buying support/licenses at

New default config file was created as /usr/my.cnf and

will be used by default by the server when you start it.

You may edit this file to change server settings

[root@localhost mysql]#

三、安装mysql客户端

[root@localhost mysql]# rpm -ivh MySQL-client-5.6.15-1.linux_glibc2.5.x86_64.rpm

Preparing...                ########################################### [100%]

1:MySQL-client           ########################################### [100%]

启动mysqld服务

查找mysql.server

[root@localhost /]# find / -name mysql.server

/usr/share/mysql/mysql.server

拷贝mysql.server/etc/rc.d/init.d/mysqld

[root@terminal opt]# cp /usr/share/mysql/mysql.server  /etc/rc.d/init.d/mysqld

添加mysqld执行权限

[root@terminal opt]#chmod +x /etc/rc.d/init.d/mysqld

添加mysqld系统服务

[root@terminal opt]#chkconfig --add mysqld

检查mysqld是否生效

[root@terminal opt]# chkconfig --list mysqld

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zwsxyp.html