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--
This article mainly introduces the simple deployment of Mysql to you, hoping to supplement and update some knowledge, if you have other questions to understand, you can continue to follow my updated article in the industry information.
MySQL is a relational database management system developed by MySQL AB Company of Sweden and currently belongs to Oracle Company. The SQL language used by MySQL is the most commonly used standardized language for accessing databases. 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. This article will explain the simple deployment of mysql.
There are four versions of mysql:
Alpha version: generally only runs within the software development company and is not made public.
Beta version: fully functional development and all the testing work of the product, there will be no major vulnerabilities BUG, and invited and provided to the user experience and testing, in order to more comprehensively test the shortcomings or problems of the software.
RC version: a small version or candidate version before the release of the production process, which is the product after testing beta version 2 collected BUG or deficiencies, repaired and improved according to the information received by the phone.
GA version: a software product that is officially released and is also a production version.
And mysql divides the version route into three for better development.
Upgrade from 5.0 version to 5.1 series version, continue to improve and improve its user experience and performance. At the same time, new functions are added.
In order to better integrate mysqlab company, community and new features. The version number began with 5.4 and has now grown to 5.6
In order to better promote the mysqlcluster version, it has been developed from version 6.0 to version 7.3.
Since there are still differences in compilation and installation methods between mysql product lines, this article will explain the simple deployment of version 5.1.7 and version 5.6.13 of mysql respectively.
Version 5.1.7
Environment
CentOS6.4 x86twin 64-bit uses minimal installation, and the system has been basically optimized.
Selinux is off and iptables is in unlimited mode
Ip:192.168.0.157/24
Mysql version: mysql-5.1.70
Source package location: / server/tools
Source package compilation installation location: / etc/local/ software name
Database location: / mydata
I. preparatory work
1. Deployment of development environment
[root@c64web ~] # yum groupinstall "Development tools"Server Platform Development"-y # install the package groups for these two development environments
[root@c64-web ~] # yum install pcre*-y # install pcre compatible regular expressions
2. Create users and directories
[root@c64-web ~] # useradd-s / sbin/nologin-M mysql # create mysql users, and join the mysql group, do not create a home directory, close login
[root@c64-web ~] # mkdir / mydata # create a database storage directory
[root@c64-web] # chown-R mysql.mysql / mydata
3. Download the source package
[root@c64-web ~] # cd / server/tools
[root@c64-web tools] # wget http://mysql.ntu.edu.tw/Downloads/MySQL-5.1/mysql-5.1.70.tar.gz
II. Compilation and installation
Now that the preparations are done, let's start compiling and installing mysql.
[root@c64-web tools] # tar zxf mysql-5.1.70.tar.gz
[root@c64-web tools] # cd mysql-5.1.70
[root@c64-web mysql-5.1.70] #. / configure\
-- prefix=/usr/local/mysql\ # set the mysql installation path. Default is / usr/local.
-- with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock\ # specify the directory where Mysql socket files are stored
-- localstatedir=/mydata\ # set the location of the data file for mysql
-- enable-assembler\ # allows assembly mode (optimizes performance)
-- enable-thread-safe-client\ # compile the client in a threaded manner
-- with-mysqld-user=mysql\ # specify the system user under which MySQL is running
-- with-big-tables\ # enable large table support
-- without-debug\ # use non-debug mode
-- with-pthread\ # force compilation using the pthread library
-- with-extra-charsets=complex\ # complex character set support
-- with-readline\ # use system readline instead of bundled copy.
-- with-ssl\ # enable ssl encryption
-- with-embedded-server\ # build embedded MySQL library (libmysqld.a)
-- enable-local-infile\ # enables mysql to load the database locally (off by default)
-- with-plugins=partition # mysql partition feature support
-- with-plugins=innobase\ # innobas storage engine support
-- with-mysqld-ldflags=-all-static\ # CVM uses static libraries (optimize performance)
-- with-client-ldflags=-all-static # clients use static libraries (optimize performance)
[root@c64-web mysql-5.1.70] # make & & make install
After doing the above, the mysql-5.1.7 version compiles and installs successfully.
The following is the quick copy, compilation and configuration text:
[root@c64-web mysql-5.1.70] # / configure-- prefix=/usr/local/mysql-5.1.70--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock-- localstatedir=/mydata-- enable-assembler--enable-thread-safe-client-- with-mysqld-user=mysql-- with-big-tables-- without-debug--with-pthread-- with-extra-charsets=complex-- with-readline-- with-ssl--with-embedded- Server-enable-local-infile-with-plugins=partition-with-plugins=innobase-with-mysqld-ldflags=-all-static--with-client-ldflags=-all-static
1. Create a directory soft link
After the mysql installation is complete, we first need to add soft links to the compiled and installed directory. This operation is an important tuning parameter in the production environment, and the purpose of adding this soft link has two points: 1, it is convenient for human use. 2. It is convenient to upgrade the version later.
[root@c64-web mysql-5.1.70] # cd / root
[root@c64-web] # ln-s / usr/local/mysql-5.1.70 / usr/local/mysql
2. Create other corresponding directories and permissions settings
[root@c64-web ~] # mkdir / mydata # set up mysql data file directory
[root@c64-web ~] # chown-R mysql / mydata # authorize mysql users to access the mysql database directory
3. Obtain the Mysql master configuration file and modify it
Because of the main configuration file of mysql, it is not available by default after compilation and installation. So we need to select the configuration file at the end of the prepaid * .cnf in the mysql compilation package and copy it to our / etc/ directory.
[root@c64-web ~] # ll / server/tools/mysql-5.1.70/support-files/*.cnf
-rw-r--r-- 1 root root 4714 November 6 02:25 / server/tools/mysql-5.1.70/support-files/my-huge.cnf
-rw-r--r-- 1 root root 6 November 7, 763 02:25 / server/tools/mysql-5.1.70/support-files/my-innodb-heavy-4G.cnf
-rw-r--r-- 1 root root 4688 November 6 02:25 / server/tools/mysql-5.1.70/support-files/my-large.cnf
-rw-r--r-- 1 root root 4699 November 6 02:25 / server/tools/mysql-5.1.70/support-files/my-medium.cnf
-rw-r--r-- 1 root root 2467 November 6 02:25 / server/tools/mysql-5.1.70/support-files/my-small.cnf # small and medium-sized companies can use this
[root@c64-web mysql-5.1.70] # / bin/cp / server/tools/mysql-5.1.70/support-files/my-small.cnf / etc/my.cnf
Modify the main configuration file / etc/my.cnf of mysql by adding the following line
Datadir=/mydata # our custom database storage directory
4. Let the system identify the software installed by the source package
A) add mysql's library file path to the system's library file search path
Method 1: do soft links directly
[root@c64-web] # ln-s / usr/local/mysql/lib/mysql / usr/lib/mysql
Method 2: import the system library using ldconfig (recommended)
[root@c64web ~] # echo "/ usr/local/mysql/lib" > > / etc/ld.so.conf.d/mysql.conf
[root@c64-web ~] # ldconfig
B) output the header file of mysql to the system header file
[root@c64web ~] # ln-
S / usr/local/mysql/include/mysql / usr/include/mysql
C) configure mysql commands to use the path globally
[root@c64web ~] # echo "PATH=/usr/local/mysql/bin:$PATH" > > / etc/profile
[root@c64-web ~] # source / etc/profil
5. Initialize the database and start as the mysql user
[root@c64-web] # / usr/local/mysql/bin/mysql_install_db-- basedir=/usr/local/mysql-- datadir=/mydata-- user=mysql # initializes the mysql database file
WARNING: The host 'c64murmweb' could not be looked up with resolveip.
This probably means that your libc libraries are not 100% compatible
With this binary MySQL version. The MySQL daemon, mysqld, should work
Normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
When specifying MySQL privileges! # this warning can be eliminated by modifying the localhost after 127.0.0.1 to the current c64-web in the / etc/hosts file.
Installing MySQL system tables...
131108 18:07:26 [Warning]'--skip-locking' is deprecated and will be removed in a future release. Please use'--skip-external-locking' instead. # ignore the warning here
OK
Filling help tables...
131108 18:07:27 [Warning]'--skip-locking' is deprecated and will be removed in a future release. Please use'--skip-external-locking' instead. # ignore the warning here
OK
To start mysqld at boot time you have to copy
Support-files/mysql.server to the right place for your system
# what I mean here is that you can create a quick start script, which we will mention below
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER!
To do so, start the server, then issue the following commands:
/ usr/local/mysql/bin/mysqladmin-u root password' new-password'
/ usr/local/mysql/bin/mysqladmin-u root-h lhh password' new-password'
# teach you how to create a password for root users to access mysql database
Alternatively you can run:
/ usr/local/mysql/bin/mysql_secure_installation
Which will also give you the option of removing the test
Databases and anonymous user created by default. This is
Strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
Cd / usr/local/mysql; / usr/local/mysql/bin/mysqld_safe &
# the above is one of the opening commands, and the latter is meant to be executed in the background
You can test the MySQL daemon with mysql-test-run.pl
Cd / usr/local/mysql/mysql-test; perl mysql-test-run.pl
# here is to show you how to perform the test
Please report any problems with the / usr/local/mysql/scripts/mysqlbug script!
# the above is the information generated during the initialization creation of the mysql database file.
[root@lhh mydata] # cd / usr/local/mysql; / usr/local/mysql/bin/mysqld_safe &
[1] 7146
131108 18:50:37 mysqld_safe Logging to'/ mydata/lhh.err'.
131108 18:50:37 mysqld_safe Starting mysqld daemon with databases from / mydata # you need to hit enter here to return to the command input interface.
Another method of starting mysql Database
[root@c64-web ~] # / bin/cp / server/tools/mysql-5.1.70/support-files/mysql.server / etc/init.d/mysqld # copy the mysql startup script mysql command path
[root@c64-web ~] # chmod 700 / etc/init.d/mysqld # makes the script executable
[root@c64-web] # / etc/init.d/mysqld start # this is one of the ways to start the database
[root@c64-web ~] # / etc/init.d/mysqld stop # method of shutting down database
[root@c64-web ~] # killalll mysqld # another way to shut down the database
6. Check whether the mysql database is started:
[root@c64-web ~] # netstat-lnt | grep 3306
Tcp 0 0 0.0.0.0 3306 0.0.0.015 * LISTEN
As you can see, our mysql service has been started. Here, if port 3306 is not up, please tail-100 / usr/local/mysql/data/ machine name. err check log error report for debugging.
7. Set up the initial account and log in to the backend
Above, when initializing the creation of the mysql database, we have been mentioned how to set a password for the mysql database account, so let's do it.
[root@c64-web ~] # mysqladmin-u root password 123456 # set password
After setting [root@c64-web ~] # history-c #, clear the history to prevent password disclosure.
[root@c64-web ~] # mysql-u root-p # connection database view
Enter password: # enter the password you just set here
Welcome to the MySQL monitor. Commands end with; or\ g.
Your MySQL connection id is 2
Server version: 5.1.70 Source distribution
Copyright (c) 2000, 2013, 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 > show databases; # View existing databases
+-+
| | Database |
+-+
| | information_schema |
| | mysql |
| | test |
+-+
3 rows in set (0.00 sec)
Mysql > select user (); # View existing users
+-+
| | user () |
+-+
| | root@localhost |
+-+
1 row in set (0.00 sec)
Mysql > quit # exit
Bye
At this point, the deployment of our mysql-5.1.17 is complete, and here is the deployment of 5.6.13.
Version 5.6.13
The products of mysql's second product line and the first product line are mainly different in the data storage engine and the method of compilation and installation, so here I will mainly explain the part of compilation and installation, and everything else is more or less the same.
Download address of mysql-5.6.13 source package: http://mysql.ntu.edu.tw/Downloads/MySQL-5.6/mysql-5.6.13.tar.gz
Change the compiler configuration tool to cmake
Note that the following mysql-5.6.x series version uses cmake instead of. / configure when compiling the configuration, so we need to install the cmake tool before we can execute the compiled configuration.
II. Changes in compilation parameters
Detailed explanation of comprehensive compilation parameters for mysql-5.6.x series version:
[root@c64-web mysql-5.6.13] # cmake
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql\ # specify the mysql installation directory
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock\ # Unix socket file path, which is customized to prevent errors.
-DDEFAULT_CHARSET=gbk\ # default character
-DDEFAULT_COLLATION=gbk_chinese_ci\ # check character
-DEXTRA_CHARSETS=all\ # install all extended character sets
-DWITH_MYISAM_STORAGE_ENGINE=1\ # install the myisam storage engine
-DWITH_INNOBASE_STORAGE_ENGINE=1\ # install the innodb storage engine
-DWITH_ARCHIVE_STORAGE_ENGINE=1\ # install the archive storage engine
-DWITH_BLACKHOLE_STORAGE_ENGINE=1\ # install the blackhole storage engine
-DWITH_MEMORY_STORAGE_ENGINE=1\ # install the memory storage engine
-DWITH_FEDERATED_STORAGE_ENGINE=1 # install the frderated storage engine
-DWITH_READLINE=1\ # shortcut key function
-DENABLED_LOCAL_INFILE=1\ # allow data to be imported locally
-DMYSQL_DATADIR=/usr/local/mysql/data\ # Database storage directory
-DMYSQL_USER=mysql\ # Database owner
-DMYSQL_TCP_PORT=3306\ # Database port
-DSYSCONFDIR=/etc\ # MySQL catalog file
-DWITH_SSL=yes # Database SSL
The following is a quick copy execution command:
[root@c64-web mysql-5.6.13] # cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_UNIX_ADDR=/tmp/mysql.sock-DDEFAULT_CHARSET=gbk-DDEFAULT_COLLATION=gbk_chinese_ci-DEXTRA_CHARSETS=all-DWITH_MYISAM_STORAGE_ENGINE=1-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_ARCHIVE_STORAGE_ENGINE=1-DWITH_BLACKHOLE_STORAGE_ENGINE=1-DWITH_MEMORY_STORAGE_ENGINE=1-DWITH_FEDERATED_STORAGE_ENGINE=1-DWITH_READLINE=1-DENABLED_LOCAL_INFILE=1-DMYSQL_DATADIR=/mydata -DMYSQL_USER=mysql-DMYSQL_TCP_PORT=3306-DSYSCONFDIR=/etc-DWITH_SSL=yes
After execution, you still use make&&make install to perform the compilation installation.
III. Adjustment of main configuration file
In the version of the 5.6.X series, the main configuration file of mysql has changed. As you can see, the original my-huge.cnf,my-large.cnf,my-small.cnf template has been removed from the mysql-5.6.13 version and replaced by a my.cnf or my-default.cnf configuration template.
[root@c64-web mysql-5.6.13] # ll / server/tools/mysql-5.6.13/support-files/*.cnf
-rw-r--r--. 1 root root 1126 Nov 8 01:37 / server/tools/mysql-5.6.13/support-files/my-default.cnf
[root@c64-web mysql-5.6.13] # / bin/cp / server/tools/mysql-5.6.13/support-files/my-default.cnf / etc/my.cnf
Also, there are few places that need to be configured in the template file. This is because the mysql-5.6.x series adjusts many parameters with unreasonable default values, and adopts an out-of-box thinking that some values are fixed and some values are automatically set according to other parameters or server configuration at startup, so there is no need to initially specify a lot of values.
After reading the above simple deployment analysis of Mysql, I hope it can bring some help to everyone in practical application. Due to the limited space in this article, it is inevitable that there will be deficiencies and need to be supplemented. If you need more professional answers, you can contact us on the official website for 24-hour pre-sales and after-sales to help you answer questions at any time.
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.