Linuxオペレーティングシステム: centOS6.5 64ビット(システムデフォルト開発パッケージがインストールされています)
データベース1:
MYSQLバージョン: mysql-5.0.56
ポート:3306
システムディレクトリ:/usr/local/mysql3306
データベース2:
MYSQLバージョン: mysql-5.1.72
ポート:3307
システムディレクトリ:/usr/local/mysql3307
<pre name="code" class="plain"># yum -y install wget gcc-c++ ncurses ncurses-devel cmake make perl bison openssl openssl-devel gcc* libxml2 libxml2-devel curl-devel libjpeg* libpng* freetype*
# service iptables stop # setenforce 0 # vi /etc/sysconfig/selinux --------------- SELINUX=disabled
# su - # mkdir ~/src # cd src # wget //m.sbmmt.com/ # wget //m.sbmmt.com/
# useradd mysql
# mkdir -p /usr/local/mysql{3306,3307}/data # mkdir -p /usr/local/mysql{3306,3307}/log
# chown -R mysql:mysql /usr/local/mysql{3306,3307}/data/ # chown -R mysql:mysql /usr/local/mysql{3306,3307}/log/ # chmod 750 /usr/local/mysql{3306,3307}/data # chmod 750 /usr/local/mysql{3306,3307}/log
# mkdir -p /usr/local/mysql{3306,3307}/etc # chown -R mysql.mysql /usr/local/mysql{3306,3307}/etc # mkdir -p /var/run/mysqld{3306,3307} # chown -R mysql.mysql /var/run/mysqld{3306,3307} # mkdir -p /var/lib/mysqld{3306,3307} # chown -R mysql.mysql /var/lib/mysqld{3306,3307} # cp /etc/my.cnf /usr/local/mysql{3306,3307}/etc
# cd ~/src # tar -zxvf mysql-5.0.56.tar.gz # cd mysql-5.0.56 ./configure --prefix=/usr/local/mysql3306 --with-mysqld-user=mysql --sysconfdir=/usr/local/mysql3306/etc --localstatedir=/usr/local/mysql3306/data --with-tcp-port=3306 -enable-assembler --with-mysqld-ldflags=-all-static --with-charset=utf8 --with-extra-charsets=utf-8 -with-extra-charsets=all --with-plugins=csv,innobase,myisam,heap --with-unix-socket-path=/tmp/mysql3306.sock # make # make install
# cd ~/src # tar -zxvf mysql-5.1.71.tar.gz # cd mysql-5.1.71 ./configure --prefix=/usr/local/mysql3307 --with-mysqld-user=mysql --sysconfdir=/usr/local/mysql3307/etc --localstatedir=/usr/local/mysql3307/data --with-tcp-port=3307 -enable-assembler --with-mysqld-ldflags=-all-static --with-charset=utf8 --with-extra-charsets=utf-8 -with-extra-charsets=all --with-plugins=csv,innobase,myisam,heap --with-unix-socket-path=/tmp/mysql3307.sock # make # make install
# vi /usr/local/mysql3306/etc/my.cnf ------------------------------------------------------- [mysqld] datadir=/usr/local/mysql3306/data socket=/tmp/mysql3306.sock user=mysql port=3306 pid-file=/var/lib/mysqld3306/mysql.pid # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 max_connections= 16384 skip-name-resolve skip-locking key_buffer = 256M max_allowed_packet = 32M table_cache = 3072 thread_cache_size = 256 sort_buffer_size = 16M read_buffer_size = 4M read_rnd_buffer_size = 16M net_buffer_length = 256M thread_stack = 8M query_cache_size = 128M query_cache_limit = 2M wait_timeout=7200 interactive_timeout=7200 #log log-error=/usr/local/mysql3306/log/error.log log=/usr/local/mysql3306/log/mysql.log long_query_time=2 log-slow-queries= /usr/local/mysql3306/log/slowquery.log log-bin= /usr/local/mysql3306/log/bin.log expire_logs_days = 15 sync_binlog = 1 max_binlog_cache_size = 4294967295 local-infile=0 default-storage-engine=INNODB [mysqld_safe] log-error=/var/log/mysqld3306.log pid-file=/var/run/mysqld3306/mysqld.pid
# vi /usr/local/mysql3307/etc/my.cnf ------------------------------------------------------- [mysqld] datadir=/usr/local/mysql3307/data socket=/tmp/mysql3307.sock user=mysql port=3307 pid-file=/var/lib/mysqld3307/mysql.pid # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 max_connections= 16384 skip-name-resolve skip-locking key_buffer = 256M max_allowed_packet = 32M table_cache = 3072 thread_cache_size = 256 sort_buffer_size = 16M read_buffer_size = 4M read_rnd_buffer_size = 16M net_buffer_length = 256M thread_stack = 8M query_cache_size = 128M query_cache_limit = 2M wait_timeout=7200 interactive_timeout=7200 #log log-error=/usr/local/mysql3307/log/error.log log=/usr/local/mysql3307/log/mysql.log long_query_time=2 log-slow-queries= /usr/local/mysql3307/log/slowquery.log log-bin= /usr/local/mysql3307/log/bin.log expire_logs_days = 15 sync_binlog = 1 max_binlog_cache_size = 4294967295 local-infile=0 default-storage-engine=INNODB [mysqld_safe] log-error=/var/log/mysqld3307.log pid-file=/var/run/mysqld3307/mysqld.pid -------------------------------------------------------
# ln -s /usr/local/mysql3306/lib/mysql /usr/lib/mysql
# echo "/usr/local/mysql3306/lib" >> /etc/ld.so.conf.d/mysql.conf # ldconfig
# ln -s /usr/local/mysql3306/include/mysql /usr/include/mysql
# cd /usr/local/mysql3306 # scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql3306/data
# cd /usr/local/mysql3307 # scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql3307/data
# cp /usr/local/mysql3306/support-files/mysql.server /etc/init.d/mysqld3306 # cp /usr/local/mysql3307/support-files/mysql.server /etc/init.d/mysqld3307
データベース 2 の構成:
# vi /etc/init.d/mysqld3006
basedir=/usr/local/mysql3306 datadir=/usr/local/mysql3306/data conf=/usr/local/mysql3306/etc/my.cnf $bindir/mysqld_safe --defaults-file=$conf --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1 & --------------------------------------------
下の図で赤でマークされているパラメータは追加されたパラメータです:
9. システムの起動 項目関連の設定
データベース 1 の設定:
# vi /etc/init.d/mysqld3007
basedir=/usr/local/mysql3307 datadir=/usr/local/mysql3307/data conf=/usr/local/mysql3307/etc/my.cnf $bindir/mysqld_safe --defaults-file=$conf --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1 & --------------------------------------------
# chkconfig --add mysqld3306 #添加开机启动服务 # chkconfig --level 35 mysqld3306 on #设置mysql启动
# chkconfig --add mysqld3307 # chkconfig --level 35 mysqld3307 on
# service mysqld3306 start
# service mysqld3307 start
注: mysql 環境変数が追加されるため、システム バックエンドは今後ログインするために mysql コマンドを直接使用できます。操作を標準化するためにここでは絶対パスが使用されます
# echo "PATH=$PATH:/usr/local/mysql3306/bin;export PATH" >> /etc/profile # source /etc/profile
# /usr/local/mysql3306/bin/mysqladmin -u root password 123456 #设置超级管理员密码 # /usr/local/mysql3306/bin/mysql -P3306 -S/tmp/mysql3306.sock -uroot -p123456 #连接数据库
1、-bash: ./scripts/mysql_install_db: そのようなファイルまたはディレクトリはありません
# /usr/local/mysql3307/bin/mysqladmin -u root password 123456 #设置超级管理员密码 # /usr/local/mysql3307/bin/mysql -P3307 -S/tmp/mysql3307.sock -uroot -p123456 #连接数据库
# mysql -P3307 -S/tmp/mysql3307.sock -uroot -p123456
解凍したソースコード内の support-files ディレクトリをインストールディレクトリにコピーし、コマンドを再実行します
3. env: /etc/init.d/mysqld3307: Permission Deny
データベース起動時に、コマンドを実行します
#lsof -i:3306 #lsof -i:3307
scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql3306/data
-bash: ./scripts/mysql_install_db: No such file or directory
以上が複数の mysql データベース構成例の MySQL-Centos インストールの詳細な紹介の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。