CentOS 7 source installation MySQL 5.7.6

Source: Internet
Author: User
Tags mysql version

Recently in the CentOS 7 source code installed MySQL 5.7.6+, found that mysql5.7.6+ after the installation method is really different from the previous version of the MySQL installation method greatly. Do not install a piece of your own, you do not know where the difference is, the following this article is through their own installation process summarized an installation of the tutorial, the need for friends can reference, the following to see together.

Configuration Instructions

Linux version: Centos7

MySQL version: MySQL5.7.16

This document applies to MySQL version >=5.7.6

First, uninstall CentOS7 default carry MARIADB Pack

1 # Check the MARIADB installation package2[Email protected] ~]# Rpm-qa |grep-i mysql3[Email protected] ~]# Rpm-qa |grep-I mariadb4mariadb-libs-5.5. --1. el7_2.x86_645 # Uninstalling the MARIADB installation package6[Email protected] ~]# rpm-e mariadb-libs-5.5. --1. el7_2.x86_647 error:failed dependencies:8Libmysqlclient.so. -() (64bit) is needed by (installed) postfix-2:2.10.1-6. el7.x86_649Libmysqlclient.so. -(LIBMYSQLCLIENT_18) (64bit) is needed by (installed) postfix-2:2.10.1-6. el7.x86_64Ten[Email protected] ~]# rpm-e mariadb-libs-5.5. --1. el7_2.x86_64 postfix-2:2.10.1-6. el7.x86_64

Second, get MySQL all version (5.0.15-latest) address portal

http://downloads.mysql.com/archives/community/

Third, install the compilation software

?
1 yum install-y cmake makegcc gcc-c++

Iv. creating the MySQL installation directory

?
12 # 如MySQL安装目录为:/usr/local/mysqlmkdir-p /usr/local/mysql

Five, decompression MySQL source package

?
1 tar-zxvf mysql-5.7.16.tar.gz

Vi. creating MySQL users and user groups

?
1234 # 创建用户组groupadd mysql# 创建mysql用户,所属组为mysqluseradd-s /bin/bash-m -g mysql mysql

Vii. installation of MySQL dependent packages

?
1 yum install-y wget ncurses-devel cmake make perl ncurses-devel openssl-devel bison-devel libaio libaio-devel

Eight, boost library installation

?
123456789 # 该步骤可以省略,在cmake阶段添加参数-DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost即可# boost库安装wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gztar -zxvf boost_1_59_0.tar.gz -C /usr/localmv /usr/local/boost_1_59_0 /usr/local/boostcd /usr/local/boost./bootstrap.sh./b2 stage threading=multi link=shared./b2 install threading=multi link=shared

Ix. creating MySQL-related directories

| Catalogue | meaning | Configuration Parameters |

| : ——— | ———————————— –| —————————————-|

| Bin_log | Binary Log Directory | Log_bin_basename

Log_bin_index |

| MyData | Data File Directory | DataDir |

| Innodb_log | InnoDB Redo Log Directory | Innodb_log_group_home_dir |

| Innodb_ts | InnoDB shared Table Space Directory | Innodb_data_home_dir |

| Log | Log file directory (Error log+general log+slow log) | Log_error

General_log_file

Slow_query_log_file |

| Relay_log | InnoDB Relay Log Directory | Relay_log_basename

Relay_log_index |

| Tmpdir | Temp file Directory | Tmpdir |

| Undo_log | InnoDB Rollback LOG Directory | Innodb_undo_directory |

?
12345678 mkdir -p /data/mysql/mysql3306/bin_logmkdir -p /data/mysql/mysql3306/db_filemkdir -p /data/mysql/mysql3306/innodb_logmkdir -p /data/mysql/mysql3306/innodb_tsmkdir -p /data/mysql/mysql3306/logmkdir -p /data/mysql/mysql3306/relay_logmkdir -p /data/mysql/mysql3306/tmpdirmkdir -p /data/mysql/mysql3306/undo_log

Ten, modify the directory created by step 9 belongs to the user and the owning group is Mysql:mysql

?
1 chown-R mysql:mysql /data/mysql/mysql3306

Place the MySQL configuration file my.cnf in the/etc directory

By default, MySQL will find the following paths sequentially in order to get the MySQL configuration ask file:

/etc/my.cnf

/etc/mysql/my.cnf

/etc/my.cnf/my.cnf

/usr/local/mysql/my.cnf

~/.my.cnf

The configuration file can be specified through –defaults-file=xxx during use.

?
12 # 修改MySQL配置文件所属用户与所属组chown-R mysql:mysql my.cnf

Compiling and installing mysql5.7.6+

?
1234567891011 # 切换到mysql-5.7.16源码目录下cd /path/mysql-5.7.16# cmakecmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql/mysql3306/mydata -DSYSCONFDIR=/etc/my.cnf -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLE_DEBUG_SYNC=0 -DENABLED_LOCAL_INFILE=1 -DENABLED_PROFILING=1 -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/data/mysql/mysql3306/tmpdir/my-3306.sock -DWITH_DEBUG=0 -DWITH_SSL=yes -DWITH_SAFEMALLOC=OFF -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost # make # 该命令中可以通过添加-j参数指定多线程工作,如make -j2 && make install -j2 则使用2个CPU核进行make# 该步骤执行完毕后,可以到CMAKE_INSTALL_PREFIX参数指定的目录下,即MySQL安装目录下查看到mysql相关目录与文件make && make install# 修改MySQL安装目录的所属用户与用户组为mysql:mysqlchown -R mysql:mysql /usr/local/mysql

Initialize MySQL

?
12345 "shell   # into the MySQL installation directory   CD /usr/local/mysql   # initialize MySQL, remember--defaults-file=/etc/ MY.CNF is placed in the first bit of the parameter, the initialization information can be viewed in MySQL errorlog, and the errorlog generates a root random password that is only owned by the [email protected] user.   mysqld--defaults- file = /etc/my .cnf--initialize--basedir= /usr/local/mysql --datadir= /data/mysql/mysql3306/mydata --user=mysql

1. Add the MySQL environment variable

?
123456 vim /etc/profile# 在~/.bashrc文件下添加如下语句exportMYSQL_HOME=/usr/local/mysqlexport PATH=${MYSQL_HOME}/bin:$PATH# 保存后,使环境变量生效source/etc/profile

2. Start MySQL

?
12 mysqld_safe --defaults-file=/etc/my.cnf &# 此时可以通过ps -ef | grep mysql看到相关进程

3. Log in to MySQL

?
1234567891011121314 mysql -uroot -S /data/mysql/mysql3306/tmpdir/mysql.sock -p# 输入errorlog中生成的随机密码,即可登陆MySQL# 登陆mysql需要修改root密码,否则会出现下列情况:[email protected] : (none) 11:16:52> show databases;ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.# 修改root密码set password=‘MYSQL‘;# 目前版本可以使用直接的字符串代替以前password(‘xxx‘)的加密方式,目前版本提示如下:[email protected] : (none) 11:16:54> set password=password(‘MYSQL‘);Query OK, 0 rows affected, 1 warning (0.00 sec)Warning (Code 1287): ‘SET PASSWORD = PASSWORD(‘<plaintext_password>‘)‘ is deprecated and will be removed in a future release. Please use SET PASSWORD = ‘<plaintext_password>‘ instead[email protected] : (none) 11:19:27> set password=‘MYSQL‘;

4. Turn off MySQL?

?
12 mysqladmin shutdown-uroot -S /data/mysql/mysql3306/tmpdir/mysql.sock -p# 使用新密码

The initialized mysql5.7.6+ differs from the mysql5.6.xx

Initial chemical with different

MYSQL5.6.XX is using the mysql_install_db,mysql5.7.6+ official recommended mysqld–initialize.

Initializing the database is different

There are mysql,information_schema,performance_schema,test four databases after initialization of MYSQL5.6.XX, mysql5.7.6+ after initialization mysql,information_ Schema,performance_schema,sys of four databases.

Initialize users differently

MYSQL5.6.XX after initialization exists [email protected],[email protected] ':: 1 ', [email protected] ' hostname ', ' @ ' localhost ', ' @ ' Hostname ' Five users, mysql5.7.6+ exists after initialization mysql.sys,[email protected] User

Initialize root password

After mysql5.6.xx initialization, the root user password is empty, and after mysql5.7.6+ initialization, a random password is generated for the [email protected] user.
```

Summarize

The above is the entire content of this article, I hope that the content of this article on everyone's study or work can bring certain help, if there is doubt you can message exchange.

CentOS 7 source installation MySQL 5.7.6

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.