MySQL--centos installed in rpm mode MySQL5.5

Source: Internet
Author: User

Reprint Please specify source: http://blog.csdn.net/l1028386804/article/details/46507735
First go to MySQL website download page:

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

Select Platform Choose Oracle & Red Hat Linux 4 & 5

Download the following three files separately (since my machine is 32 bits, below is the 32-bit version of the 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 using a breakpoint transfer

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
Start the installation after the download is complete:
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) was needed by Mysql-server-5.5.28-1.rhel5.x86_64
is dependent on the library is missing, install the dependent library can
Yum Install Libaio
After the installation is complete, enter MySQL to see if the installation is successful.
Mysql

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

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

Description MySQL service has not started, input service MySQL start start MySQL service

Service MySQL Start
Then enter MySQL, if prompted with the following message, indicating success.

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) #, Oracl e and/or its affiliates. All rights reserved.                                                            Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names 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 error address

The address here is/var/lib/mysql/.

The log name is typically the server name. err

Open to discover that there is such a sentence:

[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

So the table is missing.

Perform initialization of the table

/usr/bin/mysql_install_db
To perform a startup or failure after that, view the log:

[ERROR] Failed to open log (file './mysql-bin.000004 ', errno 13)
There should be no permissions, give MySQL permission

Chown-r mysql:mysql/var/lib/mysql/

After re-executing service MySQL start services, success!

You can start the daemon process

/usr/bin/mysqld_safe &
I usually go back several times exit putty or SECURECRT and then re-open a session
Problem

Where did MySQL go after installation? Usually in the following folder

/usr/share/mysql/or/usr/lib/mysql/or/var/lib/mysql/.

You can pass the instructions:

Whereis MySQL
To see exactly where the installation went. "Initialize Settings"

RPM package installed MySQL is not installed/etc/my.cnf files, the solution, only need to copy the/usr/share/mysql directory my-huge.cnf files to/etc directory, and renamed to MY.CNF can

Cp/usr/share/mysql/my-huge.cnf/etc/my.cnf
"Set Password"

When you first install, the default password is blank, you can use the following command to modify the root password,

/usr/bin/mysqladmin-u root  password New password xxxxx
Example:/usr/bin/mysqladmin-u root password 123456

Then log in again

Mysql-u root–p New Password xxxxx

Modify Login Password

This is done by changing the password with the Mysqladmin command, or by modifying the library.

"Directory description" 1, database directory

/var/lib/mysql/

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)

"Start and stop" 1, start

After the MySQL installation is complete, start the file MySQL in the/ETC/INIT.D directory and run the following command when it needs to start.

/etc/init.d/mysql start

Or

/etc/rc.d/init.d/mysql start

2. Stop

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

3. Auto-start

1) See if MySQL is in the auto-start list

/sbin/chkconfig–list

2) Add MySQL to your system's start-up service group

/sbin/chkconfig–add MySQL

3) Remove MySQL from the Startup service group.

/sbin/chkconfig–del MySQL
"Change MySQL 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

Remember to give permission:

Chown-r Mysql:mysql/home/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/,

Copy one of them to/etc/and rename 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 correctly, you need to indicate where the Mysql.sock file is generated.

Modify the value to the right of the equals sign in a socket=/var/lib/mysql/mysql.sock line

As:/home/mysql/mysql.sock. The operation is as follows:

VI my.cnf # #用vi工具编辑my. cnf file, locate the following data modifications

# The MySQL server

[Mysqld]

Port = 3306

#socket =/var/lib/mysql/mysql.sock # #原内容, in order to be more secure with "#" Comment this line

Socket =/home/data/mysql/mysql.sock #加上此行

6. Modify MySQL startup script/etc/rc.d/init.d/mysql

Finally, you need to modify the MySQL startup script/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

Drop path: Home/data/mysql.

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

#datadir =/var/lib/mysql# #注释此行

Datadir=/home/data/mysql # #加上此行

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.

"Configure remote Access"

For security reasons, MySQL does not allow remote access by default, you can use the following to turn on remote access

Give any host access to data
Mysql>grant all privileges on * * to ' root ' @ '% ' with GRANT OPTION

Make the changes effective
Mysql>flush Privileges

If the remote access is still not possible, it is likely that the firewall, you can open the firewall 3306 port or simply shut down the firewall.

MySQL--centos installed in rpm mode MySQL5.5

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.