Mysql学习之--卸载源码mysql-5.6安装mysql-5.5

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
云数据库 RDS PostgreSQL,集群系列 2核4GB
简介:

系统环境

操作系统:RedHat EL6

DB Soft:  Mysql 5.5.12

    Mysql 在linux下的安装方式有两种版本,一种为Binary(二进制),另外一种为Source(源码包),本文为Source Install方式。

由于,本机已经安装了mysql-5.6的版本,前面的版本采用源码包安装,只需要删除相应的安装文件即可!

1、卸载mysql-5.6

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
删除/var/lib/mysql下的文件:
[oracle @ogg  mysql]$ su -
Password:
[root @ogg  ~]# cd /var/lib/mysql/
[root @ogg  mysql]# ls
auto.cnf     ib_logfile1           mysql-bin. 000001   mysql-bin. 000004   mysql-bin. 000007   ogg.err             test
ibdata1      master-log-bin.index  mysql-bin. 000002   mysql-bin. 000005   mysql-bin. 000008   ogg.pid
ib_logfile0  mysql                 mysql-bin. 000003   mysql-bin. 000006   mysql-bin.index   performance_schema
[root @ogg  mysql]# rm -rf *
 
删除/usr/local/mysql下的文件:
[root @ogg  mysql]# cd /usr/local/mysql
[root @ogg  mysql]# ls
bin      data  include         lib  mysql- 5.6 . 4 -m7  README   share      support-files
COPYING  docs  INSTALL-BINARY  man  mysql-test      scripts  sql-bench
[root @ogg  mysql]# rm -rf mysql- 5.6 . 4 -m7/
[root @ogg  mysql]# rm -rf *

卸载完成!

2、安装mysql-5.5

1
2
3
4
5
6
7
[root@ogg mysql]# ls
[root@ogg mysql]# cd /home/oracle/mysql -5.5. 12
[root@ogg mysql -5.5. 12 ]# ls
BUILD        CMakeLists.txt   COPYING  include             libmysqld    mysys      regex      sql-common     tests     win
BUILD-CMAKE  cmd-line-utils   dbug     INSTALL-SOURCE      libservices  packaging  scripts    storage        unittest  zlib
client       config.h.cmake   Docs     INSTALL-WIN-SOURCE  man          plugin     sql        strings        VERSION
cmake        configure.cmake  extra    libmysql            mysql-test   README     sql-bench  support-files  vio

源码安装,检查编译环境:

[root@ogg mysql-5.5.12]# cmake ./

1
2
3
4
5
6
7
8
9
10
11
12
13
14
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check  for  working C compiler: /usr/bin/gcc
-- Check  for  working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check  for  working CXX compiler: /usr/bin/c++
-- Check  for  working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking  for  SHM_HUGETLB
-- Looking  for  SHM_HUGETLB - found
-- MySQL  5.5. 12
……

编译:

[root@ogg mysql-5.5.12]# make

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Scanning dependencies of target INFO_BIN
[   0 %] Built target INFO_BIN
Scanning dependencies of target INFO_SRC
[   0 %] Built target INFO_SRC
Scanning dependencies of target abi_check
[   0 %] Built target abi_check
[   0 %] Generating common.h
[   0 %] Generating help.c
[   0 %] Generating help.h
[   0 %] Generating vi.h
[   1 %] Generating emacs.h
[   1 %] Generating fcns.c
[   1 %] Generating fcns.h
Scanning dependencies of target edit
[   1 %] Building C object cmd-line-utils/libedit/CMakeFiles/edit.dir/chared.c.o
[   1 %] Building C object cmd-line-utils/libedit/CMakeFiles/edit.dir/el.c.o
[   1 %] Building C object cmd-line-utils/libedit/CMakeFiles/edit.dir/history.c.o
……
Linking CXX  static  library libsql.a
[ 100 %] Built target sql
Scanning dependencies of target mysqld
[ 100 %] Building CXX object sql/CMakeFiles/mysqld.dir/main.cc.o
Linking CXX executable mysqld
[ 100 %] Built target mysqld
Scanning dependencies of target udf_example
[ 100 %] Building C object sql/CMakeFiles/udf_example.dir/udf_example.c.o
Linking C shared module udf_example.so
[ 100 %] Built target udf_example
Scanning dependencies of target my_safe_process
[ 100 %] Building CXX object mysql-test/lib/My/SafeProcess/CMakeFiles/my_safe_process.dir/safe_process.cc.o
Linking CXX executable my_safe_process
[ 100 %] Built target my_safe_process

安装软件:

[root@ogg mysql-5.5.12]# make install

1
2
3
4
5
6
7
8
9
10
11
12
13
  Installing: /usr/local/mysql/mysql-test/./include/have_binlog_format_row.inc
-- Installing: /usr/local/mysql/mysql-test/./include/ assert .inc
-- Installing: /usr/local/mysql/mysql-test/./include/gis_keys.inc
-- Installing: /usr/local/mysql/mysql-test/./include/implicit_commit_helper.inc
-- Installing: /usr/local/mysql/mysql-test/./include/stop_slave_sql.inc
-- Installing: /usr/local/mysql/mysql-test/./include/have_ucs2.inc
-- Installing: /usr/local/mysql/mysql-test/./include/get_binlog_dump_thread_id.inc
-- Installing: /usr/local/mysql/mysql-test/./include/index_merge_ror_cpk.inc
-- Installing: /usr/local/mysql/mysql-test/./include/linux_sys_vars.inc
-- Installing: /usr/local/mysql/mysql-test/./include/ctype_czech.inc
-- Installing: /usr/local/mysql/mysql-test/./include/have_binlog_format_statement.inc
-- Installing: /usr/local/mysql/mysql-test/./include/mix2.inc
……

3、初始化和配置数据库

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
[root@ogg mysql]# cd /usr/local/mysql
[root@ogg mysql]# ls
bin  COPYING  data  docs  include  INSTALL-BINARY  lib  man  mysql-test  README  scripts  share  sql-bench  support-files
 
[root@ogg mysql]# chown -R mysql:mysql .
[root@ogg mysql]# ls -l
total  76
drwxr-sr-x   2  mysql mysql   4096  Sep  29  15 : 32  bin
-rw-r--r--   1  mysql mysql  17987  Apr  11   2011  COPYING
drwxr-sr-x   4  mysql mysql   4096  Sep  29  15 : 32  data
drwxr-xr-x   2  mysql mysql   4096  Sep  29  15 : 32  docs
drwxr-sr-x   3  mysql mysql   4096  Sep  29  15 : 32  include
-rw-r--r--   1  mysql mysql   7370  Apr  11   2011  INSTALL-BINARY
drwxr-sr-x   3  mysql mysql   4096  Sep  29  15 : 32  lib
drwxr-sr-x   4  mysql mysql   4096  Sep  29  15 : 32  man
drwxr-xr-x  10  mysql mysql   4096  Sep  29  15 : 32  mysql-test
-rw-r--r--   1  mysql mysql   2552  Apr  11   2011  README
drwxr-sr-x   2  mysql mysql   4096  Sep  29  15 : 32  scripts
drwxr-sr-x  27  mysql mysql   4096  Sep  29  15 : 32  share
drwxr-sr-x   4  mysql mysql   4096  Sep  29  15 : 32  sql-bench
drwxr-sr-x   2  mysql mysql   4096  Sep  29  15 : 32  support-files
 
初始化数据库:
[root@ogg mysql]# scripts/mysql_install_db --user=mysql
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld  at  boot time you have to copy
support-files/mysql.server to the right place  for  your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server,  then  issue the following commands:
./bin/mysqladmin -u root password  'new-password'
./bin/mysqladmin -u root -h ogg password  'new-password'
Alternatively you can run:
./bin/mysql_secure_installation
which will also give you the option of removing the test
databases  and  anonymous user created by default.  This is
strongly recommended  for  production servers.
See the manual  for  more instructions.
You can start the MySQL daemon  with :
cd . ; ./bin/mysqld_safe &
You can test the MySQL daemon  with  mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl
Please report any problems  with  the ./bin/mysqlbug script!
 
[root@ogg mysql]# chown -R mysql:mysql ./data
[root@ogg mysql]# chmod -R ug+rws .
 
配置数据库:
[root@ogg mysql]# vi /etc/my.cnf
[mysqld]
port            =  3306
socket          = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache =  64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
user=mysql
datadir=/ var /lib/mysql
default-storage-engine=MyISAM

四、启动并访问数据库

[root@ogg mysql]# bin/mysqld_safe --user=mysql &

1
2
[root@ogg mysql]#  140929  15 : 39 : 15  mysqld_safe Logging to  '/var/lib/mysql/ogg.err' .
140929  15 : 39 : 15  mysqld_safe Starting mysqld daemon  with  databases  from  / var /lib/mysql

日志信息:

[root@ogg mysql]# more /var/lib/mysql/ogg.err

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
140929  15 : 39 : 15  mysqld_safe Starting mysqld daemon  with  databases  from  / var /lib/mysql
140929  15 : 39 : 15  InnoDB: The InnoDB memory heap is disabled
140929  15 : 39 : 15  InnoDB: Mutexes  and  rw_locks use GCC atomic builtins
140929  15 : 39 : 15  InnoDB: Compressed tables use zlib  1.2. 3
140929  15 : 39 : 15  InnoDB: Using Linux native AIO
140929  15 : 39 : 15  InnoDB: Initializing buffer pool, size =  128. 0M
140929  15 : 39 : 15  InnoDB: Completed initialization of buffer pool
InnoDB: The  first  specified data file ./ibdata1 did  not  exist:
InnoDB: a  new  database to be created!
140929  15 : 39 : 15   InnoDB: Setting file ./ibdata1 size to  10  MB
InnoDB: Database physically writes the file full: wait...
140929  15 : 39 : 15   InnoDB: Log file ./ib_logfile0 did  not  exist:  new  to be created
InnoDB: Setting log file ./ib_logfile0 size to  5  MB
InnoDB: Database physically writes the file full: wait...
140929  15 : 39 : 15   InnoDB: Log file ./ib_logfile1 did  not  exist:  new  to be created
InnoDB: Setting log file ./ib_logfile1 size to  5  MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer  not  found: creating  new
InnoDB: Doublewrite buffer created
InnoDB:  127  rollback segment(s) active.
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
140929  15 : 39 : 15   InnoDB: Waiting  for  the background threads to start
140929  15 : 39 : 16  InnoDB:  1.1. 6  started; log sequence number  0
140929  15 : 39 : 16  [Note] Event Scheduler: Loaded  0  events
140929  15 : 39 : 16  [Note] /usr/local/mysql/bin/mysqld: ready  for  connections.
Version:  '5.5.12-log'   socket:  '/tmp/mysql.sock'   port:  3306   Source distribution
[root@ogg mysql]# ls / var /lib/mysql
ibdata1      ib_logfile1  mysql-bin .000001   mysql-bin .000003   ogg.err  performance_schema
ib_logfile0  mysql        mysql-bin .000002   mysql-bin.index   ogg.pid  test

查看server启动信息:

[root@ogg mysql]# netstat -an |grep 3306

tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN

访问数据库:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
修改root用户口令
[root @ogg  mysql]# bin/mysqladmin -u root password
New password:
Confirm  new  password:
 
连接数据库
[root @ogg  mysql]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is  3
Server version:  5.5 . 12 -log Source distribution
Copyright (c)  2000 2010 , Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type  'help;'  or  '\h'  for  help. Type  '\c'  to clear the current input statement.
mysql> use mysql;
Database changed
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4  rows in set ( 0.00  sec)
mysql>
 
配置server启动脚本
[root @ogg  mysql]# cp support-files/mysql.server  /etc/init.d/mysql
cp: overwrite `/etc/init.d/mysql'? y
 
[root @ogg  mysql]# service mysql stop
Shutting down MySQL. 140929  15 : 43 : 39  mysqld_safe mysqld from pid file /var/lib/mysql/ogg.pid ended
                                                            [  OK  ]
[ 1 ]+  Done                    bin/mysqld_safe --user=mysql
 
[root @ogg  mysql]# service mysql start
Starting MySQL..                                           [  OK  ]
[root @ogg  mysql]# netstat -an |grep  3306
tcp         0       0  0.0 . 0.0 : 3306                 0.0 . 0.0 :*                   LISTEN

@至此,mysql安装成功!











本文转自 客居天涯 51CTO博客,原文链接:http://blog.51cto.com/tiany/1559491,如需转载请自行联系原作者
相关实践学习
如何快速连接云数据库RDS MySQL
本场景介绍如何通过阿里云数据管理服务DMS快速连接云数据库RDS MySQL,然后进行数据表的CRUD操作。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
打赏
0
0
0
0
235
分享
相关文章
源码编译安装LAMP(HTTP服务,MYSQL ,PHP,以及bbs论坛)
通过以上步骤,你可以成功地在一台Linux服务器上从源码编译并安装LAMP环境,并配置一个BBS论坛(Discuz!)。这些步骤涵盖了从安装依赖、下载源代码、配置编译到安装完成的所有细节。每个命令的解释确保了过程的透明度,使即使是非专业人士也能够理解整个流程。
34 18
Docker Compose V2 安装常用数据库MySQL+Mongo
以上内容涵盖了使用 Docker Compose 安装和管理 MySQL 和 MongoDB 的详细步骤,希望对您有所帮助。
183 42
CentOS7仅安装部署MySQL80客户端
通过上述步骤,你可以在CentOS 7上成功安装并配置MySQL 8.0客户端。这个过程确保你能够使用MySQL客户端工具连接和管理远程的MySQL数据库,而不需要在本地安装MySQL服务器。定期更新MySQL客户端可以确保你使用的是最新的功能和安全修复。
293 16
【MySQL基础篇】全面学习总结SQL语法、DataGrip安装教程
本文详细介绍了MySQL中的SQL语法,包括数据定义(DDL)、数据操作(DML)、数据查询(DQL)和数据控制(DCL)四个主要部分。内容涵盖了创建、修改和删除数据库、表以及表字段的操作,以及通过图形化工具DataGrip进行数据库管理和查询。此外,还讲解了数据的增、删、改、查操作,以及查询语句的条件、聚合函数、分组、排序和分页等知识点。
【MySQL基础篇】全面学习总结SQL语法、DataGrip安装教程
【MySQL基础篇】MySQL概述、Windows下载MySQL8.0超详细图文安装教程
在这一章节,主要介绍两个部分,数据库相关概念及MySQL数据库的介绍、下载、安装、启动及连接。接着,详细描述了MySQL 8.0的版本选择与下载,推荐使用社区版(免费)。安装过程包括自定义安装路径、配置环境变量、启动和停止服务、以及客户端连接测试。此外,还提供了在同一台电脑上安装多个MySQL版本的方法及卸载步骤。最后,解释了关系型数据库(RDBMS)的特点,即基于二维表存储数据,使用SQL语言进行操作,格式统一且便于维护。通过具体的结构图展示了MySQL的数据模型,说明了数据库服务器、数据库、表和记录之间的层次关系。
【MySQL基础篇】MySQL概述、Windows下载MySQL8.0超详细图文安装教程
《docker高级篇(大厂进阶):1.Docker复杂安装详说》包括:安装mysql主从复制、安装redis集群
《docker高级篇(大厂进阶):1.Docker复杂安装详说》包括:安装mysql主从复制、安装redis集群
146 14
《docker基础篇:8.Docker常规安装简介》包括:docker常规安装总体步骤、安装tomcat、安装mysql、安装redis
《docker基础篇:8.Docker常规安装简介》包括:docker常规安装总体步骤、安装tomcat、安装mysql、安装redis
161 7
Windows Server 安装 MySQL 8.0 详细指南
安装 MySQL 需要谨慎,特别注意安全配置和权限管理。根据实际业务需求调整配置,确保数据库的性能和安全。
395 9
缓存与数据库的一致性方案,Redis与Mysql一致性方案,大厂P8的终极方案(图解+秒懂+史上最全)
缓存与数据库的一致性方案,Redis与Mysql一致性方案,大厂P8的终极方案(图解+秒懂+史上最全)