Install MySQL under Linux

Source: Internet
Author: User
Tags local time

There are two ways to install MySQL under the Linux operating system: one for the tar installation and one for the RPM installation. 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.20 32-bit version RPM format as an example, detailing how MySQL is installed, and how the 64-bit RPM version is installed. (a) Remove the old version of MySQL before installing to determine whether the system has installed other versions of MySQL, such as the installation of other versions of MySQL, you need to remove and then install the new version.  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

/ -name MySQL
(ii) RPM format installation MySQL Currently, the latest version of MySQL is: 5.6.20, download the MySQL RPM installation package from the official website, after extracting the following seven files:
Mysql-Client-Advanced-5.6. --1. el6.i686.rpm #MySQL客户端程序MySQL-Devel-Advanced-5.6. --1. el6.i686.rpm #MySQL的库和头文件MySQL-Embedded-Advanced-5.6. --1. el6.i686.rpm #MySQL的嵌入式程序MySQL-Server-Advanced-5.6. --1. el6.i686.rpm #MySQL服务端程序MySQL-Shared-Advanced-5.6. --1. el6.i686.rpm #MySQL的共享库MySQL-Shared-Compat-Advanced-5.6. --1. el6.i686.rpm #RHEL兼容包MySQL-Test-Advanced-5.6. --1. el6.i686.rpm #MySQL的测试组件

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

Mysql-Client-Advanced-5.6. --1. El6.i686.rpmMySQL-Devel-Advanced-5.6. --1. El6.i686.rpmMySQL-Server-Advanced-5.6. --1. el6.i686.rpm

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.

- | -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.

-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-Advanced-5.6. --1. el6.i686.rpm rpm-IVH MySQL-Devel-Advanced-5.6. --1. el6.i686.rpm rpm-IVH MySQL-Client-Advanced-5.6. --1. el6.i686.rpm
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.
/usr/share/mysql/my-default/etc/ My.cnf

4. Run the command below to initialize MySQL and set the password.

/Usr/Bin/mysql_install_db #初始化MySQLservice MySQL start # start Mysqlcat/Root/. Mysql_secret #查看root账号的初始密码, the following information will appear # The random passwordSet  forThe rootUserAt Mon - Ten: -: $  the(local time): Zfrmqnpofh3ao5pumysql-Uroot-Pzfrmqnpofh3ao5pu #使用root账号登陆MySQLSetPassword=Password'123456'); # change the MySQL password, note; no lessExit# quit MySQL-Uroot-p123456 #使用新密码登陆

5. Configuration allows remote login.

 UseMysql;mysql> SelectHostUser, password from User;+-----------+------+-------------------------------------------+|Host| User |Password|+-----------+------+-------------------------------------------+|localhost|Root| *dfeb299b8a17e376e7804a115f471149953b5645||Chenxu|Root| *6e4c48edf3cc66bc5f6e6c0980935c8ed660efaa|| 127.0.0.1 |Root| *6e4c48edf3cc66bc5f6e6c0980935c8ed660efaa||::1 |Root| *6e4c48edf3cc66bc5f6e6c0980935c8ed660efaa|+-----------+------+-------------------------------------------+4Rowsinch Set(0.00sec) MySQL> Update User SetPassword=Password'AQJCCMTJ')where User='Root'; Query OK,3Rows Affected (0.00sec) Rows matched:4Changed:3Warnings:0MySQL> Update User SetHost='%' where User='Root'  andHost='localhost'; Query OK,1Row affected (0.00sec) Rows matched:1Changed:1Warnings:0MySQL>FlushPrivileges; Query OK,0Rows Affected (0.00sec) MySQL> ExitBye

6. Set Boot up

[[email protected] local]# chkconfig MySQL on [[email protected] local]# chkconfig--List | grep mysqlMysql0: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. 7. Modify/ETC/MY.CNF, set MySQL character sets, configure MySQL to indicate case-insensitive (by default, MySQL is case-sensitive for table names, column names are case-insensitive). Under [Mysqld], add the following:
Character_set_server=utf8character_set_client=UTF8  collation- Server=utf8_general_cilower_case_table_names=1max_connections =  +

Default file path for 8.MySQL

/ var /lib/mysql/               #数据库目录 /usr/share/MySQL              #配置文件目录 /usr/bin                     #相关命令目录 # startup script

9. Restart MySQL

[[email protected] local] # service MySQL restart shutting down MySQL. success! Starting MySQL. Success!

Install MySQL under Linux

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.