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

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
云数据库 RDS MySQL Serverless,价值2615元额度,1个月
简介:

系统环境

操作系统: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,如需转载请自行联系原作者
相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
1天前
|
关系型数据库 MySQL Linux
本地虚拟机centos7通过docker安装主从mysql5.7.21
本地虚拟机centos7通过docker安装主从mysql5.7.21
|
3天前
|
关系型数据库 MySQL 数据库
龙蜥操作系统上安装MySQL:步骤详解与常见问题解决
龙蜥操作系统上安装MySQL:步骤详解与常见问题解决
|
3天前
|
关系型数据库 MySQL Linux
在Centos7中:通过Docker安装MySQL5.7(保姆级)
在Centos7中:通过Docker安装MySQL5.7(保姆级)
|
3天前
|
存储 关系型数据库 MySQL
学习MySQL(5.7)第二战:四大引擎、账号管理以及建库(干货满满)
学习MySQL(5.7)第二战:四大引擎、账号管理以及建库(干货满满)
|
3天前
|
编解码 安全 关系型数据库
祝福CSDN的小伙伴2024年快乐!Windows7安装MySQL
祝福CSDN的小伙伴2024年快乐!Windows7安装MySQL
|
4天前
|
传感器 人工智能 前端开发
JAVA语言VUE2+Spring boot+MySQL开发的智慧校园系统源码(电子班牌可人脸识别)Saas 模式
智慧校园电子班牌,坐落于班级的门口,适合于各类型学校的场景应用,班级学校日常内容更新可由班级自行管理,也可由学校统一管理。让我们一起看看,电子班牌有哪些功能呢?
45 4
JAVA语言VUE2+Spring boot+MySQL开发的智慧校园系统源码(电子班牌可人脸识别)Saas 模式
|
5天前
|
关系型数据库 MySQL Linux
Linux CentOs7 安装Mysql(5.7和8.0版本)密码修改 超详细教程
Linux CentOs7 安装Mysql(5.7和8.0版本)密码修改 超详细教程
|
5天前
|
安全 关系型数据库 MySQL
MySQL安装教程
MySQL安装教程
29 0
|
1天前
|
关系型数据库 MySQL 数据库
docker MySQL删除数据库时的错误(errno: 39)
docker MySQL删除数据库时的错误(errno: 39)
|
1天前
|
关系型数据库 MySQL 数据库连接
用Navicat备份Mysql演示系统数据库的时候出:Too Many Connections
用Navicat备份Mysql演示系统数据库的时候出:Too Many Connections

推荐镜像

更多