RHEL6.2インストール+MySQL 5.6.16の起動

9517 ワード

この文章は主にRHEL 6を紹介した.2コンパイルインストールMySQL 5.6.16プロセスの共有、mysqlも含まれています.secure_Installationスクリプト実行指導、必要な方は参考にしてください
一、環境説明:
 
       : 
   
[root@beanvm ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.2 (Santiago)
[root@beanvm ~]# uname -a
Linux beanvm 2.6.32-220.el6.i686 #1 SMP Wed Nov 9 08:02:18 EST 2011 i686 i686 i386 GNU/Linux

、 とシステム
1.インストールパッケージのダウンロード
ここでダウンロードしたのは に しいMySQL 5.6.16バージョンで、 の が すぎて、ファイルは:mysql-5.6.16です.tar.gz
ダウンロード :http://dev.mysql.com/downloads/mysql/
2.コンパイルに なパッケージのインストール

        : 
   
[root@beanvm ~]# rpm -ivh bison-devel-2.4.1-5.el6.i686.rpm
warning: bison-devel-2.4.1-5.el6.i686.rpm: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:bison-devel            ########################################### [100%]
[root@beanvm ~]# rpm -ivh ncurses-devel-5.7-3.20090208.el6.i686.rpm
warning: ncurses-devel-5.7-3.20090208.el6.i686.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing...                ########################################### [100%]
   1:ncurses-devel          ########################################### [100%]

な では、 の2つのバッグが けやすいので、gcc、make、cmakeのように です.チェックすることをお めします.

        : 
   
[root@beanvm ~]# rpm -qa |grep gcc-c++
gcc-c++-4.4.6-3.el6.i686
[root@beanvm ~]# rpm -qa |grep make
imake-1.0.2-11.el6.i686
automake-1.11.1-1.2.el6.noarch
cmake-2.6.4-5.el6.i686
make-3.81-19.el6.i686

3.MySQLユーザーとグループの

         : 
   
[root@beanvm ~]# groupadd mysql
[root@beanvm ~]# useradd -g mysql mysql
[root@beanvm ~]# passwd mysql

4. の
 
   
[root@beanvm ~]# su – mysql

はい.bash_profileファイルではPATH にmysqlパスを します.
 
   
export PATH=/sbin:$HOME/bin:/usr/local/mysql/bin:$PATH

、MySQLのインストール
インストールパッケージを するには:
 
   
[root@beanvm ~]# tar -xvf mysql-5.6.16.tar.gz
[root@beanvm ~]# cd mysql-5.6.16

コンパイルスクリプトは のとおりです.

cmake \
# MySQL   
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
#       
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
は に、
make && make install

にインストールされているオプションは ですが、 については、 を してください.
http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html
コンパイル は によって まり、 のは20 の があります.
インストールが したら、ルートディレクトリにmysqlユーザーとグループを するか、mysqlユーザーとグループの を うことができます.
 
   
[root@beanvm ~]# chown -R mysql:mysql /usr/local/mysql

インストールが したMySQLルートは のとおりです.

         : 
   
[root@beanvm ~]# ls -l /usr/local/mysql/
total 164
drwxr-xr-x.  2 mysql mysql  4096 Feb 15 14:40 bin
-rw-r--r--.  1 mysql mysql 17987 Jan 14 23:38 COPYING
drwxr-xr-x.  6 mysql mysql  4096 Feb 18 16:32 data
drwxr-xr-x.  2 mysql mysql  4096 Feb 15 14:39 docs
drwxr-xr-x.  3 mysql mysql  4096 Feb 15 14:39 include
-rw-r--r--.  1 mysql mysql 88109 Jan 14 23:38 INSTALL-BINARY
drwxr-xr-x.  3 mysql mysql  4096 Feb 15 14:39 lib
drwxr-xr-x.  4 mysql mysql  4096 Feb 15 14:40 man
-rw-r--r--.  1 mysql mysql   943 Feb 15 14:56 my.cnf
-rw-r--r--.  1 mysql mysql   943 Feb 18 16:26 my-new.cnf
drwxr-xr-x. 10 mysql mysql  4096 Feb 15 14:40 mysql-test
-rw-r--r--.  1 mysql mysql  2496 Jan 14 23:38 README
drwxr-xr-x.  2 mysql mysql  4096 Feb 15 14:40 scripts
drwxr-xr-x. 28 mysql mysql  4096 Feb 15 14:40 share
drwxr-xr-x.  4 mysql mysql  4096 Feb 15 14:40 sql-bench
drwxr-xr-x.  3 mysql mysql  4096 Feb 15 14:40 support-files

デフォルトのプロファイルmyが されていることがわかります.cnf.
、MySQL
データベースを する スクリプトを します.

        : 
   
[root@beanvm ~]# cd /usr/local/mysql/scripts/
[root@beanvm scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

MySQLサービスを して します.

        : 
   
[root@beanvm ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
[root@beanvm ~]# service mysql start
Starting MySQL.. SUCCESS!

はデータベースの です. しいMySQLのインストール に、/usr/local/mysql/bin/mysql_にあるデータベースの の を に するスクリプトが されました.secure_Installationは、 のタスクを します.
1.rootユーザーパスワードを します(デフォルトはパスワードがありません). ユーザ3を する.rootユーザーのリモートアクセスを します(ファイアウォールで3306ポートをオンにする があります.そうしないと、リモート に10038エラーが します!)4.テストデータベースを するかどうか5. テーブルの ロード
ここでは、 の でこのスクリプトを することをお めします.

         : 
   
[mysql@beanvm ~]$ /usr/local/mysql/bin/mysql_secure_installation

NOTE: 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 current
password for the root user.  If you've just installed MySQL, and
you 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 MySQL
root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n
 ... skipping.

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] n
 ... skipping.

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!

All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

Cleaning up...

もちろん、これらの は で うこともできます.
[mysql@beanvm ~]$ mysqladmin -u root password 'new-password'
[mysql@beanvm ~]$ mysqladmin -u root -h beanvm password 'new-password'
[mysql@beanvm ~]$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 5.6.16 Source distribution

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> delete from mysql.user where user='';
Query OK, 2 rows affected (0.01 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mypasswd' WITH GRANT OPTION;
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

、ファイアウォールで3306ポートをオンにする(そうでなければ、リモート に2003-Can't connect MySQL Server on'localhost'(10038))
1、ファイアウォールプロファイルを く
vi  /etc/sysconfig/iptables

2、 の を やす
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

: したオープン3306ポートの はicmp-host-prohibitedの に ず
3、ファイアウォールの
service  iptables restart

この でmysqlをリモート しても2003-Can't connect MySQL Server on'localhost'(10038)エラーは しません
、MySQLの と
1、mysqlバージョンの 1:status; 2:select version();
2、Mysql 、 、 コマンドa 、 1、サービス :[root@localhost//]#service mysqld start(5.0バージョンはmysqld)[root@szxdbetc]#service mysql start(5.5.7バージョンはmysql)
2、mysqldスクリプトを して する:/etc/inint.d/mysqld start
3、safe_を うmysqld :safe_mysqld&
b、 1、サービスで :サービスmysqld stop
2、mysqldスクリプトを して する:/etc/inint.d/mysqld stop
3、mysqladmin shutdown
c、 1、サービス :サービスmysqld restartサービスmysql restart(5.5.7バージョンコマンド)
2、mysqldスクリプトを して する:/etc/init.d/mysqld restart
:
http://www.jb51.net/article/52263.htm
http://www.cnblogs.com/linjiqin/p/3544472.html