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)






热门AI工具

更多
DeepSeek
DeepSeek

幻方量化公司旗下的开源大模型平台

豆包大模型
豆包大模型

字节跳动自主研发的一系列大型语言模型

通义千问
通义千问

阿里巴巴推出的全能AI助手

腾讯元宝
腾讯元宝

腾讯混元平台推出的AI助手

文心一言
文心一言

文心一言是百度开发的AI聊天机器人,通过对话可以生成各种形式的内容。

讯飞写作
讯飞写作

基于讯飞星火大模型的AI写作工具,可以快速生成新闻稿件、品宣文案、工作总结、心得体会等各种文文稿

即梦AI
即梦AI

一站式AI创作平台,免费AI图片和视频生成。

ChatGPT
ChatGPT

最最强大的AI聊天机器人程序,ChatGPT不单是聊天机器人,还能进行撰写邮件、视频脚本、文案、翻译、代码等任务。

相关专题

更多
Python 序列化
Python 序列化

本专题整合了python序列化、反序列化相关内容,阅读专题下面的文章了解更多详细内容。

0

2026.02.02

AO3官网入口与中文阅读设置 AO3网页版使用与访问
AO3官网入口与中文阅读设置 AO3网页版使用与访问

本专题围绕 Archive of Our Own(AO3)官网入口展开,系统整理 AO3 最新可用官网地址、网页版访问方式、正确打开链接的方法,并详细讲解 AO3 中文界面设置、阅读语言切换及基础使用流程,帮助用户稳定访问 AO3 官网,高效完成中文阅读与作品浏览。

91

2026.02.02

主流快递单号查询入口 实时物流进度一站式追踪专题
主流快递单号查询入口 实时物流进度一站式追踪专题

本专题聚合极兔快递、京东快递、中通快递、圆通快递、韵达快递等主流物流平台的单号查询与运单追踪内容,重点解决单号查询、手机号查物流、官网入口直达、包裹进度实时追踪等高频问题,帮助用户快速获取最新物流状态,提升查件效率与使用体验。

27

2026.02.02

Golang WebAssembly(WASM)开发入门
Golang WebAssembly(WASM)开发入门

本专题系统讲解 Golang 在 WebAssembly(WASM)开发中的实践方法,涵盖 WASM 基础原理、Go 编译到 WASM 的流程、与 JavaScript 的交互方式、性能与体积优化,以及典型应用场景(如前端计算、跨平台模块)。帮助开发者掌握 Go 在新一代 Web 技术栈中的应用能力。

11

2026.02.02

PHP Swoole 高性能服务开发
PHP Swoole 高性能服务开发

本专题聚焦 PHP Swoole 扩展在高性能服务端开发中的应用,系统讲解协程模型、异步IO、TCP/HTTP/WebSocket服务器、进程与任务管理、常驻内存架构设计。通过实战案例,帮助开发者掌握 使用 PHP 构建高并发、低延迟服务端应用的工程化能力。

5

2026.02.02

Java JNI 与本地代码交互实战
Java JNI 与本地代码交互实战

本专题系统讲解 Java 通过 JNI 调用 C/C++ 本地代码的核心机制,涵盖 JNI 基本原理、数据类型映射、内存管理、异常处理、性能优化策略以及典型应用场景(如高性能计算、底层库封装)。通过实战示例,帮助开发者掌握 Java 与本地代码混合开发的完整流程。

5

2026.02.02

go语言 注释编码
go语言 注释编码

本专题整合了go语言注释、注释规范等等内容,阅读专题下面的文章了解更多详细内容。

62

2026.01.31

go语言 math包
go语言 math包

本专题整合了go语言math包相关内容,阅读专题下面的文章了解更多详细内容。

55

2026.01.31

go语言输入函数
go语言输入函数

本专题整合了go语言输入相关教程内容,阅读专题下面的文章了解更多详细内容。

27

2026.01.31

热门下载

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

精品课程

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

共48课时 | 8.3万人学习

Git 教程
Git 教程

共21课时 | 3.3万人学习

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

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