Mysql学习之--卸载源码mysql-5.6安装mysql-5.5
系统环境:
操作系统:RedHat EL6
DB Soft: Mysql 5.5.12
Mysql 在linux下的安装方式有两种版本,一种为Binary(二进制),另外一种为Source(源码包),本文为Source Install方式。
由于,本机已经安装了mysql-5.6的版本,前面的版本采用源码包安装,只需要删除相应的安装文件即可!
1、卸载mysql-5.6
删除/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
[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 ./
-- 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
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
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、初始化和配置数据库
[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 &
[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
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
访问数据库:
修改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安装成功!
本文出自 “天涯客的blog” 博客,请务必保留此出处http://tiany.blog.51cto.com/513694/1559491