2011年7月22日 星期五

[記事] MySQL Installation

 想看的再點開

# Install relative libraries
shell > yum –y install gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel*

# Get and install cmake
shell> mkdir -p /home/cmake/src
shell> cd /home/cmake/src
shell> wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
shell> tar zxvf cmake-2.8.4.tar.gz
shell> cd cmake-2.8.4
shell>./bootstrap --prefix=/home/cmake
shell> gmake
shell> gmake install

# Create the mysql user and group in the OS
shell> groupadd mysql
shell> useradd -s /sbin/nologin -M -g mysql mysql

# Create the mysql data directory

shell> mkdir -p /home/mysql/data
shell> chown -R mysql:mysql /home/mysql/data/

# Beginning of source-build specific instructions
shell> mkdir -p /home/mysql/src
shell> cd /home/mysql/src/
shell> wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.14-linux2.6-x86_64.tar.gz/from/http://mysql.stu.edu.tw/
shell> tar zxvf mysql-5.5.14-linux2.6-x86_64.tar.gz
shell> cd mysql-5.5.14

# (You can find the cmake options in file INSTALL-SOURCE)
shell> /home/cmake/bin/cmake . -DCMAKE_INSTALL_PREFIX=/home/mysql/ -DMYSQL_DATADIR=/home/mysql/data/ -DMYSQL_UNIX_ADDR=/home/mysql/data/mysqld.sock -DENABLED_LOCAL_INFILE=1 -DMYSQL_TCP_PORT=3306 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
shell> make
shell> make install
shell> mkdir /home/mysql/etc
shell> cp support-files/my-medium.cnf /home/mysql/etc/my.cnf
shell> rm -rf /etc/my.cnf
shell> ln -s /home/mysql/etc/my.cnf /etc/my.cnf
shell> cp support-files/mysql.server /etc/init.d/mysqld
shell> chmod 755 /etc/init.d/mysqld
shell> bash /home/mysql/src/mysql-5.5.13/scripts/mysql_install_db --user=mysql --basedir=/home/mysql/ --datadir=/home/mysql/data

shell> /etc/init.d/mysqld start

# Set root password
shell> /home/mysql/bin/mysqladmin -u root password 'NEW_PASSWORD'
shell> /home/mysql/bin/mysqladmin -u root -h DB_HOST_NAME password 'NEW_PASSWORD'

# Create another user and set it's access privilege
shell> mysql -p

Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.5.13-log Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> grant all on DB_NAME.* to 'my_admin'@'COME_FROM_IP identified by 'NEW_PASSWORD';


# The user privileges information are stored in the table USER of database MYSQL
shell> mysql -p mysql

Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.5.13-log Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> select User, Host, password from user where user in ('root', 'my_admin');

ref : http://cnvz.org/a/fuwuqi/mysql/2011/0509/402.html

0 意見:

張貼留言