CentOS6.3 install MySQL5.5

Source: Internet
Author: User
Tags localhost mysql
1. Download MySQL: www.linuxidc.comLinux2012-0357270.htm the version I downloaded: mysql-5.5.22.tar.gz2. Uninstall C before installation

1. Download MySQL: http://www.linuxidc.com/linux/2012-03/57270.htmmy download page: mysql-5.5.22.tar.gz 2. Uninstall C before installation

1. Download MySQL
:
Version I downloaded: mysql-5.5.22.tar.gz

2. uninstall MySQL that comes with CentOS before installation
[Root @ localhost ~] # Yum remove mysql

3. Compile and install Cmake
Download the cmake source code package:

Move from shared directory to usr directory
[Root @ localhost ~] # Mv/mnt/hgfs/Share-CentOS/cmake-2.8.4.tar.gz/usr/cmake-2.8.4.tar.gz
[Root @ localhost ~] # Cd/usr

Decompress and install cmake
[Root @ localhost usr] # tar xzvf cmake-2.8.4.tar.gz
[Root @ localhost usr] # cd cmake-2.8.4
[Root @ localhost cmake-2.8.4] #./bootstrap

---------------------------------------------
CMake 2.8.4, Copyright 2000-2009 Kitware, Inc.
---------------------------------------------
Error when bootstrapping CMake:
Cannot find appropriate C compiler on this system.
Please specify one using environment variable CC.
See cmake_bootstrap.log for compilers attempted.

---------------------------------------------
Log of errors:/usr/local/src/cmake-2.8.4/Bootstrap. cmk/cmake_bootstrap.log
---------------------------------------------

[Root @ localhost ~] # Yum install gcc-c ++

Install again
[Root @ localhost cmake-2.8.4] #./bootstrap
No error reported, compilation and Installation
[Root @ localhost cmake-2.8.4] # gmake
[Root @ localhost cmake-2.8.4] # gmake install

4. start installing MySQL
Add MySQL users and user groups
[Root @ localhost ~] # Groupadd mysql
[Root @ localhost ~] # Useradd-g mysql

Migrate the MySQL source code package from the shared folder to/usr and decompress it.
[Root @ localhost ~] Mv/mnt/hgfs/Share/CentOS/mysql-5.5.22.tar.gz/usr/mysql-5.5.22.tar.gz
[Root @ localhost usr] # tar xzvf mysql-5.5.22.tar.gz
[Root @ localhost usr] # cd mysql-5.5.22

Run Cmake
[Root @ localhost mysql-5.5.22] # cmake.

Start compilation and Installation
[Root @ localhost mysql-5.5.22] # make & make install

Go to the installation directory, change the ownership of the binary program to root, and change the description of the data directory to mysql user to update the authorization table.
[Root @ localhost mysql-5.5.22] # cd/usr/local/mysql/
[Root @ localhost mysql] # chown-R root.
[Root @ localhost mysql] # chown-R mysql.
[Root @ localhost mysql] # chgrp-R mysql.
[Root @ localhost mysql] # scripts/mysql_install_db -- user = mysql

Start MySQL safely (the default password is blank)
[Root @ localhost mysql] #./bin/mysqld_safe -- user = mysql &

Error:
090408 21:19:24 mysqld_safe Logging to '/var/log/mysqld. log '.
090408 21:19:24 mysqld_safe Starting mysqld daemon with databases from/var/lib/mysql
090408 21:19:24 mysqld_safe mysqld from pid file/var/run/mysqld. pid ended
Cause:
Open the/var/log/mysqld. log file to get the Can't create/write to file '/var/run/mysqld. pid' (Errcode: 2)
Can't start server: can't create PID file: No such file or directory
Solution:
Go to the/var/run directory and find that there is no mysqld directory. Create the mysqld directory, enter the directory, create the mysqld. pid file, and modify the File Attribute chown-R mysql mysqld.

Connect to the local MySQL
[Root @ localhost mysql] # mysql-u root-p
Enter password. The default value is null. Press Enter.

Disconnect
Mysql> exit;

Disable MySQL
[Root @ localhost mysql] #./bin/mysqladmin-u root shutdown-p

Error:
Bin/mysqladmin: connect to server at 'localhost' failed
Error: 'Can't connect to local MySQL server through socket '/tmp/mysql. sock' (2 )'
Check that mysqld is running and that the socket: '/tmp/mysql. sock' exists!
Cause:
Go to the/var/lib/mysql directory and find the mysql. sock file.
Solution:
Establish connection ln-s/var/lib/mysql. sock/tmp/mysql. sock to solve this problem.

Easy to call, set a soft link for mysql
[Root @ localhost ~] # Ln-s/usr/local/mysql/bin/mysql/usr/bin/mysql

Set password for root account
[Root @ localhost ~] # Cd/usr/local/mysql/bin
[Root @ localhost mysql] #./bin/mysqladmin-u root-p password root
Enter Password: root

Set the option file and copy the configuration file to/etc.
[Root @ localhost mysql] # cp support-files/my-medium.cnf/etc/mysql. cnf

Set auto-start
[Root @ localhost mysql] # cp support-files/mysql. server/etc/init. d/mysql
[Root @ localhost mysql] # chmod + x/etc/init. d/mysql

Enable and disable Mysql through services
[Root @ localhost ~] # Service mysql start
[Root @ localhost ~] # Service mysql shutdown

Error: mysql startup Error
Starting MySQL... The server quit without updating PID file (/usr/local/mysql/data/CentOS. pid). [failed]
Solution:
In my. cnf
# The MySQL server
[Mysqld]
Port = 3306
Socket =/tmp/mysql. sock
......
Add
Datadir =/var/lib/mysql
[Safe_mysqld]
Err-log =/var/log/mysqld. log
Pid-file =/var/lib/mysql/CentOS. pid

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.