無名

大猫咪与小狮子

My Links

Blog Stats

mysql 安装

编译环境
yum install gcc gcc-c++ ncurses-devel perl
依赖
yum install boost boost-devel boost-doc

安装cmake
wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz
tar -xzvf cmake-2.8.10.2.tar.gz
cd cmake-2.8.10.2
./bootstrap
make
make install

安装mysql
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.51.tar.gz

解压后进入mysql-5.5.51
cmake -DCMAKE_INSTALL_PREFIX=/software/installed/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
make
make install

添加用户和分组
groupadd mysql
useradd -r -g mysql mysql

配置与初始化
cd /software/installed/mysql/
chown -R mysql:mysql .
chown -R mysql:mysql /usr/local/mysql/data
cp support-files/my-large.cnf /etc/my.cnf //增加配置文件
cp support-files/mysql.server /etc/init.d/mysql //加入service
scripts/mysql_install_db --datadir=/usr/local/mysql/data --user=mysql --basedir=/software/installed/mysql
启动mysql
service mysql start

为root设置密码

设置PATH
vi /etc/profile
在文件末尾加上
PATH=/software/installed/mysql/bin:$PATH
export PATH
source /etc/profile

mysql -uroot
mysql> SET PASSWORD = PASSWORD('mysqlroot123456');
设置远程可以访问
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.%' IDENTIFIED BY 'mysql123456' WITH GRANT OPTION;
eixt;

配置iptables 3306端口通过
vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
service iptables restart

 

关闭mysql DNS反向解析,

MySQL数据库收到一个网络连接后,首先拿到对方的IP地址,然后对这个IP地址进行反向DNS解析从而得到这个IP地址对应的主机名。用主机名在权限系统里面进行权限判断。反向DNS解析是耗费时间的,有可能让用户感觉起来很慢。甚至有的时候,反向解析出来的主机名并没有指向这个IP地址,这时候就无法连接成功了。 

只需在my.cnf的[mysqld]段落中加入如下行即可:

skip-name-resolve

posted on 2016-08-02 10:42 xiezhengcai 阅读(...) 评论(...) 编辑 收藏