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 files for MySQL, and then run the RM-RFfile name"Delete the remaining MySQL files
(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.20-1.el6.i686.rpm #MySQL客户端程序MySQL-devel-advanced-5.6.20-1.el6.i686.rpm #MySQL的库和头文件MySQL-embedded-advanced-5.6.20-1.el6.i686.rpm #MySQL的嵌入式程序MySQL-S erver-advanced-5.6.20-1.el6.i686.rpm#MySQL服务端程序mysql-shared-advanced-5.6.20-1.el6.i686.rpm#MySQL的共享库mysql-shared-compat-advanced-5.6.20-1.el6.i686.rpm#RHEL兼容包mysql-test-advanced-5.6.20-1.el6.i686.rpm#MySQL的测试组件 |
Generally for development, we only need the following three files to be able.
| Mysql-client-advanced-5.6.20-1.el6.i686.rpmmysql-devel-advanced-5.6.20-1.el6.i686.rpmmysql-server-advanced-5.6.20-1.el6.i 686.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.
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.
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.20-1.el6.i686.rpm RPM-IVH mysql-devel-advanced-5.6.20-1.el6.i686.rpm RPM-IVH mysql-client-advanced-5.6.20-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.
| 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#初始化MySQLservice MySQL start # start MySQLCat/root/.mysql_secret #查看root账号的初始密码, the information shown below will appear
| # The random password set for the root user at Mon 10:26:57 (local time): Zfrmqnpofh3ao5pu |
Mysql-uroot-pzfrmqnpofh3ao5pu#使用root账号登陆MySQLset Password=password (' 123456 '); # Change the MySQL password, note; no lessExit# Exitmysql-uroot-p123456#使用新密码登陆 |
5. Configuration allows remote login.
Use MySQL;Mysql>select Host,user,password from user;+-----------+------+-------------------------------------------+| Host | user | Password |+-----------+------+-------------------------------------------+| localhost | Root | *dfeb299b8a17e376e7804a115f471149953b5645 | | Chenxu | Root | *6E4C48EDF3CC66BC5F6E6C0980935C8ED660EFAA | | 127.0.0.1 | Root | *6E4C48EDF3CC66BC5F6E6C0980935C8ED660EFAA | | :: 1 | Root | *6E4C48EDF3CC66BC5F6E6C0980935C8ED660EFAA |+-----------+------+-------------------------------------------+4 Rows in Set (0.00 sec) Mysql>Update user Set Password=password (' AQJCCMTJ ') where user= ' root ';Query OK, 3 Rows Affected (0.00 sec) rows Matched:4 changed:3 warnings:0 Mysql>Update user set host= '% ' where user= ' root ' and host= ' localhost ';Query OK, 1 row Affected (0.00 sec) Rows matched:1 changed:1 warnings:0 Mysql>flush Privileges;Query OK, 0 rows Affected (0.00 sec) mysql>ExitBye |
6. Set Boot up
[[email protected" local]# chkconfig MySQL on BR style= "Background-color:inherit" >[ [email protected] favccxx local]# chkconfig--list | grep mysql mysql 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.
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=utf8 Character_set_client=utf8 Collation-server=utf8_general_ci Lower_case_table_names=1 max_connections=1000 |
Default file path for 8.MySQL
/var/lib/mysql/ #数据库目录/usr/share/mysql #配置文件目录 /usr/bin #相关命令目录 #启动脚本 |
9. Restart MySQL
[[email protected] local]# service mysql restart Shutting down MySQL. success! Starting MySQL. success! |
It's easy to install MySQL under Linux, but it's also a tedious thing to do, and most of the operations on Linux are done by command. For beginners to remember that all commands are not a wise choice, the best way is to keep some of the usual operations in your notes.
Install MySQL under Linux