Second, MySQL series-MySQL source installation configuration (with the latest version of 5.7)
1. Environment-dependent preparation
2. Start the installation
2.1. Download MySQL
2.2. Decompression
2.3. Assigning Permissions
2.4. Modify the configuration file
2.5. Start MySQL
3, MySQL 5.7 source installation of different places
Second, MySQL series-MySQL source installation configuration (with 5.7 and other latest version) 1, environment-dependent preparation
- Make installation
Make compiler: http://www.gnu.org/software/make/
# tar zxvf make-3.82.tar.gz
# cd make-3.82
# ./configure
# make
# make install
- Bison Installation
bison:http://www.gnu.org/software/bison/
# tar zxvf bison-2.5.tar.gz
# cd bison-2.5
# ./configure
# make
# make install
- gcc-c++ Installation
gcc-c++:http://www.gnu.org/software/gcc/
# tar zxvf gcc-c++-4.4.4.tar.gz
# cd gcc-c++-4.4.4
#./configure
# make
# make install
- CMake Installation
cmake:http://www.cmake.org/
# tar zxvf cmake-2.8.4.tar.gz
# cd cmake-2.8.4
#./configure
# make
# make install
- ncurses Installation
ncurses:http://www.gnu.org/software/ncurses/
# tar zxvf ncurses-5.8.tar.gz
# cd ncurses-5.8
#./configure
# make
# make install
2. Start installation 2.1, download MySQL
mysql5.6:http://dev.mysql.com/
Here i download the mysql-5.6.12.tar.gz here
ftp://mirror.switch.ch/mirror/mysql/Downloads/MySQL-5.6/
# groupadd mysql
# useradd mysql -g mysql -M -s /sbin/nologin
#增加一个名为 mysql的用户。
-g:指定新用户所属的用户组(group)
-M:不建立根目录
-s:定义其使用的shell,/sbin/nologin代表用户不能登录系统。
2.2. Decompression
Unzip and install MySQL
# tar zxvf mysql-5.6.12.tar.gz
# cd mysql-5.6.12
CMake./ -Dcmake_install_prefix=/usr/Local/MySQL-Dmysql_datadir=/usr/Local/MySQL/Data-Dsysconfdir=/etc-Dwith_myisam_storage_engine=1 -Dwith_innobase_storage_engine=1 -Dwith_memory_storage_engine=1 -Dwith_readline=1 -dmysql_unix_addr=/tmp/mysqld.sock-Dmysql_tcp_port=3306 -Denabled_local_infile=1 -Dwith_partition_storage_engine=1 -dextra_charsets= All-Ddefault_charset=UTF8-ddefault_collation=Utf8_general_ci
# make
# make install
2.3. Assigning Permissions
# cd /usr/local/mysql
# chown -R mysql:mysql . (#这里最后是有个.的大家要注意# 为了安全安装完成后请修改权限给root用户)
# scripts/mysql_install_db --user=mysql (先进行这一步再做如下权限的修改)
# chown -R root:mysql . (将权限设置给root用户,并设置给mysql组, 取消其他用户的读写执行权限,仅留给mysql "rx"读执行权限,其他用户无任何权限)
# chown -R mysql:mysql ./data (数据库存放目录设置成mysql用户mysql组)
# chmod -R ug+rwx . (赋予读写执行权限,其他用户权限一律删除仅给mysql用户权限)
2.4. Modify the configuration file
下面的命令是将mysql的配置文件拷贝到/etc
# cp support-files/my-default.cnf /etc/my.cnf
(5.6之前的版本用如下命令)
# cp support-files/my-medium.cnf /etc/my.cnf (5.6之前的版本是此操作,读者也可在此时自己进入support-files文件夹下面,看是配置文件的真正名称,那个存在,就拷贝那个。。)
修改my.cnf配置
# vi /etc/my.cnf
#[mysqld] 下面添加:
user=mysql
datadir=/data/mysql
default-storage-engine=MyISAM
2.5. Start MySQL
# bin/mysqld_safe --user=mysql & 或者直接进入bin文件夹下面
# cd bin
#./mysqld \ 这里说明,mysqld_safe或者mysqld都可以启动的
启动mysql,看是否成功
# ps –ef|grep mysql
The above is a way to start MySQL, there is a simple convenience, as follows:
将mysql的启动服务添加到系统服务中
# cp support-files/mysql.server /etc/init.d/mysql
现在可以使用下面的命令启动mysql
# service mysql start
停止mysql服务
# service mysql stop
重启mysql服务
# service mysql restart
3, MySQL 5.7 source installation of different places
- CMake version must be at least 2.8
- Depending on the boost library, you need to add the following options when CMake
-ddownload_boost=1-dwith_boost=/usr/local/boost
- Initialize and start
在5.7.6之前初始化的方法是:bin/mysql_install_db --user=mysql 5.7.6之后的版本初始化数据库不再使用mysql_install_db
bin/mysqld --initialize --user=mysql --basedir=/package/mysql --datadir=/package/mysql/data --innodb_undo_tablespaces=3
bin/mysql_ssl_rsa_setup
cp support-files/mysql.server /etc/init.d/mysql
bin/./mysqld_safe --skip-grant-tables --skip-networking &
在5.7中存储密码的字段不再是password了,变成了authentication_string
update mysql.user set authentication_string=password(‘root‘) where user=‘root‘
SET PASSWORD=PASSWORD(‘root‘);
Null
MySQL Series-MySQL source installation configuration