CentOS6.4 x 64コンパイルインストールMySQL 5.6.12


一、環境の準備
1、依存パッケージのインストール
# yum -y install bison bison-devel gcc gcc-c++ make cmake autoconf automake zlib* libxml* ncurses-devel libtool-ltdl-devel*  openssl openssl-devel libaio libaio-devel

yumソースのcmakeバージョン番号はmysqlの要件に達しているため、別途インストールされていません.
2、mysqlユーザーを創立する
# groupadd -r mysql
# useradd -g mysql -r -M -s /sbin/nologin mysql

このmysqlユーザーはログインできません
二、取り付け
1、解凍ソフト
# tar -zxvf mysql-5.6.12.tar.gz -C /tmp

2、コンパイルパラメータの設定
# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=all \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_SSL=system \
-DWITH_EMBEDDED_SERVER=1 \
-DWITH_READLINE=1 \
-DMYSQL_USER=mysql

3、取り付け
# make && make install

三、配置
1、インストールディレクトリとデータディレクトリに権限を与える
# chown -R mysql:mysql /usr/local/mysql/

2、初期化スクリプトの実行
# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

3、初めてMySQLを起動する
# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
# chmod +x /etc/init.d/mysqld
# service mysqld start      //  mysql  
# chkconfig --add mysqld    //
# chkconfig mysqld on       //mysql          

4、環境変数の構成
# vim /etc/profile

55行export PATHで...後挿入export PATH=$PATH:/usr/local/mysql/bin
# source /etc/profile

5、MySQLセキュリティスクリプトの実行
# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQLSERVERS 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):<--mysqlのrootパスワードが設定されている場合は、ここに入力する必要があります
OK, successfully used password, moving on…
Setting the root password ensures that nobody can log into the MySQLroot user without the proper authorisation.
Set root password? [Y/n]<--rootパスワードを設定するかどうかNew password:<--ユーザーパスワードRe-enter new password:<--設定したパスワードPassword updated successfullyをもう一度入力!Reloading privilege tables..… Success!
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]<--匿名ユーザーを削除するかどうか...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]<--rootリモートログインをオフにするかどうか...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]<--testデータベースを削除するかどうか-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]<--パーミッションテーブルを再読み込みするかどうか...Success!
Cleaning up…
All done!  If you’ve completed all of the above steps, your MySQLinstallation should now be secure.
Thanks for using MySQL!
#
セキュリティスクリプトを実行しない場合は、次の設定もできます.
1、rootアカウントの初期パスワードを設定する
# /usr/local/mysql/bin/mysqladmin -u root password 'new-password'

2、ネイティブ匿名接続の空パスワードアカウントを削除する
# mysql -uroot -p
mysql>use mysql; //       mysql
mysql>update user set password='root123' where user = '127.0.0.1';
mysql>delete from user where password="";//   root    
mysql>flush privileges;
mysql>quit  root       

rootアカウントの場合、セキュリティを考慮してリモートログインのために他のアカウントを新規作成する必要がある場合は、rootアカウントはリモートログインを開く必要はありません.しかし、一般的な使用では、セキュリティのニーズがあまりなく、rootユーザーのリモートログインを許可することで管理が容易になります.結局、専用管理ソフトウェアを使用するグラフィックインタフェースは操作の面で便利です.
3、MySQLリモート接続の設定
# /mysql -u root -p //     
mysql>use mysql
mysql>select user,password,host from user;
mysql>grant all privileges on *.* to root@'%' identified by "root123";
mysql>flush privileges;
mysql>exit
root@ip , 。 。 root123。