64-bit CentOs7 source code installation mysql-5.6.35 process sharing,

Source: Internet
Author: User
Tags install perl

64-bit CentOs7 source code installation mysql-5.6.35 process sharing,

First install the dependency package to avoid problems during installation

[Root @ bogon liuzhen] # yum-y install gcc-c ++
[Root @ bogon liuzhen] # yum-y install cmake
[Root @ bogon liuzhen] # yum-y install ncurses-devel
[Root @ bogon liuzhen] # yum-y install autoconf
[Root @ bogon liuzhen] # yum-y install perl-devel
The preceding dependency package can also be installed in one line.

[Root @ bogon liuzhen] # yum-y install gcc-c ++ cmake ncurses-devel autoconf perl-devel

Source mysql: https://dev.mysql.com/downloads/mysql/5.6.html#downloads

Source package address: https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.35.tar.gz

Create the mysql installation directory and data storage directory

[Root @ bogon liuzhen] # mkdir/usr/local/mysql
[Root @ bogon liuzhen] # mkdir/usr/local/mysql/data

Create a folder using mkdir

-M: Set the access permission for the new directory.

-P: if some directories in the path do not exist, the system automatically creates those directories that do not exist.

Create users and user groups

[Root @ bogon liuzhen] # groupadd mysql
[Root @ bogon liuzhen] # useradd-r-g mysql

The useradd command is used to create a user account and create a user's initial directory. The command uses permissions as the ultimate user. The new user password is blank.

-G: Specifies the starting group to which the user belongs.

-D: Specify the start directory when the user logs on.

-S: Specifies the shell used after the user logs on. -S/sbin/nologin does not allow shell Login

-G: The first mysql is the group name, and the second mysql is the new user name. The new user information can be found in the/etc/passwd file.

Decompress the file to the current folder.

Tar backup, compression and decompression, and Linux commands are also a tool

-Z: indicates that the tar package is compressed by gzip. Therefore, you must use gunzip to decompress the package.

-X: Extract files from the tar package

-V: displays details.

-F xxx.tar.gz: specifies that the file to be processed is xxx.tar.gz.

Tar zxvfis used to decompress tar.gz, and tar jxvf is used to decompress tar.bz2.

Start Installation

[Code]
[Root @ bogon liuzhen] # tar-zxvf mysql-5.6.35.tar.gz
[Root @ bogon liuzhen] # cd mysql-5.6.35
[Root @ bogon mysql-5.6.35] # cmake.-DCMAKE_INSTALL_PREFIX =/usr/local/mysql \
-DINSTALL_DATADIR =/usr/local/mysql/data \
-DDEFAULT_CHARSET = utf8 \
-DDEFAULT_COLLATION = utf8_general_ci \
-DEXTRA_CHARSETS = all \
-DENABLED_LOCAL_INFILE = 1
[Root @ bogon mysql-5.6.35] # make & make install
 
CMAKE parameter description:

-DCMAKE_INSTALL_PREFIX =/usr/local/mysql // default installation directory

-DINSTALL_DATADIR =/usr/local/mysql/data // database storage directory

-DDEFAULT_CHARSET = utf8 // use the utf8 character

-DDEFAULT_COLLATION = utf8_general_ci // check the character

-DEXTRA_CHARSETS = all // install all extended character sets

-DENABLED_LOCAL_INFILE = 1 // allow local data import

-DMYSQL_USER = mysql

-DMYSQL_TCP_PORT = 3306

For detailed configuration of CMAKE, refer to the mysql official website.

Note:

If the installation fails, clear the old object file and cache information.

[Root @ bogon mysql-5.6.35] # make clean
[Root @ bogon mysql-5.6.35] # rm-f CMakeCache.txt
[Root @ bogon mysql-5.6.35] # rm-rf/etc/my. cnf

Set Directory Permissions

[Root @ bogon liuzhen] # cd/usr/local/mysql
[Root @ bogon mysql] # chown-R mysql: mysql.
[Root @ bogon mysql] # chown-R mysql: mysql data

Chown command to change the owner and group of a file or directory.

-R: recursively changes the owner of all subdirectories and files under a specified directory.

-V: displays the work done by the chown command.

Add the mysql startup service to the System Service

[Root @ bogon liuzhen] # cd/usr/local/mysql
[Root @ bogon mysql] # cp support-files/my-default.cnf/etc/my. cnf

Create base table:

[Root @ bogon liuzhen] # cd/usr/local/mysql
[Root @ bogon mysql] #./scripts/mysql_install_db -- user = mysql

Configure Environment Variables

[Root @ bogon liuzhen] # vi/etc/profile

Add the following two values at the bottom

Export MYSQL_HOME = "/usr/local/mysql"

Export PATH = "$ PATH: $ MYSQL_HOME/bin"

Then save

Make the modified profile effective immediately

[Root @ bogon liuzhen] # source/etc/profile

Add mysql to the folder of the service that can be controlled to start, and name mysql, that is, the service name that can be controlled by the service. At this point, the service mysql start control can be used to start mysql.

/Etc/init. d is/etc/rc. d/init. d link in/etc/init. d. Adding a file will be synchronized to/etc/rc. d/init. d. Add the same file.

[Root @ bogon liuzhen] # cd/usr/local/mysql/
[Root @ bogon mysql] # cp support-files/mysql. server/etc/init. d/mysql

The chkconfig command is used to update (start or stop) and query the running level information of the system service. Remember that chkconfig does not automatically disable or activate a service immediately. It simply changes the symbolic connection.

-- Add: add the specified system service to allow the chkconfig command to manage it, and add relevant data in the system startup description file. The service script must be stored in the/etc/ini. d/directory.

Add mysql service to the service list of startup command Management

[Root @ bogon liuzhen] # chkconfig -- add mysql
Start mysql service at startup

On: the target service has a level limit. For more information, see chkconfig.

[Root @ bogon liuzhen] # chkconfig mysql on

Run the following command to start mysql:

[Root @ bogon liuzhen] # service mysql start
Stop mysql Service

[Root @ bogon liuzhen] # service mysql stop
Restart mysql Service

[Root @ bogon liuzhen] # service mysql restart

The following two commands serve the same purpose.

Systemctl [stop | start | restart] service name

Service name [stop | start | restart]

Press enter and set a new password in the following prompt.

[Root @ bogon liuzhen] # mysqladmin-u root password
New password:
Confirm new password:
[Root @ bogon liuzhen] #

Connect to mysql

[Root @ bogon mysql] # mysql-u root-p
Enter password:
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 2
Server version: 5.6.35 Source distribution

Copyright (c) 2000,201 6, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.

Type 'help; 'or' \ H' for help. type' \ C' to clear the current input statement.

Mysql>

Add the remote connection capability to the root user

Mysql> use mysql;
Mysql> desc user;
Mysql> grant all privileges on *. * TO root @ "%" identified by "root"; // Add the remote connection capability TO the root user.
Mysql> update user set Password = password ('xxxxxx') where User = 'root ';
Mysql> select Host, User, Password from user where User = 'root ';
Mysql> flush privileges; // refresh the permission
Mysql> exit // exit

The following four examples of GRANT

Assign the user user1 from 192.168.155.1 the permission to perform operations such as SELECT, INSERT, UPDATE, DELETE, CREATE, and DROP on the tablename table of the database dbname, and set the password to 123456.

There are many other table operation permissions, such as ALTER.

Mysql> grant select, INSERT, UPDATE, DELETE, CREATE, drop on dbname. tablename TO 'user1' @ '192. 168.155.1 'identified by '123 ';
Assign user2 from 192.168.155.1 the permission to perform all operations on all the database dbname tables and set the password to 123456.

Mysql> grant all privileges on dbname. * TO 'user2' @ '192. 168.155.1 'identified BY '20140901 ';
Assign user3 from 192.168.155.1 the permission to perform all operations on all tables in all databases and set the password to 123456.

Mysql> grant all privileges on *. * TO 'user3' @ '192. 168.155.1 'identified BY '123 ';
Assign the user user4 on the local machine the permission to perform all operations on all tables in all databases, and set the password to 123456.

Mysql> grant all privileges on *. * TO 'user4' @ 'localhost' identified by '123 ';

Enable external access to port mysql3306 of the firewall

After CentOS is upgraded to 7, firewalld is used to replace the original iptables. The following describes how to open a Linux port using firewalld.

-- Zone: scope. The network area defines the credibility level of the network connection. This is a one-to-many relationship, which means that a single connection can be only part of a region, while a region can be used for many connections.

-- Add-port: adds the port and communication protocol. Format: port/communication protocol. Protocol: tcp or udp

-- Permanent: Permanently effective. If this parameter is not set, port access becomes invalid after the system is restarted.

[Root @ bogon/] # firewall-cmd -- zone = public -- add-port = 3306/tcp -- permanent
Restart Firewall

[Root @ bogon/] # firewall-cmd -- reload
-----------------------------------------------------------------------

How to change the password after you forget the root password

Stop mysql service, or run systemctl stop mysql

[Root @ bogon/] # service mysql stop
Enter/usr/local/mysql

[Root @ bogon/] # cd/usr/local/mysql/
Start mysql through mysqld_safe and do not start the grant-tables authorization table when mysql is started

[Root @ bogon mysql] #./bin/mysqld_safe -- basedir =/usr/local/mysql \
-- Datadir =/usr/local/mysql/data \
-- Skip-grant-tables &
Log on to mysql

[Root @ bogon/] # mysql-u root mysql
Change root Password

Mysql> UPDATE user SET password = PASSWORD ("new_password") WHERE user = 'root ';
Refresh permission

Mysql> flush privileges;
Exit mysql

Mysql> exit;

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.