Mariadbのインストールと構成

3778 ワード

Mariadbのインストールと構成
1インストール計画
1.1 Mariadbバージョン:
Mariadb 10.0.14 Stable
1.2データベースデータファイルのパス:
/xwtec/mysql/
2ダウンロードとインストール
2.1ダウンロードアドレス:
https://downloads.mariadb.org/
2.2 Mariadbのインストール
rootユーザーに切り替えて、次のインストールを行います.
#   mysql  
groupadd mysql
useradd -g mysql mysql
#        /usr/local
cd /usr/local
tar -zxvpf /path-to/mariadb-VERSION-OS.tar.gz
#   mysql   
ln -s mariadb-VERSION-OS mysql
#   mariadb
cd mysql
./scripts/mysql_install_db --user=mysql
#       
chown -R root .
chown -R mysql data

上記の手順を実行した後、インストールを完了します.
 
2.3起動と接続のテスト
./bin/mysqld_safe --user=mysql &
 
修正bash_ファイルかbashrcファイル、環境変数を次のように追加します.
export PATH=$PATH:/usr/local/mysql/bin/
 
接続に成功したかどうかをテストします.
mysql –u root
3電源オン
#mysqlサービスファイルのコピー
cd/usr/local/mariadb-version/support-files/
cp mysql.server/etc/init.d/mysql
chmod +x/etc/init.d/mysql
#起動の設定(RPMベースのシステム)
chkconfig --add mysql
chkconfig --level 345 mysql on
4構成パラメータ
4.1起動ファイルの変更
Mariadbの起動時にプロファイルを読み込むmy.cnf、デフォルトの読み取り優先度は以下の通りです.
1/etc/my.cnf
2/etc/mysql/my.cnf
3 my.cnf in the DEFAULT_SYSCONFDIR specified during the compilation
4 my.cnf in the path, specified in the environment variable MYSQL_HOME (if any)
5 the file specified in --defaults-extra-file (if any)
6 user-home-dir/.my.cnf
 
使用/etc/myを選択します.cnfはプロファイルとして、関連する修正を行います.
 
まず、データベースデータファイルに格納されているフォルダ/xwtec/mysqlを追加します.
cp -a/var/lib/mysql/xwtec/mysql
 
その後、/etc/myを変更します.cnf、datadirの構成は以下の通りです.
# datadir=/var/lib/mysql
datadir=/xwtec/mysql
 
4.2 mysqladmin管理
rootパスワードの変更:
mysqladmin -u root password
5よくある質問
5.1  /tmp/mysql.sock問題
問題の説明:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2 "No such file or directory")
 
ソリューション:
検査するcnf,socket=/var/lib/mysql/mysql.sock、ソフトリンクを追加
ln -s/var/lib/mysql/mysql.sock/tmp/mysql.sock
問題の説明:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (13 "Permission denied")
 
ソリューション:
mysqlを追加します.sockが存在するディレクトリへのアクセスと読み取り権限:
chmod +rx/var/lib/mysql/
 
6参考文書
インストール
https://mariadb.com/kb/en/mariadb/documentation/getting-started/binary-packages/installing-mariadb-binary-tarballs/
 
起動
https://mariadb.com/kb/en/mariadb/documentation/getting-started/starting-and-stopping-mariadb/iniciando-e-parando-mariadb-automaticamente/
 
コンフィギュレーション
https://mariadb.com/kb/en/mariadb/documentation/getting-started/starting-and-stopping-mariadb/mysqld-configuration-files-and-groups/
 
mysqlサービス
https://mariadb.com/kb/en/mariadb/documentation/getting-started/starting-and-stopping-mariadb/mysqlserver/
 
mysqladmin設定
https://mariadb.com/kb/en/mariadb/documentation/clients-and-utilities/mysqladmin/