Home >Database >Mysql Tutorial >MySql5.7.11编译安装及修改root密码的方法小结_MySQL

MySql5.7.11编译安装及修改root密码的方法小结_MySQL

PHP中文网
PHP中文网Original
2016-05-27 10:44:121480browse

推荐阅读:

Mysql5.7忘记root密码及mysql5.7修改root密码的方法

Mac 安装和卸载 Mysql5.7.11 的方法

系统是cenos6.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)


就可以了

以上就是MySql5.7.11编译安装及修改root密码的方法小结_MySQL的内容,更多相关内容请关注PHP中文网(www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn