yum -y install gcc gcc-c++ cmake ncurses-devel bison
groupadd mysql
useradd mysql -g mysql -s /sbin/nologin -M
mkdir -p /usr/local/src/download/mysql5.7
cd /usr/local/src/download/mysql5.7
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-boost-5.7.25.tar.gz
tar zxvf mysql-boost-5.7.25.tar.gz
mkdir -p /usr/local/mysql5.7/data
mkdir -p /usr/local/mysql5.7/log
touch /usr/local/mysql5.7/log/error.log
mkdir -p /usr/local/mysql5.7/run
chown -R mysql:mysql /usr/local/mysql5.7
cd mysql-5.7.25
cmake -DMYSQL_USER=mysql\
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql5.7\
-DINSTALL_DATADIR=/usr/local/mysql5.7/data\
-DMYSQL_UNIX_ADDR=/usr/local/mysql5.7/tmp/mysqld.sock\
-DDEFAULT_CHARSET=utf8\
-DDEFAULT_COLLATION=utf8_general_ci\
-DEXTRA_CHARSETS=all\
-DWITH_EMBEDDED_SERVER=1\
-DENABLED_LOCAL_INFILE=1\
-DWITH_MYISAM_STORAGE_ENGINE=1\
-DWITH_INNOBASE_STORAGE_ENGINE=1\
-DDOWNLOAD_BOOST=1\
-DWITH_BOOST=./boost
make
make install
vi /etc/my.cnf
[client]
port = 3306
socket = /usr/local/mysql5.7/run/mysql.sock
[mysqld]
basedir = /usr/local/mysql5.7
datadir = /usr/local/mysql5.7/data
socket = /usr/local/mysql5.7/run/mysql.sock
[mysqld_safe]
log-error = /usr/local/mysql5.7/log/error.log
pid-file = /usr/local/mysql5.7/run/mysql.pid
cp mysql.server /etc/init.d/mysqld
chmod a+x /etc/init.d/mysqld
chkconfig --level 345 mysqld on
echo "export PATH=/usr/local/mysql5.7/bin:$PATH" >> /etc/profile
source /etc/profile
- 初始化 mysql,得到 root 用户的初始密码
/usr/local/mysql5.7/bin/mysqld --initialize\
--basedir=/usr/local/mysql5.7\
--datadir=/usr/local/mysql5.7/data\
--user=mysql
/etc/init.d/mysqld start
/usr/local/mysql5.7/bin/mysql -uroot -p
alter user 'root'@'localhost' identified by '123456';
网友评论