CentOs7 64-bit mysql-5.6.35 source code installation, centos source code installation php5.6

Source: Internet
Author: User

CentOs7 64-bit mysql-5.6.35 source code installation, centos source code installation php5.6

First install the dependency package to avoid problems during installation

[root@bogon liuzhen]# yum -y install gcc 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 perl-devel

The preceding dependency package can also be installed in one line.

[root@bogon liuzhen]# yum -y install gcc gcc-c++ cmake ncurses-devel autoconf perl 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 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

[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 passwordNew 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 2Server version: 5.6.35 Source distributionCopyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.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 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 '123456';

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 '123456';

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 '123456';

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 '123456';

 

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.