yum -y install gcc gcc-c++ ncurses ncurses-devel cmake bison
wget https://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
tar -zxvf boost_1_59_0.tar.gz
mv boost_1_59_0 /usr/local/boost
tar -xf mysql-5.7.17.tar.gz –C /usr/src/
groupadd -r mysql && useradd -r -g mysql -s /sbin/nologin -M mysql
mkdir -pv /data/mysql
cd /usr/src/mysql-5.7.17
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/data/mysql/mysqld.sock -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_BOOST=/usr/local/boost -DMYSQL_USER=mysql -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
make
make install #编译安装
chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /data
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
ln -s /usr/local/mysql/bin/* /usr/local/bin/
chkconfig --add mysqld
chkconfig mysqld on
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
初始化
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql(如果这里报错,就指定为--datadir=/usr/local/mysql/data)
--initialize为随机生成mysql密码,注意初始化最后一行是root用户密码(例如root@localhost: ,5j1Qj_LLAek)
/etc/init.d/mysqld start
mysql5.7以上密码重置方法
vim /etc/my.cnf
加入一行
mysqld--skip-grant-tables
mysql
登录 use mysql;
update user set authentication_string=password("new_pass") where user="root";
flush privileges;
如果报错ERROR 1820 (HY000): You must reset your password
using ALTER USER statement
;
SET
PASSWORD = PASSWORD('123456');
如果出现ERROR 1819 (HY000): Your password does not satisfy the current policy requirements;
set
global validate_password_policy=0; set global validate_password_mixed_case_count=2;
(取消密码强度)
SET
PASSWORD = PASSWORD('123456');
Mysql5.7.17
开启远程连接
:
mysql -uroot –p
use mysql;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
flush privileges;
select host,user from user;(
查看所有用户)