In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
I don't know if you have any knowledge about the detailed tutorials similar to the compilation and installation of MySQL version 5.7. today I'm here to give you a brief introduction. If you are interested, let's take a look at the body. I believe you will gain something after reading the detailed tutorials on the compilation and installation of MySQL version 5.7.
1. Overview of Mysql:
1.1.Overview of Mysql
MySQL is a relational database management system developed by MySQL AB Company of Sweden and currently belongs to Oracle Company.
MySQL is the most popular relational database management system, and MySQL is one of the best RDBMS (Relational Database Management System: relational database management system) applications in WEB applications.
MySQL is an associated database management system that stores data in different tables instead of all data in a large warehouse, which increases speed and flexibility.
The SQL language used by MySQL is the most commonly used standardized language for accessing databases. MySQL software adopts the dual licensing policy, which is divided into community version and commercial version. Because of its small size, high speed and low total cost of ownership, especially open source, the development of small and medium-sized websites generally choose MySQL as the website database. Because of the excellent performance of its community version, it can form a good development environment with PHP and Apache.
Dual licensing policy: open source version and commercial version. For example, many companies sell applications such as Microsoft, Apple, and Oracle;, such as Red Hat and IBM, and make money by providing sales support, hosting, or consulting services for their open source software. Companies can release their software through open source, or they can sell commercial versions of the software at the same time.
1.2.Overview of SQL
Structured query language (Structured Query Language), referred to as SQL, is a special purpose programming language, a database query and programming language for accessing data and querying, updating and managing relational database systems, as well as an extension of database script files.
From the above, we can see that there are about two kinds of jobs related to our database: DBD and DBA.
Dba is the database administrator database administrator
Dbd is the database developer database developer
SQL is an American standard for database language adopted by the American National Standards Institute (ANSI) in October 1986, and then the International Organization for Standardization (ISO) issued a formal international standard for SQL. In April 1989, ISO put forward the SQL89 standard with integrity characteristics, and in November 1992, the SQL92 standard was published. In this standard, the database is divided into three levels: basic set, standard set and complete set.
1.3.The structure of SQL statement
Structured query language consists of six parts
1.3.1, data query language (DQL)
Its statement, also known as a "data retrieval statement", is to query data from a table.
1.3.2. Data manipulation language (DML):
Add, modify, and delete data records in the table. Also known as Action query language.
1.3.3. Transaction language (TPL):
It consists of multiple sql statements as a whole, and its statements ensure that all records in the table modified by the DML statement are updated in a timely manner.
1.3.4. Data Control language (DCL):
Set access to the database.
1.3.5. Data definition language (DDL)
Create or delete tables (CREAT TABLE or DROP TABLE) in the database; add indexes to the tables, and so on.
1.3.6. Pointer Control language (CCL):
Its statements, such as DECLARE CURSOR,FETCH INTO and UPDATE WHERE CURRENT, are used for separate operations on one or more forms.
2. Install mysql with source code
2.1. Prepare the experimental environment
2.1.1. Prepare the source code package
Method 1:
Upload mysql installation package and boost installation package to our CVM
[root@cong11 ~] # ls
Anaconda-ks.cfg boost_1_59_0.tar.bz2 mysql-5.7.26.tar.gz
Method 2:
Download address of mysql:
Https://dev.mysql.com/downloads/mysql/5.7.html#downloads
Note: the source code package mysql-community-5.7.26-1.el7.src.rpm ends with .src.rpm is available on the official website. Rpm-ivh is required to install this package, generate the directory file of rpmbuild in the current directory, and then the source code package that ends with .tar.gz in the rpmbuild/SOURCES/ directory.
2.1.2. Configure local yum source
[root@cong11 ~] # mount / dev/sr0 / mnt
[root@cong11 ~] # vim / etc/yum.repos.d/centos7.repo
[centos7]
Name=CentOS7
Baseurl= file:///mnt
Enable=1
Gpgcheck=0
Clear / generate yum cache after configuration
[root@cong11 ~] # yum clean all
[root@cong11 ~] # yum makecache
[root@cong11 ~] # yum-y groupinstall base / / this package has most command tools.
Uninstall boost
After MySQL version 5.7, you must have boost support. It is recommended to uninstall the boost library that comes with the system and use a higher version.
[root@cong11 ~] # yum-y remove boost-*
Decompress the boost_1_59_0.tar.bz2 we uploaded to the root directory, and specify the boost directory for installation later.
Install the bzip2 decompression tool and extract the boost_1_59_0.tar.bz2
[root@cong11 ~] # yum install-y bzip2
[root@cong11 ~] # tar-jxvf boost_1_59_0.tar.bz2
2.1.3. Uninstall the mysql that comes with the system
# rpm-qa | grep-E'(mysql | mariadb)'
# rpm-e mariadb-- nodeps
[root@cong11 ~] # yum-y remove mysql*
[root@cong11 ~] # yum-y remove mariadb*
2.2.install mysql
2.2.4. Install the MYSQL dependency package
Mysql needs to be compiled using cmake, so cmake needs to be installed, and version 5.7 cmake version is no less than 2.8
[root@cong11 ~] # yum install-y cmake make gcc gcc-c++ bison ncurses ncurses-devel
2.2.5. Add mysql users and user groups
[root@cong11 ~] # groupadd mysql
[root@cong11] # useradd-M-s / sbin/nologin-r-g mysql mysql
2.2.6. Create a mysql database location and modify directory permissions
[root@cong11 ~] # mkdir-p / usr/local/mysql/ {data,log}
[root@cong11] # chown-R mysql:mysql / usr/local/mysql/
Note: the data data directory of mysql in the production environment will be placed on a separate hard disk (the ability to write data and logs in parallel to improve efficiency)
2.2.7. Decompress the source package
[root@cong11 ~] # tar-zxvf mysql-5.7.26.tar.gz
2.2.8. Pre-compilation (configuration. / configure)
Pre-compilation requires us to specify the parameters or modules of the installation service. We will also test the compilation environment. Only after passing the test can we compile. The failure of pre-compilation is usually due to the lack of compilation environment GCC or other dependent packages. We need to precompile again after manually installing the dependency package.
[root@cong11 ~] # 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=/usr/local/mysql/mysql.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\
-DDOWNLOAD_BOOST=1\
-DWITH_BOOST=/root/boost_1_59_0 # specifies the boost directory we just extracted
Detailed address of the official website:
Https://dev.mysql.com/doc/refman/5.7/en/source-configuration-options.html
Parameter comments:
DCMAKE_INSTALL_PREFIX: specify the installation directory of the MySQL program, default / usr/local/mysql
DEFAULT_CHARSET: specifies the default character set of CVM, and the default latin1
DEFAULT_COLLATION: specifies the default proofreading rule of the CVM, and the default latin1_general_ci
ENABLED_LOCAL_INFILE: specifies whether to allow local execution of LOAD DATA INFILE, default OFF
WITH_COMMENT: specify compilation remarks information
WITH_xxx_STORAGE_ENGINE: specify the storage engine that is statically compiled to mysql. MyISAM, MERGE,MEMBER and CSV engines are compiled to the CVM by default. No special specification is required.
WITHOUT_xxx_STORAGE_ENGINE: specifies a storage engine that is not compiled
SYSCONFDIR: initialization parameter file directory
MYSQL_DATADIR: data file directory
MYSQL_TCP_PORT: service port number. Default is 3306.
MYSQL_UNIX_ADDR:socket file path, default / tmp/mysql.sock
Detect the execution result of the command
[root@cong11 ~] # echo $? # 0 indicates that the previous command was executed successfully, while the others failed.
0
2.2.9, compilation
[root@cong11 ~] # make-j $(grep processor / proc/cpuinfo | wc-l)
Make-j 4 # Note:-j is used to specify the number of CPU cores to speed up compilation.
Detect the execution result of the command
[root@cong11] # echo $?
0
Check the number of CPU cores on CVM
[root@cong11 ~] # grep processor / proc/cpuinfo | wc-l
four
2.2.10. Installation
[root@cong11 ~] # make install
Detect the execution result of the command
[root@cong11] # echo $?
0
2.2.11. Modify mysql directory permissions
[root@cong11 mysql-5.7.26] # chown-R mysql:mysql / usr/local/mysql/
2.2.12. Generate my.cnf configuration file
Backup configuration file
[root@cong11 ~] # mv / etc/my.cnf {, .bak} = = mv / etc/my.cnf / etc/my.cnf.bak
Create your own my.cnf configuration file
[root@cong11 ~] # vim / etc/my.cnf
[mysqld]
Basedir=/usr/local/mysql # mysql installation directory
Datadir=/usr/local/mysql/data # mysql data storage directory
Port=3306 # mysql listening Port
Socket=/usr/local/mysql/mysql.sock # mysql.sock file storage directory
Symbolic-links=0 # closes symbolic links to mysql
Character-set-server=utf8 # specifies that the character set of mysql is utf8
Log-error=/usr/local/mysql/log/mysqld.log # specify the error log storage path for mysql
Pid-file=/usr/local/mysql/mysqld.pid # mysql pid file storage directory
Note: all mysql users in directories specified by my.cnf must have read and write permissions. Symbolic-links symbolic links support storing mysql database files in other directories. When our mysql data disk is full, we can start symbolic-links=1 (symbolic links are allowed), put mysql data in other directories, and then link to mysql's datadir directory.
2.2.13. Generate service startup script
[root@cong11 ~] # cp / usr/local/mysql/support-files/mysql.server / etc/init.d/mysqld
[root@cong11 ~] # chmod + x / etc/init.d/mysqld # add execution permissions to the script
2.2.14. Add mysqld to boot self-startup
[root@cong11 ~] # chkconfig-- add mysqld # add mysql to the system service
[root@cong11 ~] # chkconfig mysqld on # add mysql to boot self-startup
[root@cong11 ~] # chkconfig-- list mysqld # View mysql boot status
2.2.15. Initialize the database (create the system table of the database)
Start mysql first if it cannot be initialized
[root@cong11] # / usr/local/mysql/bin/mysqld-- initialize-insecure-- user=mysql\
-basedir=/usr/local/mysql-datadir=/usr/local/mysql/data
2.2.16. Start the service
[root@cong11 ~] # / etc/init.d/mysqld start
Starting MySQL SUCCESS!
2.2.17. Add path path:
Add the mysql command path to the path environment variable or softly connect the mysql command path to the directory that already exists in the path environment variable, so that we can directly execute mysql-related commands anywhere on the system
[root@cong11 ~] # vim / etc/profile add the following two lines at the end of the file
Export MYSQL_HOME=/usr/local/mysql
Export PATH=$PATH:$MYSQL_HOME/bin
Make the changes effective
[root@cong11 ~] # source / etc/profile
Or:
[root@cong11] # ln-s / usr/local/mysql/bin/* / usr/local/bin/
2.2.18. Modify the mysql password:
[root@cong11 ~] # mysqladmin-u root password "123456"
Or log in to mysql to change the password
[root@cong11 ~] # mysql
Mysql > set password for 'root'@'localhost'=password (' 123456')
2.2.19. Log in to mysql
[root@cong11] # mysql-uroot-p123456
Mysql > show databases
+-+
| | Database |
+-+
| | information_schema |
| | mysql |
| | performance_schema |
| | sys |
+-+
4 rows in set (0.00 sec)
What to do after the administrator forgets the MySQL password.
1. First write / etc/my.cnf
Skip-grant-tables
two。 Restart the mysql service
[root@Centos4 ~] # / etc/init.d/mysqld stop
[root@Centos4 ~] # / etc/init.d/mysqld start
3. Enter mysql
[root@Centos4 ~] # mysql / / enter directly by hitting enter at this time
Mysql > update mysql.user set authentication_string=password ('123.com') where user='root'
Mysql > FLUSH PRIVILEGES; / / refresh user authorization information
The above indicates that the root password will be updated to 123.com
4. Edit the / etc/my.cnf file again to remove skip-grant-tables
5. Just enter the password again.
[root@Centos4] # mysql-u root-p
What do you think of this article after reading the detailed tutorial on compilation and installation of MySQL version 5.7? If you want to know more about it, you can continue to follow our industry information section.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.