Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6318130
  • 博文数量: 2759
  • 博客积分: 1021
  • 博客等级: 中士
  • 技术积分: 4091
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-11 14:14
文章分类

全部博文(2759)

文章存档

2019年(1)

2017年(84)

2016年(196)

2015年(204)

2014年(636)

2013年(1176)

2012年(463)

分类: Mysql/postgreSQL

2014-07-31 01:28:25

原文地址:linux下安装mysql 作者:hxl

环境:
OS:Linux As 5
mysql:5.6
 


1.
下载跟OS相应的版本

[root@node2 soft]# uname -a

Linux node2 2.6.18-274.el5 #1 SMP Fri Jul 8 17:36:59 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
 
我这里是64位的linux,所有相应的下载64位的mysql

MySQL-5.6.19-1.rhel5.x86_64.rpm-bundle.tar
 

2.解压缩tar

[root@node2 soft]# tar -xvf MySQL-5.6.19-1.rhel5.x86_64.rpm-bundle.tar

MySQL-client-5.6.19-1.rhel5.x86_64.rpm

MySQL-devel-5.6.19-1.rhel5.x86_64.rpm

MySQL-shared-compat-5.6.19-1.rhel5.x86_64.rpm

MySQL-embedded-5.6.19-1.rhel5.x86_64.rpm

MySQL-test-5.6.19-1.rhel5.x86_64.rpm

MySQL-shared-5.6.19-1.rhel5.x86_64.rpm

MySQL-server-5.6.19-1.rhel5.x86_64.rpm

加压缩后这里有好几个rpm,其实我们只要安装如下两个包即可

MySQL-server-5.6.19-1.rhel5.x86_64.rpm

MySQL-client-5.6.19-1.rhel5.x86_64.rpm

 

3. 创建MySql系统管理用户

[root@node2 soft]# groupadd mysql

[root@node2 soft]# useradd -g mysql mysql

[root@node2 ~]# passwd mysql

Changing password for user mysql.

New UNIX password:

BAD PASSWORD: it is too short

Retype new UNIX password:

passwd: all authentication tokens updated successfully.

 

4. 安装mysql rpm

这里我们只安装如下两个包

MySQL-server-5.6.19-1.rhel5.x86_64.rpm

MySQL-client-5.6.19-1.rhel5.x86_64.rpm

查看rpm安装的路径,因为以后我们通过mysql账号管理mysql,所以需要将相应的目录属主赋予给mysql账号

[root@node2 soft]# rpm -pql MySQL-server-5.6.19-1.rhel5.x86_64.rpm

/etc/init.d/mysql

/etc/logrotate.d/mysql

/etc/my.cnf

/usr/bin/innochecksum

/usr/bin/my_print_defaults

/usr/bin/myisam_ftdump

/usr/bin/myisamchk

/usr/bin/myisamlog

/usr/bin/myisampack

/usr/bin/mysql_convert_table_format

/usr/bin/mysql_fix_extensions

/usr/bin/mysql_install_db

/usr/bin/mysql_plugin

/usr/bin/mysql_secure_installation

/usr/bin/mysql_setpermission

/usr/bin/mysql_tzinfo_to_sql

/usr/bin/mysql_upgrade

/usr/bin/mysql_zap

/usr/bin/mysqlbug

/usr/bin/mysqld_multi

/usr/bin/mysqld_safe

/usr/bin/mysqldumpslow

/usr/bin/mysqlhotcopy

/usr/bin/mysqltest

/usr/bin/perror

/usr/bin/replace

/usr/bin/resolve_stack_dump

/usr/bin/resolveip

/usr/lib64/mysql/libtcmalloc_minimal.so

/usr/lib64/mysql/plugin/adt_null.so

/usr/lib64/mysql/plugin/auth.so

/usr/lib64/mysql/plugin/auth_socket.so

/usr/lib64/mysql/plugin/auth_test_plugin.so

/usr/lib64/mysql/plugin/daemon_example.ini

/usr/lib64/mysql/plugin/debug/adt_null.so

/usr/lib64/mysql/plugin/debug/auth.so

/usr/lib64/mysql/plugin/debug/auth_socket.so

/usr/lib64/mysql/plugin/debug/auth_test_plugin.so

/usr/lib64/mysql/plugin/debug/innodb_engine.so

/usr/lib64/mysql/plugin/debug/libdaemon_example.so

/usr/lib64/mysql/plugin/debug/libmemcached.so

/usr/lib64/mysql/plugin/debug/mypluglib.so

/usr/lib64/mysql/plugin/debug/qa_auth_client.so

/usr/lib64/mysql/plugin/debug/qa_auth_interface.so

/usr/lib64/mysql/plugin/debug/qa_auth_server.so

/usr/lib64/mysql/plugin/debug/semisync_master.so

/usr/lib64/mysql/plugin/debug/semisync_slave.so

/usr/lib64/mysql/plugin/debug/validate_password.so

/usr/lib64/mysql/plugin/innodb_engine.so

/usr/lib64/mysql/plugin/libdaemon_example.so

/usr/lib64/mysql/plugin/libmemcached.so

/usr/lib64/mysql/plugin/mypluglib.so

/usr/lib64/mysql/plugin/qa_auth_client.so

/usr/lib64/mysql/plugin/qa_auth_interface.so

/usr/lib64/mysql/plugin/qa_auth_server.so

/usr/lib64/mysql/plugin/semisync_master.so

/usr/lib64/mysql/plugin/semisync_slave.so

/usr/lib64/mysql/plugin/validate_password.so

/usr/sbin/mysqld

/usr/sbin/mysqld-debug

/usr/sbin/rcmysql

/usr/share/doc/MySQL-server-5.6.19

/usr/share/doc/MySQL-server-5.6.19/COPYING

/usr/share/doc/MySQL-server-5.6.19/ChangeLog

/usr/share/doc/MySQL-server-5.6.19/INFO_BIN

/usr/share/doc/MySQL-server-5.6.19/INFO_SRC

/usr/share/doc/MySQL-server-5.6.19/README

/usr/share/doc/MySQL-server-5.6.19/my-default.cnf

/usr/share/man/man1/innochecksum.1.gz

/usr/share/man/man1/my_print_defaults.1.gz

/usr/share/man/man1/myisam_ftdump.1.gz

/usr/share/man/man1/myisamchk.1.gz

/usr/share/man/man1/myisamlog.1.gz

/usr/share/man/man1/myisampack.1.gz

/usr/share/man/man1/mysql.server.1.gz

/usr/share/man/man1/mysql_convert_table_format.1.gz

/usr/share/man/man1/mysql_fix_extensions.1.gz

/usr/share/man/man1/mysql_install_db.1.gz

/usr/share/man/man1/mysql_plugin.1.gz

/usr/share/man/man1/mysql_secure_installation.1.gz

/usr/share/man/man1/mysql_setpermission.1.gz

/usr/share/man/man1/mysql_tzinfo_to_sql.1.gz

/usr/share/man/man1/mysql_upgrade.1.gz

/usr/share/man/man1/mysql_zap.1.gz

/usr/share/man/man1/mysqlbug.1.gz

/usr/share/man/man1/mysqld_multi.1.gz

/usr/share/man/man1/mysqld_safe.1.gz

/usr/share/man/man1/mysqldumpslow.1.gz

/usr/share/man/man1/mysqlhotcopy.1.gz

/usr/share/man/man1/mysqlman.1.gz

/usr/share/man/man1/mysqltest.1.gz

/usr/share/man/man1/perror.1.gz

/usr/share/man/man1/replace.1.gz

/usr/share/man/man1/resolve_stack_dump.1.gz

/usr/share/man/man1/resolveip.1.gz

/usr/share/man/man8/mysqld.8.gz

/usr/share/mysql

/usr/share/mysql/SELinux

/usr/share/mysql/SELinux/RHEL4

/usr/share/mysql/SELinux/RHEL4/mysql.fc

/usr/share/mysql/SELinux/RHEL4/mysql.te

/usr/share/mysql/binary-configure

/usr/share/mysql/bulgarian

/usr/share/mysql/bulgarian/errmsg.sys

/usr/share/mysql/charsets

/usr/share/mysql/charsets/Index.xml

/usr/share/mysql/charsets/README

/usr/share/mysql/charsets/armscii8.xml

/usr/share/mysql/charsets/ascii.xml

/usr/share/mysql/charsets/cp1250.xml

/usr/share/mysql/charsets/cp1251.xml

/usr/share/mysql/charsets/cp1256.xml

/usr/share/mysql/charsets/cp1257.xml

/usr/share/mysql/charsets/cp850.xml

/usr/share/mysql/charsets/cp852.xml

/usr/share/mysql/charsets/cp866.xml

/usr/share/mysql/charsets/dec8.xml

/usr/share/mysql/charsets/geostd8.xml

/usr/share/mysql/charsets/greek.xml

/usr/share/mysql/charsets/hebrew.xml

/usr/share/mysql/charsets/hp8.xml

/usr/share/mysql/charsets/keybcs2.xml

/usr/share/mysql/charsets/koi8r.xml

/usr/share/mysql/charsets/koi8u.xml

/usr/share/mysql/charsets/latin1.xml

/usr/share/mysql/charsets/latin2.xml

/usr/share/mysql/charsets/latin5.xml

/usr/share/mysql/charsets/latin7.xml

/usr/share/mysql/charsets/macce.xml

/usr/share/mysql/charsets/macroman.xml

/usr/share/mysql/charsets/swe7.xml

/usr/share/mysql/czech

/usr/share/mysql/czech/errmsg.sys

/usr/share/mysql/danish

/usr/share/mysql/danish/errmsg.sys

/usr/share/mysql/dictionary.txt

/usr/share/mysql/dutch

/usr/share/mysql/dutch/errmsg.sys

/usr/share/mysql/english

/usr/share/mysql/english/errmsg.sys

/usr/share/mysql/errmsg-utf8.txt

/usr/share/mysql/estonian

/usr/share/mysql/estonian/errmsg.sys

/usr/share/mysql/fill_help_tables.sql

/usr/share/mysql/french

/usr/share/mysql/french/errmsg.sys

/usr/share/mysql/german

/usr/share/mysql/german/errmsg.sys

/usr/share/mysql/greek

/usr/share/mysql/greek/errmsg.sys

/usr/share/mysql/hungarian

/usr/share/mysql/hungarian/errmsg.sys

/usr/share/mysql/innodb_memcached_config.sql

/usr/share/mysql/italian

/usr/share/mysql/italian/errmsg.sys

/usr/share/mysql/japanese

/usr/share/mysql/japanese/errmsg.sys

/usr/share/mysql/korean

/usr/share/mysql/korean/errmsg.sys

/usr/share/mysql/magic

/usr/share/mysql/my-default.cnf

/usr/share/mysql/mysql-log-rotate

/usr/share/mysql/mysql.server

/usr/share/mysql/mysql_security_commands.sql

/usr/share/mysql/mysql_system_tables.sql

/usr/share/mysql/mysql_system_tables_data.sql

/usr/share/mysql/mysql_test_data_timezone.sql

/usr/share/mysql/mysqld_multi.server

/usr/share/mysql/norwegian

/usr/share/mysql/norwegian-ny

/usr/share/mysql/norwegian-ny/errmsg.sys

/usr/share/mysql/norwegian/errmsg.sys

/usr/share/mysql/polish

/usr/share/mysql/polish/errmsg.sys

/usr/share/mysql/portuguese

/usr/share/mysql/portuguese/errmsg.sys

/usr/share/mysql/romanian

/usr/share/mysql/romanian/errmsg.sys

/usr/share/mysql/russian

/usr/share/mysql/russian/errmsg.sys

/usr/share/mysql/serbian

/usr/share/mysql/serbian/errmsg.sys

/usr/share/mysql/slovak

/usr/share/mysql/slovak/errmsg.sys

/usr/share/mysql/spanish

/usr/share/mysql/spanish/errmsg.sys

/usr/share/mysql/swedish

/usr/share/mysql/swedish/errmsg.sys

/usr/share/mysql/ukrainian

/usr/share/mysql/ukrainian/errmsg.sys

[root@node2 soft]# rpm -qpl MySQL-client-5.6.19-1.rhel5.x86_64.rpm

/usr/bin/msql2mysql

/usr/bin/mysql

/usr/bin/mysql_config_editor

/usr/bin/mysql_find_rows

/usr/bin/mysql_waitpid

/usr/bin/mysqlaccess

/usr/bin/mysqlaccess.conf

/usr/bin/mysqladmin

/usr/bin/mysqlbinlog

/usr/bin/mysqlcheck

/usr/bin/mysqldump

/usr/bin/mysqlimport

/usr/bin/mysqlshow

/usr/bin/mysqlslap

/usr/share/man/man1/msql2mysql.1.gz

/usr/share/man/man1/mysql.1.gz

/usr/share/man/man1/mysql_config_editor.1.gz

/usr/share/man/man1/mysql_find_rows.1.gz

/usr/share/man/man1/mysql_waitpid.1.gz

/usr/share/man/man1/mysqlaccess.1.gz

/usr/share/man/man1/mysqladmin.1.gz

/usr/share/man/man1/mysqlbinlog.1.gz

/usr/share/man/man1/mysqlcheck.1.gz

/usr/share/man/man1/mysqldump.1.gz

/usr/share/man/man1/mysqlimport.1.gz

/usr/share/man/man1/mysqlshow.1.gz

/usr/share/man/man1/mysqlslap.1.gz

安装rpm

[root@node2 soft]# rpm -ivh MySQL-server-5.6.19-1.rhel5.x86_64.rpm

Preparing...                ########################################### [100%]

   1:MySQL-server           ########################################### [100%]

2014-07-29 11:30:06 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2014-07-29 11:30:06 12606 [Note] InnoDB: Using atomics to ref count buffer pool pages

2014-07-29 11:30:06 12606 [Note] InnoDB: The InnoDB memory heap is disabled

2014-07-29 11:30:06 12606 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2014-07-29 11:30:06 12606 [Note] InnoDB: Compressed tables use zlib 1.2.3

2014-07-29 11:30:06 12606 [Note] InnoDB: Using Linux native AIO

2014-07-29 11:30:06 12606 [Note] InnoDB: Not using CPU crc32 instructions

2014-07-29 11:30:06 12606 [Note] InnoDB: Initializing buffer pool, size = 128.0M

2014-07-29 11:30:06 12606 [Note] InnoDB: Completed initialization of buffer pool

2014-07-29 11:30:06 12606 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!

2014-07-29 11:30:06 12606 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB

2014-07-29 11:30:06 12606 [Note] InnoDB: Database physically writes the file full: wait...

2014-07-29 11:30:08 12606 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB

2014-07-29 11:30:09 12606 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB

2014-07-29 11:30:10 12606 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0

2014-07-29 11:30:10 12606 [Warning] InnoDB: New log files created, LSN=45781

2014-07-29 11:30:10 12606 [Note] InnoDB: Doublewrite buffer not found: creating new

2014-07-29 11:30:11 12606 [Note] InnoDB: Doublewrite buffer created

2014-07-29 11:30:11 12606 [Note] InnoDB: 128 rollback segment(s) are active.

2014-07-29 11:30:11 12606 [Warning] InnoDB: Creating foreign key constraint system tables.

2014-07-29 11:30:11 12606 [Note] InnoDB: Foreign key constraint system tables created

2014-07-29 11:30:11 12606 [Note] InnoDB: Creating tablespace and datafile system tables.

2014-07-29 11:30:11 12606 [Note] InnoDB: Tablespace and datafile system tables created.

2014-07-29 11:30:11 12606 [Note] InnoDB: Waiting for purge to start

2014-07-29 11:30:11 12606 [Note] InnoDB: 5.6.19 started; log sequence number 0

A random root password has been set. You will find it in '/root/.mysql_secret'.

2014-07-29 11:30:13 12606 [Note] Binlog end

2014-07-29 11:30:13 12606 [Note] InnoDB: FTS optimize thread exiting.

2014-07-29 11:30:13 12606 [Note] InnoDB: Starting shutdown...

2014-07-29 11:30:14 12606 [Note] InnoDB: Shutdown completed; log sequence number 1625977

2014-07-29 11:30:15 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2014-07-29 11:30:15 12630 [Note] InnoDB: Using atomics to ref count buffer pool pages

2014-07-29 11:30:15 12630 [Note] InnoDB: The InnoDB memory heap is disabled

2014-07-29 11:30:15 12630 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2014-07-29 11:30:15 12630 [Note] InnoDB: Compressed tables use zlib 1.2.3

2014-07-29 11:30:15 12630 [Note] InnoDB: Using Linux native AIO

2014-07-29 11:30:15 12630 [Note] InnoDB: Not using CPU crc32 instructions

2014-07-29 11:30:15 12630 [Note] InnoDB: Initializing buffer pool, size = 128.0M

2014-07-29 11:30:15 12630 [Note] InnoDB: Completed initialization of buffer pool

2014-07-29 11:30:15 12630 [Note] InnoDB: Highest supported file format is Barracuda.

2014-07-29 11:30:15 12630 [Note] InnoDB: 128 rollback segment(s) are active.

2014-07-29 11:30:15 12630 [Note] InnoDB: Waiting for purge to start

2014-07-29 11:30:15 12630 [Note] InnoDB: 5.6.19 started; log sequence number 1625977

2014-07-29 11:30:15 12630 [Note] Binlog end

2014-07-29 11:30:15 12630 [Note] InnoDB: FTS optimize thread exiting.

2014-07-29 11:30:15 12630 [Note] InnoDB: Starting shutdown...

2014-07-29 11:30:17 12630 [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'.

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

The latest information about MySQL is available on the web at

 

Support MySQL by buying support/licenses at

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

安装完成后,root账号的随机密码保留在/root/.mysql_secret文件中,等会我们登陆的时候会用到这个随机密码.

[root@node2 soft]# rpm -ivh MySQL-client-5.6.19-1.rhel5.x86_64.rpm

Preparing...                ########################################### [100%]

   1:MySQL-client           ########################################### [100%]


 

5.使用root用户登陆修改密码

获取root密码

[root@node2 soft]# more /root/.mysql_secret

# The random password set for the root user at Tue Jul 29 11:30:12 2014 (local time): fUKrlXCOc6iHiKKx

启动mysql

[root@node2 soft]# service mysql start

Starting MySQL.........................[  OK  ]

[root@node2 soft]# mysql -h node2 -uroot -pfUKrlXCOc6iHiKKx

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 1

Server version: 5.6.19

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> set password=password('mysql');

Query OK, 0 rows affected (0.09 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.06 sec)


 

6. 修改安装目录权限

[root@node2 mysql]# chown -R mysql:mysql /usr/share/mysql

[root@node2 mysql]# chown -R mysql:mysql /var/lib/mysql


7. mysql添加环境变量

[mysql@node2 ~]$ more .bash_profile

# .bash_profile

# Get the aliases and functions

if [ -f ~/.bashrc ]; then

        . ~/.bashrc

fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH

export LANG=zh_CN

export DATADIR=/var/lib/mysql

export MYSQL_HOME=/usr/share/mysql

8.停止启动mysql

停止mysql

[mysql@node2 ~]$ mysqladmin -h node2 -uroot -p shutdown

启动mysql

[mysql@node2 ~]$ /usr/share/mysql/mysql.server start --user=mysql

Starting MySQL...[  OK  ]

或是

[mysql@node2 ~]$/usr/bin/mysqld_safe --user=mysql &


 -- The End --

阅读(1458) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~