Installation of MySQL under Linux OS--go to

Source: Internet
Author: User
Tags change settings crc32 deprecated local time dedicated server

Transferred from: http://www.cnblogs.com/mjorcen/p/4000371.html

Note: Additional URL reference: http://www.linuxidc.com/Linux/2015-01/112583.htm

There are two ways to install MySQL under the Linux operating system:

A type of tar installation,

The other is the RPM installation method.

What is the difference between these two types of installation? Although we commonly use tar to compress/unzip files under Linux, the MySQL file in tar format is only a MySQL file package and cannot be installed directly, it needs to operate configure, make, install and other commands to complete the installation. is a more cumbersome installation method. The RPM format file is the real installation package, equivalent to the Windows EXE file that can be installed directly.

  

This article takes the installation of the MySQL-5.6.21 64-bit version RPM format as an example, detailing how MySQL is installed, and how the 32-bit RPM version is installed.

(a) Delete the old version of MySQL

Before installing, you need to determine if the system has other versions of MySQL installed, and if you have installed other versions of MySQL, you will need to remove and install the new version first. After this article pro-test, the following way to remove the old version of MySQL or MySQL residual files as a convenience.

1. Execute yum command, delete MySQL Lib library, service file

Yum remove MySQL mysql-server mysql-libs mysql-server;

2. Execute the Find command, find the remaining MySQL files, and then run "RM-RF file name" To delete the remaining MySQL files

Find/-name MySQL

(ii) RPM format installation MySQL

Currently, the latest version of MySQL is: 5.6.21, download the MySQL RPM installation package from the official website, after extracting the following six files:

  1. mysql-client-5.6.21-1.linux_glibc2.5.x86_64.rpm #MySQL客户端程序
  2. mysql-devel-5.6.21-1.linux_glibc2.5.x86_64.rpm #MySQL的库和头文件
  3. mysql-embedded-5.6.21-1.linux_glibc2.5.x86_64.rpm #MySQL的嵌入式程序
  4. mysql-server-5.6.21-1.linux_glibc2.5.x86_64.rpm #MySQL服务端程序
  5. mysql-shared-5.6.21-1.linux_glibc2.5.x86_64.rpm #MySQL的共享库
  6. mysql-test-5.6.21-1.linux_glibc2.5.x86_64.rpm #MySQL的测试组件

Generally for development, we only need the following three files to be able.

  1. mysql-devel-5.6.21-1.linux_glibc2.5.x86_64.rpm #MySQL的库和头文件
  2. mysql-server-5.6.21-1.linux_glibc2.5.x86_64.rpm #MySQL服务端程序
  3. mysql-devel-5.6.21-1.linux_glibc2.5.x86_64.rpm #MySQL的库和头文件
1. Before restarting the installation, to ensure that it is foolproof, let us confirm whether there is MySQL's extremely relevant RPM installation package in the system. If there is one, delete it first.
Rpm-qa | Grep-i MySQL

After executing the above command, return empty data, you can take the second step. Otherwise, execute the following command to delete the MySQL related package file.

Yum-y Remove mysql-libs*
2. Copy the previously mentioned three MySQL installation files to the server and perform the following installation commands
RPM-IVH MYSQL-SERVER-5.6.21-1.LINUX_GLIBC2.5.X86_64.RPMRPM-IVH mysql-devel-5.6.21-1.linux_glibc2.5.x86_64.rpmrpm -IVH mysql-client-5.6.21-1.linux_glibc2.5.x86_64.rpm

Debug as follows:

[[Email protected]_32_234_centos tools]# RPM-IVH mysql-server-5.6.21-1.linux_glibc2.5.x86_64.rpmpreparing ... ########################################### [100%] 1:mysql-server RPM-IVH mysql-devel-5.6.21-1.linux _GLIBC2.5.X86_64.RPMRPM-IVH mysql-client-5.6.21-1.linux_glibc2.5.x86_64.rpm################# ################### ######################## [100%]2014-09-29 15:01:50 0 [Warning] TIMESTAMP with implicit the DEFAULT value is deprecated.  --explicit_defaults_for_timestamp server option (see documentation for more details). 2014-09-29 15:01:50 30994 [Note] Innodb:using Atomics to ref count buffer pool pages2014-09-29 15:01:50 30994 [Note] innodb:the InnoDB memory heap is dis  abled2014-09-29 15:01:50 30994 [note] innodb:mutexes and rw_locks use GCC atomic builtins2014-09-29 15:01:50 30994 [note] Innodb:memory barrier is isn't used2014-09-29 15:01:50 30994 [Note] innodb:compressed tables use zlib 1.2.32014-09-29 15: 01:50 30994 [note] InnoDB:Using Linux native aio2014-09-29 15:01:50 30994 [note] innodb:using CPU crc32 instructions2014-09-29 15:01:50 30994 [Note ] innodb:initializing buffer pool, size = 128.0m2014-09-29 15:01:50 30994 [Note] innodb:completed initialization of buff ER pool2014-09-29 15:01:50 30994 [Note] innodb:the first specified data file./ibdata1 did not exist:a new database to B e created!2014-09-29 15:01:50 30994 [note] innodb:setting file./ibdata1 size to a mb2014-09-29 15:01:50 30994 [note] in Nodb:database physically writes the file full:wait ... 2014-09-29 15:01:51 30994 [note] innodb:setting log file./ib_logfile101 size to ~ mb2014-09-29 15:01:52 30994 [note] in nodb:setting log file./ib_logfile1 size to mb2014-09-29 15:01:52 30994 [Note] innodb:renaming log file./ib_logfile1 /ib_logfile02014-09-29 15:01:52 30994 [Warning] innodb:new log files created, lsn=457812014-09-29 15:01:52 30994 [ Note] Innodb:doublewrite buffer not found:creating new2014-09-29 15:01:52 30994 [note] inNodb:doublewrite buffer created2014-09-29 15:01:52 30994 [Note] innodb:128 rollback segment (s) is active.2014-09-29 15: 01:52 30994 [Warning] innodb:creating FOREIGN KEY constraint system tables.2014-09-29 15:01:52 30994 [Note] Innodb:forei GN KEY Constraint system tables created2014-09-29 15:01:52 30994 [Note] innodb:creating tablespace and datafile system TA bles.2014-09-29 15:01:52 30994 [Note] innodb:tablespace and datafile system tables created.2014-09-29 15:01:52 30994 [not E] innodb:waiting for purge to start2014-09-29 15:01:52 30994 [Note] innodb:5.6.21 started; Log sequence number 0A random root password has been set. You'll find it in '/root/.mysql_secret '. 2014-09-29 15:01:53 30994 [note] Binlog end2014-09-29 15:01:53 30994 [note] Inno Db:fts optimize thread exiting.2014-09-29 15:01:53 30994 [Note] innodb:starting shutdown ... 2014-09-29 15:01:54 30994 [Note] Innodb:shutdown completed; Log sequence number 16259772014-09-29 15:01:54 0 [Warning] TIMESTAMP with implicit DEfault value is deprecated.  --explicit_defaults_for_timestamp server option (see documentation for more details). 2014-09-29 15:01:54 31016 [Note] Innodb:using Atomics to ref count buffer pool pages2014-09-29 15:01:54 31016 [Note] innodb:the InnoDB memory heap is dis  abled2014-09-29 15:01:54 31016 [note] innodb:mutexes and rw_locks use GCC atomic builtins2014-09-29 15:01:54 31016 [note] Innodb:memory barrier is isn't used2014-09-29 15:01:54 31016 [Note] innodb:compressed tables use zlib 1.2.32014-09-29 15: 01:54 31016 [note] innodb:using Linux native aio2014-09-29 15:01:54 31016 [Note] innodb:using CPU CRC32 instructions2014 -09-29 15:01:54 31016 [note] innodb:initializing buffer pool, size = 128.0m2014-09-29 15:01:54 31016 [note] Innodb:compl Eted initialization of buffer pool2014-09-29 15:01:54 31016 [Note] innodb:highest supported file format is barracuda.2014 -09-29 15:01:54 31016 [note] innodb:128 rollback segment (s) is active.2014-09-29 15:01:54 31016 [note] InnoDB: Waiting for purge to start2014-09-29 15:01:54 31016 [Note] innodb:5.6.21 started; Log sequence number 16259772014-09-29 15:01:54 31016 [note] Binlog end2014-09-29 15:01:54 31016 [note] innodb:fts Optimiz E thread exiting.2014-09-29 15:01:54 31016 [Note] innodb:starting shutdown ... 2014-09-29 15:01:56 31016 [Note] Innodb:shutdown completed; Log sequence number 1625987A RANDOM PASSWORD have BEEN SET for the MySQL root USER! You'll find that password in '/root/.mysql_secret '. You must change this password on your first connect,no other statement but ' SET password ' would be accepted. See the Manual for the semantics of the ' password expired ' flag. Also, the anonymous user has been removed. In addition, you can run:/usr/bin/mysql_secure_installationwhich would also give you the option of removing the test data Base. This is the strongly recommended for production servers. See the Manual for more instructions. Problems at Http://bugs.mysql.com/The latest InformatioN about MySQL was available on the web at Http://www.mysql.comSupport MySQL by buying support/licenses at HTTP://SHOP.MYSQ L.comnew Default Config file was created as/usr/my.cnf Andwill is used by default by the server when you start it. You could edit this file to the change server Settings[[email protected]_32_234_centos tools]# RPM-IVH mysql-devel-5.6.21-            1.linux_glibc2.5.x86_64.rpmpreparing ########################################### [100%] 1:MySQL-devel ########################################### [100%][[email protected]_32_234_centos tools]# RPM-IVH MySQL-   Client-5.6.21-1.linux_glibc2.5.x86_64.rpmpreparing ... ########################################### [100%]  1:mysql-client ########################################### [100%][[email protected]_32_234_centos tools]#

When the above three commands are executed, only the first command executes a little longer and the next two commands run fast.

3. Execute the following command to copy the MySQL configuration file to the/etc directory.
Cp/usr/share/mysql/my-default.cnf/etc/my.cnf
4. Run the command below to initialize MySQL and set the password.
/usr/bin/mysql_install_db    #初始化MySQL service mysql start        #启动MySQL cat/root/.mysql_secret        #查看root账号的初始密码 , the information shown below will appear

Such as:

[[Email protected]_32_234_centos storage]# service MySQL startstarting MySQL.] success! [[Email Protected]_32_234_centos storage]# cat/root/.mysql_secret# The random password set for the root user at Mon Sep 2 9 15:01:52 (local time): Penfgcgki8unikae
[[Email Protected]_32_234_centos storage]# mysql-u root-ppenfgcgki8unikaewarning:using a password on the command line I Nterface can be insecure. Welcome to the MySQL Monitor.  

--Set Password=password (' 123456 '); # change the MySQL password,

Mysql> set Password=password (' 123456 '); Query OK, 0 rows Affected (0.00 sec)
5. Set Boot up
Chkconfig MySQL on
[Email protected]_32_234_centos storage]# chkconfig MySQL on [[email Protected]_32_234_centos storage]# chkconfig-- List | grep mysqlmysql           0:off   1:off   2:on    3:on    4:on    5:on    6:off

In the above printed content, the 2~5 is on and the boot is on.

6. Modify/ETC/MY.CNF

Setting the MySQL character set, configuring MySQL to indicate case insensitivity (by default, MySQL is case-sensitive for table names, and column names are case-insensitive). Under [Mysqld], add the following:

Character_set_server=utf8 Character_set_client=utf8 collation-server=utf8_general_ci Lower_case_table_names=1 max_ connections=1000

Default file path for 7.MySQL

  1. /var/lib/mysql/#数据库目录
  2. /usr/share/mysql #配置文件目录
  3. /usr/bin #相关命令目录 #启动脚本

8. Modify the data file path

1. Modify the/etc/my.cnf file

Vi/etc/my.cnf

# for advice The change settings see# http://dev.mysql.com/doc/refman/5.6/en/ server-configuration-defaults.html# * * * does not EDIT the this FILE.  It's a template which'll be copied to the# * * * default location during install, and would be replaced if you# * * * Upgrade To a newer version of MySQL. [mysqld]# Remove leading # and set to the amount of RAM for the most important data# cache in MySQL. Start at 70% of all RAM for dedicated server, else 10%.# innodb_buffer_pool_size = 128m# Remove Leading # to turn on a V  ery important data Integrity option:logging# changes to the binary log between backups.# log_bin# These is commonly set, Remove the # and set as required. #basedir =/storage/server/mysql-5.6.21-1/datadir =/storage/server/mysql-5.6.21-1/data Port = 3306server_id = 2socket =/storage/server/mysql-5.6.21-1/data/mysql.sockpid-file =/storage/server/  mysql-5.6.21-1/data/vm_32_234_centos.pid# Remove Leading # To set options mainly useful for reporting servers.# the server DeFaults is faster for transactions and fast selects.# Adjust sizes as needed, experiment to find the optimal values.# join _buffer_size = 128m# Sort_buffer_size = 2m# read_rnd_buffer_size = 2msql_mode=no_engine_substitution,strict_trans_ TABLES

Copying files/var/lib/mysql/to/storage/server/mysql-5.6.21-1/data/

Cp-r/var/lib/mysql/*/storage/server/mysql-5.6.21-1/data/

9. Restart MySQL
# service MySQL restart shutting down MySQL. success! Starting MySQL. success!

Installation of MySQL under Linux OS--go to

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.