rpm -aq ncurses-devel libaio-devel cmake yum install -y ncurses-devel libaio-devel cmake
创建Mysql用户
useradd mysql -s /sbin/nologin -M
解压mysql安装包
tar xf mysql-5.5.49.tar.gz
cd mysql-5.5.49
配置编译参数
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \-DMYSQL_DATADIR=/usr/local/mysql/data \-DMYSQL_UNIX_ADDR=/usr/local/mysql/tmp/mysql.sock \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci \-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \-DENABLED_LOCAL_INFILE=ON \-DWITH_INNOBASE_STORAGE_ENGINE=1 \-DWITH_FEDERATED_STORAGE_ENGINE=1 \-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \-DWITHOUT_PARTITION_STORAGE_ENGINE=1 \-DWITH_FAST_MUTEXES=1 \-DWITH_ZLIB=bundled \-DENABLED_LOCAL_INFILE=1 \-DWITH_READLINE=1 \-DWITH_EMBEDDED_SERVER=1 \-DWITH_DEBUG=0
make & make install
给mysql安装目录用户权限
chown -R mysql:mysql /usr/local/mysql/
初始化操作
cd /usr/local/mysql/scripts/
./mysql_install_db --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data --user=mysql
复制启动文件
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
启动文件授权
chmod +x /etc/init.d/mysqld
配置文件说明
my-huge.cnf #巨大的my-innodb-heavy-4G.cnf #沉重的my-large.cnf #大的my-medium.cnf #中间的my-small.cnf #小的 如果是生产环境可以根据硬件选择更高级的配置文件,上述配置文件模板对硬件的要求从高到低依次是 my-medium.cnf ==》 my-small.cnf ==》 my-large.cnf ==》 my-huge.cnf ==》 my-innodb-heavy-4G.cnf
复制配置文件
cp support-files/my-innodb-heavy-4G.cnf /etc/my.cnf
/etc/init.d/mysqld start
配置环境变量
echo 'export PATH=/usr/local/mysql/bin:$PATH' >> /etc/profile
source /etc/profile
设置mysql密码
mysqladmin -u root password '密码'
设置防火墙
vim /etc/sysconfig/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
mysql用户创建和授权
select user,host,password from mysql.user ; create user mysql@'192.168.100.110' identified by '密码'; #创建用户 grant all on *.* to mysql@'192.168.100.110'; #授权 flush privileges; #刷新操作