1.安装
a.安装依赖
1 yum install -y ncurses-devel libaio-devel
b.安装cmake
1 yum install -y cmake
c.创建用户
1 useradd -s /sbin/nologin -M mysql
d.经典三步曲
http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.39.tar.gz
wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.39.tar.gz
tar xf mysql-5.6.39.tar.gz
cd mysql-5.6.39
1 #编译安装 2 cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.6.39 \ 3 -DMYSQL_DATADIR=/application/mysql-5.6.39/data \ 4 -DMYSQL_UNIX_ADDR=/application/mysql-5.6.39/tmp/mysql.sock \ 5 -DDEFAULT_CHARSET=utf8 \ 6 -DDEFAULT_COLLATION=utf8_general_ci \ 7 -DWITH_EXTRA_CHARSETS=all \ 8 -DWITH_INNOBASE_STORAGE_ENGINE=1 \ 9 -DWITH_FEDERATED_STORAGE_ENGINE=1 \ 10 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ 11 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \ 12 -DWITH_ZLIB=bundled \ 13 -DWITH_SSL=bundled \ 14 -DENABLED_LOCAL_INFILE=1 \ 15 -DWITH_EMBEDDED_SERVER=1 \ 16 -DENABLE_DOWNLOADS=1 \ 17 -DWITH_DEBUG=0 18 make && make install
e.创建链接
1 ln -s /application/mysql-5.6.39 /application/mysql
2.初始化数库
a.配置文件
1 cp support-files/my*.cnf /etc/my.cnf
b.创建目录
1 mkdir -p /application/mysql/tmp
c.授权
1 chown -R mysql.mysql /application/mysql-5.6.37
d.设置路径
1 echo 'PATH=/application/mysql/bin:$PATH' >>/etc/profile 2 tail -1 /etc/profile 3 source /etc/profile 4 echo $PATH 5 mysql
e.初次设置密码
1 mysqladmin password root 2 mysqladmin -uroot -p password"root" 3 #已有密码下修改密码 4 mysqladmin -uroot -p123456 password"root"
f.删除无用密码
1 drop user ''@'localhost'; 2 drop user ''@'root'; 3 drop user ''@'::1'; #视个人主机,主机域而定
#删除格式为 drop user '用户名'@'主机域'