0

0

Linux系统上安装MySQL 5.6

php中文网

php中文网

发布时间:2016-06-07 15:34:17

|

1452人浏览过

|

来源于php中文网

原创

安装环境 : 软件 版本 位数 MySQL 5.6.22 32 CentOS 6.4 32 VMware 9.0.1 32 Mysql官方下载地址,可以根据当前系统自动识别适合当前系统版本的mysql版本: http://dev.mysql.com/downloads/mysql/ 官网比较慢,百度云盘包含32位和64位的: http://pan.baidu.

安装环境 :

软件 版本 位数
MySQL 5.6.22 32
CentOS 6.4 32
VMware 9.0.1 32

Mysql官方下载地址,可以根据当前系统自动识别适合当前系统版本的mysql版本:

http://dev.mysql.com/downloads/mysql/

官网比较慢,百度云盘包含32位和64位的:

http://pan.baidu.com/s/1sj6YeJj


一,卸载自带mysql,删除MySQL的lib库,服务文件

某个性淘客站整站打包
某个性淘客站整站打包

1、演示:以截图为准 2、安装说明: 1,运行 你的域名/install/index.php填写相关信息进行安装, 2,安装后运行 你的域名/dede进入后台--系统--数据备份/还原---点击右上数据还原---开始还原数据 3, 系统--系统基本设置--站点设置--域名改为你的域名(否则显示不正常) 这一步很重要 更新主页HTML 更新栏目HTML 更新文档HT

下载
[root@localhost  ~]# yum remove mysql mysql-server mysql-libs


如果之前安装过,则执行rpm -ev进行删除,删除失败,则是有依赖项,则先删除依赖项

[root@localhost  ~]# rpm -ev MySQL-server-5.0.22-0.i386
[root@localhost  ~]# rpm -ev MySQL-client-5.0.22-0.i386


清除所有mysql相关文件:

[root@localhost  ~]#find / -name mysql
[root@localhost  ~]#rm -rf 文件或者文件夹


查看是否有残留文件:

[root@localhost  ~]#rpm -qa | grep -i mysql


执行命令卸载MySQL相关的文件

[root@localhost  ~]# yum -y remove MySQL*


二,安装MySQL

1.复制mysql安装包到安装目录

[root@localhost opt]# mkdir mysql
[root@localhost opt]# cp /home/duke147/Desktop/Tools/MySQL-5.6.22-1.linux_glibc2.5.i386.rpm-bundle.tar /opt/mysql/
[root@localhost opt]# cd mysql/
[root@localhost mysql]# ls -a 
.  ..  MySQL-5.6.22-1.linux_glibc2.5.i386.rpm-bundle.tar

2.解压安装包

[root@localhost mysql]# tar xvf MySQL-5.6.22-1.linux_glibc2.5.i386.rpm-bundle.tar
MySQL-test-5.6.22-1.linux_glibc2.5.i386.rpm                   #MySQL的测试组件
MySQL-shared-5.6.22-1.linux_glibc2.5.i386.rpm                 #MySQL的共享库
MySQL-shared-compat-5.6.22-1.linux_glibc2.5.i386.rpm          #MySQL版本兼容的包
MySQL-client-5.6.22-1.linux_glibc2.5.i386.rpm                 #MySQL客户端程序
MySQL-devel-5.6.22-1.linux_glibc2.5.i386.rpm                  #MySQL的库和头文件
MySQL-embedded-5.6.22-1.linux_glibc2.5.i386.rpm               #MySQL的嵌入式程序
MySQL-server-5.6.22-1.linux_glibc2.5.i386.rpm                 #MySQL服务端程序

3.安装服务端

[root@localhost mysql]# rpm -ivh MySQL-server-5.6.22-1.linux_glibc2.5.i386.rpm
Preparing...                ########################################### [100%]
   1:MySQL-server           ########################################### [100%]
2014-12-18 21:08:42 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-12-18 21:08:42 4959 [Note] InnoDB: Using mutexes to ref count buffer pool pages
2014-12-18 21:08:42 4959 [Note] InnoDB: The InnoDB memory heap is disabled
2014-12-18 21:08:42 4959 [Note] InnoDB: Mutexes and rw_locks use InnoDB's own implementation
2014-12-18 21:08:42 4959 [Note] InnoDB: Memory barrier is not used
2014-12-18 21:08:42 4959 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-12-18 21:08:42 4959 [Note] InnoDB: Using Linux native AIO
2014-12-18 21:08:42 4959 [Note] InnoDB: Not using CPU crc32 instructions
2014-12-18 21:08:42 4959 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-12-18 21:08:42 4959 [Note] InnoDB: Completed initialization of buffer pool
2014-12-18 21:08:42 4959 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2014-12-18 21:08:42 4959 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2014-12-18 21:08:42 4959 [Note] InnoDB: Database physically writes the file full: wait...
2014-12-18 21:08:42 4959 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2014-12-18 21:08:43 4959 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2014-12-18 21:08:44 4959 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2014-12-18 21:08:44 4959 [Warning] InnoDB: New log files created, LSN=45781
2014-12-18 21:08:44 4959 [Note] InnoDB: Doublewrite buffer not found: creating new
2014-12-18 21:08:44 4959 [Note] InnoDB: Doublewrite buffer created
2014-12-18 21:08:44 4959 [Note] InnoDB: 128 rollback segment(s) are active.
2014-12-18 21:08:44 4959 [Warning] InnoDB: Creating foreign key constraint system tables.
2014-12-18 21:08:44 4959 [Note] InnoDB: Foreign key constraint system tables created
2014-12-18 21:08:44 4959 [Note] InnoDB: Creating tablespace and datafile system tables.
2014-12-18 21:08:44 4959 [Note] InnoDB: Tablespace and datafile system tables created.
2014-12-18 21:08:44 4959 [Note] InnoDB: Waiting for purge to start
2014-12-18 21:08:44 4959 [Note] InnoDB: 5.6.22 started; log sequence number 0
A random root password has been set. You will find it in '/root/.mysql_secret'.
2014-12-18 21:08:45 4959 [Note] Binlog end
2014-12-18 21:08:45 4959 [Note] InnoDB: FTS optimize thread exiting.
2014-12-18 21:08:45 4959 [Note] InnoDB: Starting shutdown...
2014-12-18 21:08:46 4959 [Note] InnoDB: Shutdown completed; log sequence number 1625977

2014-12-18 21:08:46 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-12-18 21:08:46 4982 [Note] InnoDB: Using mutexes to ref count buffer pool pages
2014-12-18 21:08:46 4982 [Note] InnoDB: The InnoDB memory heap is disabled
2014-12-18 21:08:46 4982 [Note] InnoDB: Mutexes and rw_locks use InnoDB's own implementation
2014-12-18 21:08:46 4982 [Note] InnoDB: Memory barrier is not used
2014-12-18 21:08:46 4982 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-12-18 21:08:46 4982 [Note] InnoDB: Using Linux native AIO
2014-12-18 21:08:46 4982 [Note] InnoDB: Not using CPU crc32 instructions
2014-12-18 21:08:46 4982 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-12-18 21:08:46 4982 [Note] InnoDB: Completed initialization of buffer pool
2014-12-18 21:08:46 4982 [Note] InnoDB: Highest supported file format is Barracuda.
2014-12-18 21:08:46 4982 [Note] InnoDB: 128 rollback segment(s) are active.
2014-12-18 21:08:46 4982 [Note] InnoDB: Waiting for purge to start
2014-12-18 21:08:46 4982 [Note] InnoDB: 5.6.22 started; log sequence number 1625977
2014-12-18 21:08:46 4982 [Note] Binlog end
2014-12-18 21:08:46 4982 [Note] InnoDB: FTS optimize thread exiting.
2014-12-18 21:08:46 4982 [Note] InnoDB: Starting shutdown...
2014-12-18 21:08:48 4982 [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'.

#你可以找从/root/.mysql_secret中找到root用户的随机密码。

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 at http://bugs.mysql.com/

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

4.查看,安装客户端,库文件

[root@localhost mysql]# rpm -qa | grep -i mysql
MySQL-server-5.6.22-1.linux_glibc2.5.i386
[root@localhost mysql]# rpm -ivh MySQL-client-5.6.22-1.linux_glibc2.5.i386.rpm
Preparing...                ########################################### [100%]
   1:MySQL-client           ########################################### [100%]
[root@localhost mysql]# rpm -ivh MySQL-devel-5.6.22-1.linux_glibc2.5.i386.rpm 
Preparing...                ########################################### [100%]
   1:MySQL-devel            ########################################### [100%]


MySQL默认安装路径:

a.数据库目录: /var/lib/mysql/
b.配置文件:     /usr/share/mysql
c.相关命令:     /usr/bin
d.启动脚本:     /etc/rc.d/init.d/


5.修改配置文件,将MySQL的配置文件拷贝到/etc目录下。

[root@localhost mysql]# cp /usr/share/mysql/my-default.cnf /etc/my.cnf


#如果使用默认配置,则不需要进行修改

[root@localhost mysql]# vi /etc/my.cnf

6.初始化MySQL

[root@localhost mysql]# /usr/bin/mysql_install_db


7.启动MySQL

[root@localhost mysql]# service mysql start
Starting MySQL.... SUCCESS! 

检测mysql 3306是否安打开

[root@localhost mysql]# netstat -nat
tcp        0      0 :::3306                     :::*                        LISTEN  

8.查看root账号初始信息

[root@localhost mysql]# cat /root/.mysql_secret
# The random password set for the root user at Thu Dec 18 21:08:44 2014 (local time): vuN8xfuKTRnmqX3I

9.使用默认密码登陆mysql

[root@localhost mysql]# mysql -u root -pvuN8xfuKTRnmqX3I
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.22

Copyright (c) 2000, 2014, 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> set password = password('123456');
Query OK, 0 rows affected (0.02 sec)
退出mysql

mysql> quit;
Bye

10.添加自启动服务

[root@localhost ~]# chkconfig --add mysql
[root@localhost ~]# chkconfig mysql on

11.配置远程访问

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
Query OK, 0 rows affected (0.01 sec)

刷新权限

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

配置单个IP访问权限,*.* 指 【数据库.表】:

mysql > GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.56' IDENTIFIED BY '123456' WITH GRANT OPTION;flush privileges;

关闭防火墙

[root@localhost ~]# service iptables stop
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]
[root@localhost ~]# service iptables status
iptables: Firewall is not running.


修改密码

mysql> use mysql;
mysql> update user set password=password('123456') where user='root';
mysql> flush privileges;

查看数据库

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)






相关专题

更多
c++主流开发框架汇总
c++主流开发框架汇总

本专题整合了c++开发框架推荐,阅读专题下面的文章了解更多详细内容。

79

2026.01.09

c++框架学习教程汇总
c++框架学习教程汇总

本专题整合了c++框架学习教程汇总,阅读专题下面的文章了解更多详细内容。

46

2026.01.09

学python好用的网站推荐
学python好用的网站推荐

本专题整合了python学习教程汇总,阅读专题下面的文章了解更多详细内容。

121

2026.01.09

学python网站汇总
学python网站汇总

本专题整合了学python网站汇总,阅读专题下面的文章了解更多详细内容。

12

2026.01.09

python学习网站
python学习网站

本专题整合了python学习相关推荐汇总,阅读专题下面的文章了解更多详细内容。

15

2026.01.09

俄罗斯手机浏览器地址汇总
俄罗斯手机浏览器地址汇总

汇总俄罗斯Yandex手机浏览器官方网址入口,涵盖国际版与俄语版,适配移动端访问,一键直达搜索、地图、新闻等核心服务。

71

2026.01.09

漫蛙稳定版地址大全
漫蛙稳定版地址大全

漫蛙稳定版地址大全汇总最新可用入口,包含漫蛙manwa漫画防走失官网链接,确保用户随时畅读海量正版漫画资源,建议收藏备用,避免因域名变动无法访问。

370

2026.01.09

php学习网站大全
php学习网站大全

精选多个优质PHP入门学习网站,涵盖教程、实战与文档,适合零基础到进阶开发者,助你高效掌握PHP编程。

45

2026.01.09

php网站搭建教程大全
php网站搭建教程大全

本合集专为零基础用户打造,涵盖PHP网站搭建全流程,从环境配置到实战开发,免费、易懂、系统化,助你快速入门建站!

12

2026.01.09

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
PostgreSQL 教程
PostgreSQL 教程

共48课时 | 7万人学习

Git 教程
Git 教程

共21课时 | 2.6万人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号