安装gnake
./configure
&& gmake && gmake install
安装ncurses-devel
yum
install -y ncurses-devel
创建用户和组
groupadd
mysql
useradd
mysql -s /sbin/nologin -M -g mysql
mysql编译编译选项
cmake
. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysql
\
-DMYSQL_UNIX_ADDR=/data/tmp/mysql.sock
\
-DDEFAULT_CHARSET=utf8
\
-DDEFAULT_COLLATION=utf8_general_ci
\
-DEXTRA_CHARSETS=all
\
-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
配置环境变量以及配置文件
cp
/usr/local/mysql/support-files/my-small.cnf /etc/my.cnf
echo
'export PATH=/usr/local/mysql/bin:$PATH' >> /etc/profile
source
/etc/profile
初始化
cd
/usr/local/mysql/scripts/
./mysql_install_db
–basedir=/usr/local/mysql/ --datadir=/data/mysql/ --user=mysql
复制启动脚本
/bin/cp
/usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
删除授权表
select
user,host from mysql.user;
delete
from mysql.user where user ='';
delete
from mysql.user where host='::1';
drop
database test;
添加额外管理员
mysql>delete
from mysql.user;
mysql>grant
all privileges on *.* to system@'localhost' identified by '123qwe'
with grant option;
mysql>flush
privileges;
select
user,host from mysql.user;
添加密码
/usr/local/mysql/bin/mysqladmin
-u root password '123qwe'