欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

centos安装mysql5.6

程序员文章站 2022-05-26 23:40:16
...

一、首先下载mysql5.6所需安装包, 采用rpm方式进行安装,所以下载以下载以下安装包

MySQL-client-5.6.15-1.el6.x86_64.rpm

MySQL-devel-5.6.15-1.el6.x86_64.rpm

MySQL-server-5.6.15-1.el6.x86_64.rpm

如系统可以联网,可采用以下方式下载,如不能上网可根据以下地址提前下载。

wget http://cdn.mysql.com/archives/mysql-5.6/MySQL-client-5.6.15-1.el6.x86_64.rpm

  

wget http://cdn.mysql.com/archives/mysql-5.6/MySQL-devel-5.6.15-1.el6.x86_64.rpm

 

wget http://cdn.mysql.com/archives/mysql-5.6/MySQL-server-5.6.15-1.el6.x86_64.rpm

 

 二、安装mysql

2.1 检查系统是否已安装mysql

执行以下命令查看系统中是否安装mysql

rpm -qa|grep mysql

 我的系统执行后结果如下:

[[email protected] tmp]# rpm -qa|grep mysql
mysql-libs-5.1.61-4.el6.x86_64

 以上结果显示安装了mysql-libs 且版本为5.1.61,此时必须删除该包,否则安装时会报有冲突,如下所示

MySQL-server-5.6.15-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64

 删除mysql相应的包:

yum -y remove mysql*

 2.2安装mysql

依次执行以下命令进行安装

rpm -ivh MySQL-server-5.6.15-1.el6.x86_64.rpm

 

rpm -ivh MySQL-devel-5.6.15-1.el6.x86_64.rpm

 

rpm -ivh MySQL-client-5.6.15-1.el6.x86_64.rpm

 执行结果如下所示:

[[email protected] tmp]# rpm -ivh MySQL-server-5.6.15-1.el6.x86_64.rpm
Preparing...                ########################################### [100%]
   1:MySQL-server           ^A########################################### [100%]
2016-02-04 18:50:39 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-02-04 18:50:40 6295 [Note] InnoDB: The InnoDB memory heap is disabled
2016-02-04 18:50:40 6295 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-02-04 18:50:40 6295 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-02-04 18:50:40 6295 [Note] InnoDB: Using Linux native AIO
2016-02-04 18:50:40 6295 [Note] InnoDB: Using CPU crc32 instructions
2016-02-04 18:50:40 6295 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-02-04 18:50:41 6295 [Note] InnoDB: Completed initialization of buffer pool
2016-02-04 18:50:41 6295 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2016-02-04 18:50:41 6295 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2016-02-04 18:50:41 6295 [Note] InnoDB: Database physically writes the file full: wait...
2016-02-04 18:50:41 6295 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2016-02-04 18:50:47 6295 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2016-02-04 18:50:53 6295 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2016-02-04 18:50:53 6295 [Warning] InnoDB: New log files created, LSN=45781
2016-02-04 18:50:53 6295 [Note] InnoDB: Doublewrite buffer not found: creating new
2016-02-04 18:50:53 6295 [Note] InnoDB: Doublewrite buffer created
2016-02-04 18:50:53 6295 [Note] InnoDB: 128 rollback segment(s) are active.
2016-02-04 18:50:53 6295 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-02-04 18:50:53 6295 [Note] InnoDB: Foreign key constraint system tables created
2016-02-04 18:50:53 6295 [Note] InnoDB: Creating tablespace and datafile system tables.
2016-02-04 18:50:53 6295 [Note] InnoDB: Tablespace and datafile system tables created.
2016-02-04 18:50:53 6295 [Note] InnoDB: Waiting for purge to start
2016-02-04 18:50:53 6295 [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-02-04 18:50:54 6295 [Note] Binlog end
2016-02-04 18:50:54 6295 [Note] InnoDB: FTS optimize thread exiting.
2016-02-04 18:50:54 6295 [Note] InnoDB: Starting shutdown...
2016-02-04 18:50:55 6295 [Note] InnoDB: Shutdown completed; log sequence number 1625977


2016-02-04 18:50:55 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-02-04 18:50:55 6333 [Note] InnoDB: The InnoDB memory heap is disabled
2016-02-04 18:50:55 6333 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-02-04 18:50:55 6333 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-02-04 18:50:55 6333 [Note] InnoDB: Using Linux native AIO
2016-02-04 18:50:55 6333 [Note] InnoDB: Using CPU crc32 instructions
2016-02-04 18:50:55 6333 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-02-04 18:50:55 6333 [Note] InnoDB: Completed initialization of buffer pool
2016-02-04 18:50:55 6333 [Note] InnoDB: Highest supported file format is Barracuda.
2016-02-04 18:50:55 6333 [Note] InnoDB: 128 rollback segment(s) are active.
2016-02-04 18:50:55 6333 [Note] InnoDB: Waiting for purge to start
2016-02-04 18:50:55 6333 [Note] InnoDB: 5.6.15 started; log sequence number 1625977
2016-02-04 18:50:55 6333 [Note] Binlog end
2016-02-04 18:50:55 6333 [Note] InnoDB: FTS optimize thread exiting.
2016-02-04 18:50:55 6333 [Note] InnoDB: Starting shutdown...
2016-02-04 18:50:57 6333 [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

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

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

[[email protected] tmp]# rpm -ivh MySQL-devel-5.6.15-1.el6.x86_64.rpm
Preparing...                ########################################### [100%]
   1:MySQL-devel            ########################################### [100%]
[[email protected] tmp]# rpm -ivh MySQL-client-5.6.15-1.el6.x86_64.rpm
Preparing...                ########################################### [100%]
   1:MySQL-client           ########################################### [100%]
[[email protected] tmp]# 

 执行结果如上所示表示mysql已经安装成功。

 三、配置mysql

复制mysqlsql配置文件到/etc/my.cnf

 

cp /usr/share/mysql/my-default.cnf /etc/my.cnf

 初始化mysql数据库

/usr/bin/mysql_install_db

 启动mysql

[[email protected] tmp]# service mysql start
Starting MySQL................... SUCCESS! 

 查看mysql随机密码

[[email protected] tmp]# cat /root/.mysql_secret
# The random password set for the root user at Thu Feb  4 18:50:54 2016 (local time): 8CSQIhhd

 登录mysql

执行命令

mysql -uroot -p

 输入查看到的密码:

[[email protected] tmp]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.15

Copyright (c) 2000, 2013, 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.

mysql> 

 

修改mysql密码:

 

mysql> set password for 'root'@'localhost' =password('123456');
Query OK, 0 rows affected (0.02 sec)

 刷新权限

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

 

 

 

至此,在centos上完成安装mysql5.6

 

 

 

相关标签: mysql