mysql的三种安装方法

回复 收藏

最近在CentOS 5.10上安装最新版的mysql5.6.21时遇到了麻烦。于是将mysql文档中的关于如何在Linux上安装mysql的部分仔细的读了一遍。总结起来在CentOS或者Red Hat上安装mysql可以有三种方式:1)使用rpm -ivh ...或者 yum install ... (一般推荐使用rpm来安装)2)使用编译好的通用二进制版本的mysql来安装(Generic Binaries mysql) (在方法一失败时,可以使用方法2来安装)3)使用源码来编译安装。1. 在CentOS 5.10上安装最新版的mysql5.6.21时遇到的麻烦2. Installing MySQL on Unix/Linux Using Generic Binaries(使用通用二进制版本的mysql来安装)    当使用rpm或者yum方法安装失败时,可以使用该方法进行安装。因为通用二进制版本对glibc等lib库的版本要求不是很高。所以使用这种方法,可以很好的解决:在低版本的CentOS上安装高版本的mysql。其安装方法如下。2.1 下载      打开网页:http://dev.mysql.com/downloads/mysql/      在Select Platform: 中选择 Linux - Generic       然后下载最下面的:mysql-5.6.21-linux-glibc2.5-i686.tar.gz (有64位的和32位的,选择自己需要的)2.2 安装     具体安装步骤,mysql文档中有详细说明:To install and user a MySQL binary distribution, the basic command sequence looks like this:shell> groupadd mysqlshell> useradd -r -g mysql mysqlshell> cd /usr/localshell> tar zxvf /path/to/mysql-VERSION-OS.tar.gzshell> ln -s full-path-to-mysql-VERSION-OSmysqlshell> cd mysqlshell> chown -R mysql .shell> chgrp -R mysql .shell> scripts/mysql_install_db --user=mysqlshell> chown -R root .shell> chown -R mysql datashell> bin/mysqld_safe --user=mysql &# Next command is optionalshell> cp support-files/mysql.server /etc/init.d/mysql.server我自己的安装过程如下:[root@localhost mysql]# groupadd mysql[root@localhost mysql]# useradd -r -g mysql mysql[root@localhost mysql]# cd /usr/local[root@localhost mysql]# tar zxvf /root/mysql-5.6.21-linux-glibc2.5-i686.tar.gz [root@localhost local]# lltotal 76drwxr-xr-x  2 root root 4096 Nov  7 05:43 bindrwxr-xr-x  2 root root 4096 May 11  2011 etcdrwxr-xr-x  2 root root 4096 May 11  2011 gamesdrwxr-xr-x  3 root root 4096 Nov  7 05:43 includedrwxr-xr-x  4 root root 4096 Nov  7 05:43 libdrwxr-xr-x  2 root root 4096 May 11  2011 libexecdrwxr-xr-x 13 root root 4096 Nov  7 20:42 mysql-5.6.21-linux-glibc2.5-i686drwxr-xr-x  2 root root 4096 May 11  2011 sbindrwxr-xr-x  4 root root 4096 Nov  7 01:15 sharedrwxr-xr-x  2 root root 4096 May 11  2011 src[root@localhost local]# pwd/usr/local[root@localhost local]# ln -s /usr/local/mysql-5.6.21-linux-glibc2.5-i686 mysql[root@localhost local]# cd mysql[root@localhost mysql]# chown -R mysql .[root@localhost mysql]# chgrp -R mysql .[root@localhost mysql]# scripts/mysql_install_db --user=mysqlInstalling MySQL system tables...2014-11-07 20:45:37 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explic                    it_defaults_for_timestamp server option (see documentation for more details).2014-11-07 20:45:37 4083 [Note] InnoDB: Using mutexes to ref count buffer pool pages2014-11-07 20:45:37 4083 [Note] InnoDB: The InnoDB memory heap is disabled2014-11-07 20:45:37 4083 [Note] InnoDB: Mutexes and rw_locks use InnoDB's own implementation2014-11-07 20:45:37 4083 [Note] InnoDB: Memory barrier is not used2014-11-07 20:45:37 4083 [Note] InnoDB: Compressed tables use zlib 1.2.32014-11-07 20:45:37 4083 [Note] InnoDB: Using Linux native AIO2014-11-07 20:45:37 4083 [Note] InnoDB: Not using CPU crc32 instructions2014-11-07 20:45:37 4083 [Note] InnoDB: Initializing buffer pool, size = 128.0M2014-11-07 20:45:37 4083 [Note] InnoDB: Completed initialization of buffer pool2014-11-07 20:45:37 4083 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!2014-11-07 20:45:37 4083 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB2014-11-07 20:45:37 4083 [Note] InnoDB: Database physically writes the file full: wait...2014-11-07 20:45:37 4083 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB2014-11-07 20:45:38 4083 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB2014-11-07 20:45:38 4083 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile02014-11-07 20:45:38 4083 [Warning] InnoDB: New log files created, LSN=457812014-11-07 20:45:38 4083 [Note] InnoDB: Doublewrite buffer not found: creating new2014-11-07 20:45:38 4083 [Note] InnoDB: Doublewrite buffer created2014-11-07 20:45:38 4083 [Note] InnoDB: 128 rollback segment(s) are active.2014-11-07 20:45:38 4083 [Warning] InnoDB: Creating foreign key constraint system tables.2014-11-07 20:45:39 4083 [Note] InnoDB: Foreign key constraint system tables created2014-11-07 20:45:39 4083 [Note] InnoDB: Creating tablespace and datafile system tables.2014-11-07 20:45:39 4083 [Note] InnoDB: Tablespace and datafile system tables created.2014-11-07 20:45:39 4083 [Note] InnoDB: Waiting for purge to start2014-11-07 20:45:39 4083 [Note] InnoDB: 5.6.21 started; log sequence number 02014-11-07 20:45:39 4083 [Note] Binlog end2014-11-07 20:45:39 4083 [Note] InnoDB: FTS optimize thread exiting.2014-11-07 20:45:39 4083 [Note] InnoDB: Starting shutdown...2014-11-07 20:45:41 4083 [Note] InnoDB: Shutdown completed; log sequence number 1625977OKFilling help tables...2014-11-07 20:45:41 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults                    _for_timestamp server option (see documentation for more details).2014-11-07 20:45:41 4105 [Note] InnoDB: Using mutexes to ref count buffer pool pages2014-11-07 20:45:41 4105 [Note] InnoDB: The InnoDB memory heap is disabled2014-11-07 20:45:41 4105 [Note] InnoDB: Mutexes and rw_locks use InnoDB's own implementation2014-11-07 20:45:41 4105 [Note] InnoDB: Memory barrier is not used2014-11-07 20:45:41 4105 [Note] InnoDB: Compressed tables use zlib 1.2.32014-11-07 20:45:41 4105 [Note] InnoDB: Using Linux native AIO2014-11-07 20:45:41 4105 [Note] InnoDB: Not using CPU crc32 instructions2014-11-07 20:45:41 4105 [Note] InnoDB: Initializing buffer pool, size = 128.0M2014-11-07 20:45:41 4105 [Note] InnoDB: Completed initialization of buffer pool2014-11-07 20:45:41 4105 [Note] InnoDB: Highest supported file format is Barracuda.2014-11-07 20:45:41 4105 [Note] InnoDB: 128 rollback segment(s) are active.2014-11-07 20:45:41 4105 [Note] InnoDB: Waiting for purge to start2014-11-07 20:45:41 4105 [Note] InnoDB: 5.6.21 started; log sequence number 16259772014-11-07 20:45:41 4105 [Note] Binlog end2014-11-07 20:45:41 4105 [Note] InnoDB: FTS optimize thread exiting.2014-11-07 20:45:41 4105 [Note] InnoDB: Starting shutdown...2014-11-07 20:45:43 4105 [Note] InnoDB: Shutdown completed; log sequence number 1625987OKTo start mysqld at boot time you have to copysupport-files/mysql.server to the right place for your systemPLEASE 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 localhost.localdomain password 'new-password'Alternatively you can run:  ./bin/mysql_secure_installationwhich will also give you the option of removing the testdatabases and anonymous user created by default.  This isstrongly 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.plPlease report any problems at http://bugs.mysql.com/The latest information about MySQL is available on the web at  http://www.mysql.comSupport MySQL by buying support/licenses at http://shop.mysql.comNew default config file was created as ./my.cnf andwill be used by default by the server when you start it.You may edit this file to change server settings[root@localhost mysql]# chown -R root .[root@localhost mysql]# chown -R mysql data[root@localhost mysql]# bin/mysqld_safe --user=mysql &[1] 4144[root@localhost mysql]# 141107 20:52:14 mysqld_safe Logging to '/usr/local/mysql/data/localhost.localdomain.err'.141107 20:52:14 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysql.server[root@localhost mysql]# ps -elf | grep mysql4 S root      4144  3430  0  85   0 -  1149 wait   20:52 pts/0    00:00:00 /bin/sh bin/mysqld_safe --user=mysql4 S mysql     4234  4144  4  76   0 - 195029 stext 20:52 pts/0    00:00:02 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datad                    data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/localhost.localdomain.err --pid-file=/usr/lo                    host.localdomain.pid0 R root      4262  3430  0  78   0 -  1008 -      20:53 pts/0    00:00:00 grep mysql[root@localhost mysql]# ./bin/mysqladmin -u root password 'xxxxxx'Warning: Using a password on the command line interface can be insecure.[root@localhost mysql]# ./bin/mysql_secure_installationNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!In order to log into MySQL to secure it, we'll need the currentpassword for the root user.  If you've just installed MySQL, andyou haven't set the root password yet, the password will be blank,so you should just press enter here.Enter current password for root (enter for none):OK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MySQLroot user without the proper authorisation.You already have a root password set, so you can safely answer 'n'.Change the root password? [Y/n] n ... skipping.By default, a MySQL installation has an anonymous user, allowing anyoneto log into MySQL without having to have a user account created forthem.  This is intended only for testing, and to make the installationgo a bit smoother.  You should remove them before moving into aproduction environment.Remove anonymous users? [Y/n] y ... Success!Normally, root should only be allowed to connect from 'localhost'.  Thisensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] y ... Success!By default, MySQL comes with a database named 'test' that anyone canaccess.  This is also intended only for testing, and should be removedbefore moving into a production environment.Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success!Reloading the privilege tables will ensure that all changes made so farwill take effect immediately.Reload privilege tables now? [Y/n] y ... Success!All done!  If you've completed all of the above steps, your MySQLinstallation should now be secure.Thanks for using MySQL!Cleaning up...修改 /root/.bash_profile中的PATH:[root@localhost ~]# cat /root/.bash_profile# .bash_profile# Get the aliases and functionsif [ -f ~/.bashrc ]; then        . ~/.bashrcfi# User specific environment and startup programsPATH=$PATH:/usr/local/mysql/bin:$HOME/binexport PATHunset USERNAME[root@localhost ~]# pwd/root[root@localhost ~]# mysql -uroot -pEnter password:Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 14Server version: 5.6.21 MySQL Community Server (GPL)Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> show databases;+--------------------+| Database           |+--------------------+| information_schema || mysql              || performance_schema |+--------------------+3 rows in set (0.00 sec)mysql> user mysql;mysql> select host,user,password from user;+-----------+------+-------------------------------------------+| host      | user | password                                  |+-----------+------+-------------------------------------------+| localhost | root | *BDC62F68AF8F0B8BFAE27FF782C5D8CE9F4BAFCB || 127.0.0.1 | root |                                           || ::1       | root |                                           |+-----------+------+-------------------------------------------+3 rows in set (0.01 sec)mysql> update user set password=password('xxxxxx') where password='';Query OK, 2 rows affected (0.02 sec)Rows matched: 2  Changed: 2  Warnings: 0mysql> select host,user,password from user;+-----------+------+-------------------------------------------+| host      | user | password                                  |+-----------+------+-------------------------------------------+| localhost | root | *BDC62F68AF8F0B8BFAE27FF782C5D8CE9F4BAFCB || 127.0.0.1 | root | *BDC62F68AF8F0B8BFAE27FF782C5D8CE9F4BAFCB || ::1       | root | *BDC62F68AF8F0B8BFAE27FF782C5D8CE9F4BAFCB |+-----------+------+-------------------------------------------+3 rows in set (0.00 sec)到这里,第二种安装方法结束。该安装方法下,启动mysql命令为:mysqld_safe --user=mysql &关闭mysql命令为:mysqladmin -uroot -p shutdown

2016-09-25 00:53 举报
已邀请:
0

gsy36559067

赞同来自:

排版不太好

0

爱上神秘

赞同来自:

仿佛天书一般,不过感谢分享

0

葡萄树

赞同来自:

i_f12.gif

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: