MySQL 5.7.11編譯安裝以及修改root密碼小結

來源:互聯網
上載者:User

MySQL 5.7.11編譯安裝以及修改root密碼小結

系統是CentOS 6.7 64位的,預設MySQL5.7.11下載到/usr/local/src,安裝目錄在/app/local/mysql目錄下,MySQL資料放置目錄/app/local/data。MySQL從5.1後採用cmake方式編譯安裝,所以要先編譯安裝cmake工具,也可以採用yum方式安裝cmake。從MySQL5.7開始編譯安裝需要boost庫的支援,所以也要下載boost庫

#wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.11.tar.gz

#wget https://cmake.org/files/v3.1/cmake-3.1.3.tar.gz

#wget https://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz

如果沒有mysql使用者則建立mysql使用者。

#groupadd mysql

#useradd -g mysql mysql -s /bin/false

建立相應的目錄

#mkdir -p /app/local/{mysql,data}

#mkdir  /usr/local/boost

編譯安裝cmake

#tar zxvf cmake-3.1.3.tar.gz

#cd cmake-3.1.3

#./configure

#make && make install

#cd ../

將boost庫解壓到/usr/local/boost目錄下

#tar zxvf boost_1_59_0.tar.gz

#cd boost_1_59_0/

#mv ./* /usr/local/boost/

#cd ../

編譯安裝mysql5.7.11

#tar zxvf mysql-5.7.11.tar.gz

#cd mysql-5.7.11

#cmake -DCMAKE_INSTALL_PREFIX=/app/local/mysql/ -DMYSQL_DATADIR=/app/local/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost

#make && make install

#cd ../

#chown -R mysql:mysql /app/local/data/

#chown -R mysql:mysql /app/local/mysql/

#cd /app/local/mysql/bin

#./mysqld --initialize --user=mysql --basedir=/app/local/mysql/ --datadir=/app/local/data/#初始化mysql 並且產生一個隨機密碼

#mv /etc/my.cnf /etc/my.cnfbak#先備份產生的my.cnf

#cp ../support-files/my-default.cnf /etc/my.cnf

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

#chmod 755 /etc/init.d/mysqld

#chkconfig mysqld on

#service mysqld start

#mysql -uroot -p

Enter password:

用剛才產生的隨機密碼登入

要是不行,就在my.cnf裡配置password

登入後重設root密碼

mysql> SET PASSWORD  FOR 'root'@localhost = PASSWORD('123456');

Query OK, 0 rows affected, 1 warning (0.00 sec)

就可以了

Ubuntu 12.04 64位 下編譯安裝MySQL 5.5.29 

Linux源碼編譯安裝MySQL5.7.9 

CentOS7編譯安裝MySQL 5.6.28和編譯參數 

本文永久更新連結地址:

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.