rhel5.8 Installing MySQL Test

Source: Internet
Author: User

mysql-rhel5.8 Installation:
There are three ways to install MySQL under Linux: the first binary files with RPM are installed, the second is to compile the source code after installation, the last is to install the binary tar.gz file (this installation method to download the installation files, directly unzip, put
To the specified directory, and then modify the configuration file)
The default installation directory for MySQL is/usr/share/mysql

1. Check the old version and uninstall
Stop the MySQL service and remove the previously installed MySQL directory
[Email protected]/]# Rpm-qa | Grep-i MySQL
Mysql-server-advanced-5.6.23-1.rhel5
Mysql-client-advanced-5.6.23-1.rhel5
[Email protected]/]# Rpm-ev mysql-server-advanced-5.6.23-1.rhel5 mysql-client-advanced-5.6.23-1.rhel5
Delete residual files:
[[email protected] mysql]# Find/-name mysql* found all the MySQL directories and removed.
Rm-rf/usr/share/mysql
Rm-rf/var/lib/mysql
Rm-rf/usr/lib64/mysql
Rm-rf/var/lib/mysql
Rm-rf/etc/my.cnf.d
......

2. Install MySQL server and client
Download RPM installation package: Https://edelivery.oracle.com/EPD/Search/handle_go
Version: MySQL Database 5.6.23 RPM for Oracle Linux/rhel 5 x86 (64bit) v74393-01
[Email protected]/]# cat/etc/issue
Red Hat Enterprise Linux Server release 5.8 (Tikanga)
Kernel \ r on an \m
-----------
[Email protected] MySQL 5.6.23-rmp]# RPM-IVH mysql-server-advanced-5.6.23-1.rhel5.x86_64.rpm
Preparing ... ########################################### [100%]
1:mysql-server-advanced ########################################### [100%]
Warning:user MySQL does not exist-using root
Warning:group MySQL does not exist-using root
[[email protected] MySQL 5.6.23-RMP for oraclelinux or rhel5-x86-64v74393-01]# RPM-IVH mysql-client-advanced-5.6.23-1.rhel5.x86_64.rpm
Preparing ... ########################################### [100%]
1:mysql-client-advanced ########################################### [100%]

[[email protected] MySQL 5.6.23-rmp]# cat/etc/passwd|grep mysql--Automatically create MySQL user and MySQL group
Mysql:x:101:157:mysql Server:/var/lib/mysql:/bin/bash
[[email protected] MySQL 5.6.23-rmp]# Cat/etc/group | grep MySQL
mysql:x:157:
[[email protected] MySQL 5.6.23-rmp]# MySQL
Error 2002 (HY000): Can ' t connect to local MySQL server through socket '/var/lib/mysql/mysql.sock ' (2)--Start MySQL first or error
[[email protected] MySQL 5.6.23-rmp]#/etc/init.d/mysql start
Starting MySQL ... [OK]
[[email protected] MySQL 5.6.23-rmp]#/etc/init.d/mysql status
MySQL running (13003) [OK]

3. Log in to MySQL
The command to log in to MySQL is MySQL, and MySQL uses the following syntax:
MySQL [-u username] [-h host] [-p[password]] [dbname]
Username and password are mysql user name and password, MySQL's initial management account is root, no password, note: This root user is not a Linux system user. MySQL Default user is root, because the initial no password, the first time to enter the only need to type MySQL.
The login format after adding the password is as follows:
Mysql-u root-p
Enter Password: (enter password)
Where-u followed by the user name,-p requires a password, enter the password at the input password.
Note: This MySQL file is in the/usr/bin directory, and the boot file/etc/init.d/mysql is not a file.
[[email protected]/]# MySQL
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 2
Server version:5.6.23-enterprise-commercial-advanced MySQL Enterprise server-advanced Edition (commercial)

Copyright (c), Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

Mysql>

================
Other:
How to start MySQL:
Command:/etc/init.d/mysql start or service MySQL Start/stop/restart
Check Port Status:
MySQL default port is 3306, after the installation started successfully, you can use the command to view the 3306 port status
Command: Netstat-nat | grep 3306
Or: NETSTAT-NTLP
-----------------------

MySQL Related directories:
1. Database Directory
/var/lib/mysql/
By default, MySQL writes error log files, binary log files, and process files in the/var/lib/mysql directory, such as Localhost.err, Localhost.pid, localhost-bin.001, and so on.
2. Configuration files
/usr/share/mysql (mysql.server command and configuration file)
3. Related commands
/usr/bin (Mysqladmin mysqldump and other commands)
4. Startup script
/etc/rc.d/init.d/(startup script file for MySQL directory)
such as:/etc/rc.d/init.d/mysql Start/restart/stop/status


4. Set MySQL auto-start
See if MySQL is in the auto-start list
[Email protected] mysql]#/sbin/chkconfig--list
Add MySQL to your system's startup service group
[[email protected] mysql]#/sbin/chkconfig–-add MySQL
Remove MySQL from the Startup service group.
[[email protected] mysql]#/sbin/chkconfig–-del MySQL


5. Change MySQL Data directory
The default data file storage directory for MySQL is/var/lib/mysql. The following steps are required if you want to move the directory to/home/data:
1. Set up the data directory in the home directory
Cd/home
mkdir data

2. Stop the MySQL service process:
Mysqladmin-u root-p shutdown

3. Move/var/lib/mysql Entire directory to/home/data
mv/var/lib/mysql/home/data/
This will move the MySQL data file to/home/data/mysql.

4. Locate the MY.CNF configuration file
If there is no MY.CNF configuration file under the/etc/directory, locate the *.cnf file under/usr/share/mysql/, and copy one of them to/etc/and rename it to MY.CNF). The command is as follows:
[Email protected] mysql]# CP/USR/SHARE/MYSQL/MY-MEDIUM.CNF/ETC/MY.CNF

5. Edit the MySQL configuration file/etc/my.cnf
To ensure that MySQL works correctly, you need to indicate where the Mysql.sock file is generated. Modify the value in the Socket=/var/lib/mysql/mysql.sock line to the right of the equals sign:/home/mysql/mysql.sock. The operation is as follows:
VI my.cnf (Edit the My.cnf file with VI tool, find the following data to modify)
# The MySQL server
[Mysqld]
Port = 3306
#socket =/var/lib/mysql/mysql.sock (original content, in order to be more secure with "#" Comment this line)
Socket =/home/data/mysql/mysql.sock (plus this line)

6. Modify MySQL startup script/etc/rc.d/init.d/mysql
Finally, the MySQL startup script needs to be modified/etc/rc.d/init.d/mysql, the path to the right of the equal sign in the Datadir=/var/lib/mysql line is changed to your current actual storage path: Home/data/mysql.
[Email protected] etc]# Vi/etc/rc.d/init.d/mysql
#datadir =/var/lib/mysql (Note this line)
Datadir=/home/data/mysql (plus this line)

7. Restart MySQL Service
/etc/rc.d/init.d/mysql start
or restart Linux with the reboot command
If the work is moving properly, otherwise check the previous 7 steps.

rhel5.8 Installing MySQL Test

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.