Mysql operation and Maintenance Management-mysql database multiple installation methods

Source: Internet
Author: User
Tags chmod mysql in

MySQL Database installation 1 yum/rpm mode installation

Note: The yum/rpm way to install MySQL is suitable for all MySQL software PRODUCT families.

(1) RPM package installation MySQL
We have to install the Mysql-server and mysql.client packages, the RPM installation is very simple here will not say.

(2) Yum mode install MySQL
The Yum installation is simple, as long as you execute the Yum install Mysql-server–y.
Large portal to the source code according to the needs of enterprises to make RPM, set up Yum Warehouse, yum install xxx-y. 2 How to choose the correct way to install MySQL

Binary installation is simple and convenient, suitable for 5.0-5.1 and 5.5-5.6 series, is a lot of professional DBA choice, ordinary Linux operation and maintenance personnel to use the way of compiling, 5.0-5.1 series is the conventional way of compiling, 5.5-5.6 or more series is cmake compile the way. Therefore, mysql5.5 and above, the installation of a small number of machines, recommended CMake compiling method, which is the choice of most operations personnel. If you have a large quantity, you can use binary to install it. It's no problem.

3 install MySQL in binary mode without compiling.

Using binary method to install MySQL without compiling, this method and YUM/RPM package installation method is similar, suitable for all kinds of MySQL product line, do not need to complex compilation settings and compile time wait, directly unzip the downloaded package, initialize to complete the installation of MySQL start. 4 compile and install MySQL with CMake method

Due to the particularity of the mysql5.5.xx-5.6.xx product line, the compiling method is also different from the early-riser product installation method, which is compiled and installed in CMake or Gmake way.

SOURCE CMake Way Compile install MySQL5.5.32 4.1 download MySQL installation package

MySQL uses the CMake installation method starting from 5.3.

The actual combat selection mysql5.5.32

MySQL Series
Http://dev.mysql.com/downloads/mysql/5.5.html#downloads

Download CMake
wget http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz 4.2 Viewing the system environment

[[email protected] ~]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 6.7 (Santiago)[[email protected] ~]# uname -mx86_64[[email protected] ~]# uname -r2.6.32-573.el6.x86_64
4.3 Installing CMake
[[email protected] ~]# mkdir -p /home/zbf[[email protected] ~]# mkdir -p /home/zbf/tools[[email protected] ~]# cd /home/zbf/tools/[[email protected] tools]# tar -zxf cmake-2.8.8.tar.gz [[email protected] tools]# cd cmake-2.8.8[[email protected] cmake-2.8.8]# ./configure

Hint to install with gmake, with make also can

[[email protected] cmake-2.8.8]# gmake[[email protected] cmake-2.8.8]# gmake install

Install dependent packages

[[email protected] tools]# yum install ncurses-devel -y
4.5 Start Installation mysql4.5.1 Create users and Groups
[[email protected] tools]# groupadd mysql[[email protected] tools]# useradd -g mysql mysql
4.5.2 Decompression compiled MySQL
[[email protected] tools]# tar-zxf mysql-5.5.32.tar.gz[[email protected] tools]# CD Mysql-5.5.32[[email  protected] mysql-5.5.32] #cmake. -dcmake_install_prefix=/usr/local/mysql #指定安装目录-dmysql_datadir=/usr/local/mysql/data #指定数据存放目录重要-DMYSQL_UNIX_A Ddr=/usr/local/mysql/tmp/mysql.sock #指定sock路径-ddefault_charset=utf8 #指定默认字符集-ddefault_collation=utf8_general_ci # Specifies the calibration character set encoding-dextra_charsets=all #安装所需字符集-denabled_local_infile=on #启用加载本地数据-dwith_innobase_storage_engine=1 #支持i Nnode engine-dwith_federated_storage_engine=1 #支持federated引擎-dwith_blackhole_storage_engine=1 #支持黑洞存储引擎-dwithout_     Example_storage_engine=1-dwithout_partition_storage_engine=1 #支持安装数据库分区-dwith_fast_mutexes=1-dwith_zlib=bundled  #zlib压缩模式-denabled_local_infile=1-dwith_readline=1-dwith_embedded_server=1-dwith_debug=0 #禁用debug, turn on impact performance [[email protected] mysql-5.5.32]# make && make install[[email protected] mysql-5.5.32]# ln-s/home/ Zbf/tools/mysql-5.5.32/usr/local/mysql/ 

Special Note: The installation method of the general configure compiling method and the installation of the compiler-free way, and so on, are different in the above process, the same as below. 4.5.3 Initializing configuration MySQL4.5.3.1 Viewing the default template configuration file

[[email protected] mysql-5.5.32]# ll support-files/my*cnf-rw-r--r--. 1 root root  4723 1月  11 19:03 support-files/my-huge.cnf-rw-r--r--. 1 root root 19791 1月  11 19:03 support-files/my-innodb-heavy-4G.cnf-rw-r--r--. 1 root root  4697 1月  11 19:03 support-files/my-large.cnf-rw-r--r--. 1 root root  4708 1月  11 19:03 support-files/my-medium.cnf-rw-r--r--. 1 root root  2872 1月  
4.5.3.2 Selecting a configuration file

Configuration file Many of us choose a small one because it's a test environment

[[email protected] mysql-5.5.32]# cp support-files/my-small.cnf /etc/my.cnfcp:是否覆盖"/etc/my.cnf"? y
4.5.3.3 Configuring environment variables
[[email protected] mysql-5.5.32]# echo ‘export PATH=/usr/local/mysql/bin:$PATH‘ >> /etc/profile[[email protected] mysql-5.5.32]# tail -1 /etc/profileexport PATH=/usr/local/mysql/bin:$PATH[[email protected] mysql-5.5.32]# source /etc/profile[[email protected] mysql-5.5.32]# echo $PATH/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

Be sure to put the/usr/local/mysql/bin in front of you, because there is likely to be a yum installed client in the system installed later. If you don't put/usr/local/

Mysql/bin is placed in front of the MySQL command that calls system RPM when we enter MySQL. Here is an example of a configuration environment variable, the following example from an old boy

Teacher's blog. You can take a look at http://blog.51cto.com/oldboy/1122867. 4.5.3.4 Initializing data files

It's already there. Create a MySQL data file directory

[[email protected] mysql-5.5.32]# ll /usr/local/mysql/data/总用量 4drwxr-xr-x. 2 root root 4096 1月  11 19:17 test

Authorizing MySQL users to access MySQL's installation directory

[[email protected] mysql-5.5.32]# chown -R mysql.mysql /usr/local/mysql/data/

Adjust/TMP permissions, otherwise initialization will be wrong

[[email protected] mysql-5.5.32]# chmod -R 1777 /tmp/

Initialization note This initialization is not the same as 5.1, under scripts

[[email protected] mysql-5.5.32]# cd /usr/local/mysql/scripts/[[email protected] scripts]# ./mysql_install_db --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --user=mysql

Now that the MySQL installation is complete, we must look at the initialized information after the installation, because it

Give us a hint of a lot of information.

Installing MySQL system tables...##### #初始化成功的关键是有两个OK, there are generally two OK to indicate the success of the initialization, there is a warning without tube okfilling help tables ... ok## #这个是启动脚本, prompted for the copy startup script to start Mysqlto start mysqld at boot time, which has to Copysupport-files/mysql.server For your systemplease REMEMBER to SET A PASSWORD for the MySQL root USER! To does, start the server, then issue the following commands:#### #mysql没有密码可以改密码/usr/local/mysql//bin/mysqladmin-u root Password ' new-password '/usr/local/mysql//bin/mysqladmin-u root-h mysql password ' new-password ' alternatively you can Run:/usr/local/mysql//bin/mysql_secure_installationwhich would also give you the option of removing the testdatabases and a  Nonymous user created by default. This isstrongly recommended for production servers. See the Manual for more instructions.### #如果想启动mysql, can start with the following method of the MySQL daemon with:cd/usr/local/mysql/; /usr/local/mysql//bin/mysqld_safe &## #如果想测试可以用这个方法测试You can test the MySQL daemon with mysql-test-run.plcd/usr/ Local/mysql//mysqL-test; Perl mysql-test-run.pl## #如果想汇报bug可以用这个方法汇报bugPlease Report no problems with The/usr/local/mysql//scripts/mysqlbug script!
4.5.3.5 copy MySQL startup script, start MySQL
[[email protected] mysql-5.5.32]# cp support-files/mysql.server /etc/init.d/mysqld[[email protected] mysql-5.5.32]# chmod +x /etc/init.d/mysqld [[email protected] mysql-5.5.32]# /etc/init.d/mysqld startStarting MySQL.. SUCCESS![[email protected] ~]# chkconfig mysqld on[[email protected] ~]# chkconfig --list mysqldmysqld  0:关闭    1:关闭    2:启用    3:启用    4:启用    5:启用    6:关闭
4.6 Simple Optimization 4.6.1 clear and modify Admin user
ysql> select user,host from mysql.user;+------+-----------+| user | host  |+------+-----------+| root | 127.0.0.1 || root | ::1   ||  | localhost || root | localhost ||  | mysql || root | mysql |+------+-----------+6 rows in set (0.01 sec)mysql> delete from mysql.user where user="";Query OK, 2 rows affected (0.07 sec) mysql> delete from mysql.user where host="mysql";Query OK, 1 row affected (0.00 sec)mysql> delete from mysql.user where host="::1";Query OK, 1 row affected (0.00 sec)
4.6.2 Deleting the test library
mysql> show databases;+--------------------+| Database   |+--------------------+| information_schema || mysql  || performance_schema || test   |+--------------------+4 rows in set (0.01 sec)mysql> drop database test;Query OK, 0 rows affected (0.11 sec)
4.6.3 quit MySQL and change the password for MySQL

It's easy to change the password. The preceding initialization information has been explained

[[email protected] ~]# /usr/local/mysql//bin/mysqladmin -u root password ‘123456‘[[email protected] ~]# mysql -uroot -p123456

Mysql operation and Maintenance Management-mysql database multiple installation methods

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.