CentOS编译安装Mysql5.6

预先安装相关编译软件及依赖软件

yum -y install make gcc-c++ cmake bison-devel  ncurses-devel​

执行Cmake

cmake . \

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DMYSQL_DATADIR=/usr/local/mysql/data \

-DSYSCONFDIR=/etc \

-DWITH_MYISAM_STORAGE_ENGINE=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_MEMORY_STORAGE_ENGINE=1 \

-DWITH_READLINE=1 \

-DMYSQL_UNIX_ADDR=/var/lib/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 -g mysql mysql -s /sbin/nologin (禁止MySql登录系统)

改变Mysql目录所有者所有权限

chown -R mysql:mysql /usr/local/mysql

初始化Mysql表

scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/data/mysql-data --user=mysql

添加系统服务

cp support-files/mysql.server /etc/init.d/mysql

chkconfig mysql on

启动MySQL

service mysql start

重置Mysql密码

mysql -uroot

mysql> SET PASSWORD = PASSWORD('123456');

mysql> SET PASSWORD = PASSWORD('%$kKt!UC');

允许远程操作mysql>  GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

防火墙开放3306端口

-A INPUT -m state --state NEW -m tcp -p -dport 3306 -j ACCEPT

你可能感兴趣的:(CentOS编译安装Mysql5.6)