Linux Centos 7インストールMySQL 5.5(バイナリ方式取付)

3432 ワード

Linux Centos 7インストールMySQL 5.5(バイナリ方式取付)
一、/appディレクトリの下でmysql-5.54-linux 2をダウンロードする.6-x86_64.tar.gz`
[root@test /]# cd /app
[root@test app]# wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.54-linux2.6-x86_64.tar.gz

二、mysql-5.5.54-linux 2を解凍する.6-x86_64.tar.gz [root@test app]# ta zvxf mysql-5.5.54-linux2.6-x86_64.tar.gz
三、解凍後のmysql-5.54-linux 2.6-x86_64 mysqlと名前を変更[root@test app]# mv mysql-5.5.54-linux2.6-x86_64 mysql
四、追加/etc/my.cnfファイル
[root@test app]# cd /app/mysql/support-files/
[root@test support-files]# cp -f my-small.cnf /etc/my.cnf

五、mysqlディレクトリの下のdataディレクトリを作成する
[root@test support-files]# mkdir -p /app/mysql/data/

六、mysqlの所属ユーザーをmysqlに変更する
[root@test support-files]# chown -R mysql.mysql /app/mysql/

七、増加/etc/init.d/mysqld、実行権限を付与してMySQLを初期化
[root@test support-files]# cp -f mysql.server /etc/init.d/mysqld
[root@test support-files]# chmod +x /etc/init.d/mysqld

【MySQLの初期化】
[root@test support-files]# /app/mysql/scripts/mysql_install_db --basedir=/app/mysql --datadir=/app/mysql/data --user=mysql

八、/アプリケーション/mysql/bin/mysqld_safeと/etc/init.d/mysqldの/usr/local/mysqlを/app/mysqに変更
[root@test support-files]# sed -i 's#/usr/local/mysql#/app/mysql#g' /app/mysql/bin/mysqld_safe /etc/init.d/mysqld

九、mysqlを起動する
[root@test support-files]# /etc/init.d/mysqld start
Starting MySQL.Logging to '/app/mysql/data/test.err'.
.. SUCCESS! 

十、mysqlが起動しているかどうかをチェックする
[root@test support-files]# netstat -lntup | grep mysql
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      5478/mysqld 

十一、環境変数の設定
[root@test support-files]# echo 'export PATH=/app/mysql/bin:$PATH' >>/etc/profile
[root@test support-files]# source /etc/profile

十二、mysqlに入る
[root@test support-files]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.54 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, 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> 

十三、rootパスワードの修正
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');

十四、MySQLを脱退し、ユーザー名とパスワードを使用して再度MySQLにログインする
mysql> Ctrl-C -- exit!
Aborted
[root@test support-files]# mysql -uroot -p
Enter password: 

十五、データベースとテーブルの作成(utf-8符号化フォーマットを指定)
mysql> create database userInfo DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
Query OK, 1 row affected (0.00 sec)

mysql> use userInfo;
Database changed

mysql> create table test (
    -> name varchar(10) not null,
    -> address varchar(100) default null)
    -> ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
Query OK, 0 rows affected (0.06 sec)

十六、sqlファイルのインポート(必要に応じて)
mysql> source /app/cloud_note.sql
mysql> show databases;