MySQL -- install MySQL5.5 and centosmysql5.5 in RPM Mode Under CentOS

Source: Internet
Author: User

MySQL -- install MySQL5.5 and centosmysql5.5 in RPM Mode Under CentOS

Reprinted please indicate the source: http://blog.csdn.net/l1028386804/article/details/46507735
First go to the mySQL official website to download the page:

Http://dev.mysql.com/downloads/mysql/#downloads

Select PlatformOracle & Red Hat Linux 4 & 5

Download the following three files respectively (because my machine is 32-bit, the following is a 32-bit package. If your machine is 64-bit, please download the 64-bit version ):

1. Red Hat & Oracle Linux 5 (x86, 32-bit), RPM Package
MySQL Server

2. Red Hat & Oracle Linux 5 (x86, 32-bit), RPM Package
Client Utilities

3. Red Hat & Oracle Linux 5 (x86, 32-bit), RPM Package
Development Libraries

Use the wget command to download the three files through breakpoint transmission.

wget -c http://cdn.mysql.com/Downloads/MySQL-5.5/MySQL-server-5.5.28-1.rhel5.i386.rpm                                                                        wget -c http://cdn.mysql.com/Downloads/MySQL-5.5/MySQL-client-5.5.28-1.rhel5.i386.rpm                                                                        wget -c http://cdn.mysql.com/Downloads/MySQL-5.5/MySQL-devel-5.5.28-1.rhel5.i386.rpm
After the download is complete, start the installation:
rpm -ivh MySQL-server-5.5.28-1.rhel5.i386.rpm rpm -ivh MySQL-client-5.5.28-1.rhel5.i386.rpm rpm -ivh MySQL-devel-5.5.28-1.rhel5.i386.rpmIf an error occurs during installation:

error: Failed dependencies:                                                                         libaio.so.1()(64bit) is needed by MySQL-server-5.5.28-1.rhel5.x86_64                                                                         libaio.so.1(LIBAIO_0.1)(64bit) is needed by MySQL-server-5.5.28-1.rhel5.x86_64                                                                          libaio.so.1(LIBAIO_0.4)(64bit) is needed by MySQL-server-5.5.28-1.rhel5.x86_64
The dependency library is missing. Install the dependency library.
yum install libaio
After the installation is complete, enter mysql to check whether the installation is successful.
mysql

If there is no response or the following error message is displayed:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql. sock' (2)

The mysql service has not been started. Enter service mysql start to start the mysql service.

service mysql start
Then enter mysql. If the following message is displayed, it indicates that the operation is successful.

Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.5.16 MySQL Community Server (GPL)                                                            Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.                                                            Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.                                                            Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
If an error occurs
Starting MySQL.... ERROR! The server quit without updating PID file (/var/lib/mysql/lechiexxxxx.pid).

View log files based on the error address

The address here is/var/lib/mysql/

The log name is generally the server name. err

The following message is displayed:

[ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist121012 15:12:05 mysqld_safe mysqld from pid file /var/lib/mysql/lechiexxxxxx.pid ended

Therefore, the table is missing.

Execute table Initialization

/usr/bin/mysql_install_db
Start or fail later. view the log:

[ERROR] Failed to open log (file './mysql-bin.000004', errno 13)
You probably do not have permission to grant mysql permission.

chown -R mysql:mysql /var/lib/mysql/

Then run service mysql start again to start the service, success!

Enable daemon

/usr/bin/mysqld_safe &
I usually press enter several times to exit putty or secureCRT, and then re-open a session.
[Problem]

Where can I install mysql after installation? Usually in the following folder

/Usr/share/mysql/or/usr/lib/mysql/or/var/lib/mysql/

You can run the following command:

whereis mysql
To check where the installation is. [Initialization settings]

MySQL installed in the rpm package does not install/etc/my. cnf file, solution, just need to copy the my-huge.cnf file under the/usr/share/mysql directory to the/etc directory, and renamed my. cnf

cp /usr/share/mysql/my-huge.cnf /etc/my.cnf
Set Password]

The default password for the first installation is null. You can use the following command to change the root password,

/Usr/bin/mysqladmin-u root password new password XXXXX
Example:/usr/bin/mysqladmin-u root password 123456

Then log on again

Mysql-u root-p new password XXXXX

Change logon Password

You can use the mysqladmin command to change the password or the database to change the password.

[Directory description] 1. Database directory

/Var/lib/mysql/

2. Configuration File

/Usr/share/mysql (mysql. server command and configuration file)

3. Related commands

/Usr/bin (commands such as mysqladmin mysqldump)

4. Start the script

/Etc/rc. d/init. d/(directory for starting the script file mysql)

[Start and Stop] 1. Start

After MySQL is installed, run the following command to start mysql in the/etc/init. d directory.

/Etc/init. d/mysql start

Or

/Etc/rc. d/init. d/mysql start

2. Stop

/Usr/bin/mysqladmin-u root-p shutdown

3. Automatic Start

1) Check whether mysql is in the Auto Start List

/Sbin/chkconfig-list

2) Add MySQL to the startup Service Group of your system.

/Sbin/chkconfig-add mysql

3) Delete MySQL from the startup Service Group.

/Sbin/chkconfig-del mysql
[Change MySQL Directory]

The default data file storage directory of MySQL is/var/lib/mysql.

To move the directory to/home/data, perform the following steps:
1. Create a data directory under the home Directory

Cd/home

Mkdir data

Remember to grant permissions:

Chown-R mysql: mysql/home/data

2. Stop the MySQL service process:

Mysqladmin-u root-p shutdown

3. Move the entire/var/lib/mysql directory to/home/data

Mv/var/lib/mysql/home/data/

In this way, the MySQL data file is moved to/home/data/mysql.

4. Find the my. cnf configuration file.

If the my. cnf configuration file does not exist in the/etc/directory, go to/usr/share/mysql/and find the *. cnf file,

Copy one of them to/etc/and change it to my. cnf. The command is as follows:

Cp/usr/share/mysql/my-medium.cnf/etc/my. cnf

5. Edit the MySQL configuration file/etc/my. cnf.

To ensure that MySQL works properly, you must specify the location where the mysql. sock file is generated.

Modify the value on the right of a socket =/var/lib/mysql. sock line with a moderate number

Is/home/mysql. sock. The procedure is as follows:

Vi my. cnf # Use the vi tool to edit the my. cnf file and find the following data to modify:

# The MySQL server

[Mysqld]

Port = 3306

# Socket =/var/lib/mysql. sock # original content. To be more secure, use "#" to comment this line

Socket =/home/data/mysql. sock # Add this line

6. Modify the MySQL STARTUP script/etc/rc. d/init. d/mysql

Finally, you need to modify the MySQL STARTUP script/etc/rc. d/init. d/mysql: Replace the path on the right of the equal sign in a row of datadir =/var/lib/mysql with your actual storage

Path: home/data/mysql.

Vi/etc/rc. d/init. d/mysql

# Datadir =/var/lib/mysql # comment on this line

Datadir =/home/data/mysql # Add this row

7. Restart the MySQL service.

/Etc/rc. d/init. d/mysql start

Or use the reboot command to restart Linux.

If it works properly, it will succeed. Otherwise, check again against the previous seven steps.

Configure Remote Access]

For security reasons, Mysql does not allow remote access by default. You can use the following to enable remote access:

// Grant data access permissions to any host
Mysql> grant all privileges on *. * TO 'root' @ '%' WITH GRANT OPTION

// Make the modification take effect
Mysql> FLUSH PRIVILEGES

If remote access is still not available, it is likely the cause of the firewall. You can enable port 3306 in the firewall or simply turn off the firewall.

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.