Linux installation MySQL

Source: Internet
Author: User
Tags readline

1. Download MySQL
I downloaded the version: mysql-5.6.4.tar.gz

2. Uninstall the CentOS-brought MySQL before installing
[[email protected] ~]# yum remove MySQL

3. Compile and install CMake
Download CMake Source package: http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz

Moving from a shared directory to the USR directory
[Email protected] ~]# mv/home/user/cmake-2.8.4.tar.gz/usr/cmake-2.8.4.tar.gz
[Email protected] ~]# cd/usr

Unzip and install the CMake
[Email protected] usr]# tar xzvf cmake-2.8.4.tar.gz
[Email protected] usr]# CD cmake-2.8.4
[Email protected] cmake-2.8.4]# ./bootstrap

---------------------------------------------
CMake 2.8.4, Copyright 2000-2009 Kitware, Inc.
---------------------------------------------
Error when bootstrapping CMake:
Cannot find appropriate C compiler on the 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
---------------------------------------------
Error: C compiler is missing
Workaround: Install the GCC compiler
[[email protected] ~]# yum install gcc

Continue installing CMake
[Email protected] cmake-2.8.4]# ./bootstrap

---------------------------------------------
CMake 2.8.4, Copyright 2000-2009 Kitware, Inc.
C compiler on the This system IS:CC
---------------------------------------------
Error when bootstrapping CMake:
Cannot find appropriate C + + compiler on the This system.
Please specify one using environment variable CXX.
See Cmake_bootstrap.log for compilers attempted.
---------------------------------------------
Log of errors:/usr/local/src/cmake-2.8.4/bootstrap.cmk/cmake_bootstrap.log
---------------------------------------------
Error: Missing C + + compiler
Workaround: Install the gcc-c++ compiler
[Email protected] ~]# yum install gcc-c++

Install again
[Email protected] cmake-2.8.4]# ./bootstrap
No error, compile and install
[Email protected] cmake-2.8.4]# gmake
[[email protected] cmake-2.8.4]# gmake Install

4. Officially start installing MySQL
Adding MySQL users and user groups
[[email protected] ~]# groupadd MySQL
[[email protected] ~]# useradd-g mysql mysql

MySQL source package moved from shared folder to/usr and unzipped
[Email protected] ~]# mv/home/user/mysql-5.6.4.tar.gz/usr/mysql-5.6.4.tar.gz
[Email protected] usr]# tar xzvf mysql-5.6.4.tar.gz
[Email protected] usr]# CD mysql-5.6.4

CMake Run
[Email protected] mysql-5.5.22]# cmake.

Start compiling the installation
[[email protected] mysql-5.5.22]# make && make install

Go to the installation directory, change the ownership of the binary to root, the data directory to the MySQL user, update the authorization form
[Email protected] mysql-5.5.22]# cd/usr/local/mysql/
[Email protected] mysql]# chown-r root .
[[email protected] mysql]# chown-r MySQL.
[[email protected] mysql]# chgrp-r MySQL.
[Email protected] mysql]# scripts/mysql_install_db--user=mysql

Secure boot MySQL (default password is empty)
[Email protected] mysql]# /bin/mysqld_safe--user=mysql&

Source/etc/profile

Error:

120908 00:16:25 mysqld_safe Logging to '/usr/local/mysql/data/centos.err '.
120908 00:16:26 Mysqld_safe starting mysqld daemon with databases From/usr/local/mysql/data

Workaround:
[Email protected] ~]# cd/usr/local/mysql/data

[[email protected] data]# ls-l
Total usage 29744
-RW-RW----1 mysql root 1585 September 8 00:16 centos.err
-RW-RW----1 MySQL MySQL 6 September 8 00:16 centos.pid
-RW-RW----1 mysql mysql 18874368 September 8 00:16 ibdata1
-RW-RW----1 MySQL mysql 5 242880 September 8 00:16 ib_logfile0
-RW-RW----1 mysql mysql 5242880 September 8 00:16 ib_logfile1
drwxr-xr-x 2 mysql mysql 4096 September 8 00:14 mysql
-rw-rw----1 mysql mysql 27293 September 8 00:14 mysql-bin.000001
-RW-RW----1 mysql mysql 1031892 September 8 00 : mysql-bin.000002
-RW-RW----1 mysql mysql 107 September 8 00:16 mysql-bin.000003
-RW-RW----1 mysql mysql 57 September 8 00:16 Mysql-bin.index
drwx------2 mysql mysql 4096 September 8 00:14 performance_schema
drwxr-xr-x 2 mysql mysql 4096 September 8 00:0 8 Test


[Email protected] data]# chgrp-r MySQL Centos.err
[Email protected] data]# ls-l
Total dosage 29736
-RW-RW----1 MySQL mysql 1585 September 8 00:16 Centos.err
-RW-RW----1 MySQL mysql 6 September 8 00:16 centos.pid
-RW-RW----1 MySQL mysql 18874368 September 8 00:16 ibdata1
-RW-RW----1 MySQL mysql 5242880 September 8 00:16 Ib_logfile0
-RW-RW----1 MySQL mysql 5242880 September 8 00:16 ib_logfile1
Drwxr-xr-x 2 mysql mysql 4096 September 8 00:14 MySQL
-RW-RW----1 MySQL mysql 27293 September 8 00:14 mysql-bin.000001
-RW-RW----1 MySQL mysql 1031892 September 8 00:14 mysql-bin.000002
-RW-RW----1 MySQL mysql 107 September 8 00:16 mysql-bin.000003
-RW-RW----1 MySQL mysql 57 September 8 00:16 Mysql-bin.index
drwx------2 MySQL mysql 4096 September 8 00:14 Performance_schema
Drwxr-xr-x 2 mysql mysql 4096 September 8 00:08 test

Configure users
After MySQL starts successfully, Root does not have a password, we need to set the root password.
Before setting, we need to set path, or we can't call MySQL directly
Modify the/etc/profile file to add at the end of the file

[Email protected] mysql]#vi/etc/profile

Copy the code code as follows:
Path=/usr/local/mysql/bin: $PATH
Export PATH

Close the file, run the following command, and let the configuration take effect immediately

Copy the code code as follows:
[Email protected] mysql]# source/etc/profile


Connecting native MySQL
[[email protected] MySQL] #mysql –u root–p
Prompt to enter password, default is blank, press ENTER to

Disconnect Connection
mysql>exit;

Set a password for the root account
[Email protected] mysql]# mysqladmin-u root password 123456
Enter password:123456

Set the options file to copy the configuration file to/etc
[Email protected] mysql]# CP support-files/my-medium.cnf/etc/mysql.cnf

Set up boot from
[Email protected] mysql]# CP support-files/mysql.server/etc/init.d/mysql
[Email protected] mysql]# chmod +x/etc/init.d/mysql
[[email protected] mysql]# chkconfig MySQL on

Start and close MySQL through services
[[email protected] ~]# service MySQL start
[[email protected] ~]# service MySQL stop

5. Setup is complete, then use just start-connect-disconnect-close, command as follows:
[[email protected] mysql]# service MySQL start
Starting MySQL. Determine


[Email protected] mysql]# mysql-u root-p
Enter Password:
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 1
Server version:5.5.22 Source Distribution

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> show databases;
+--------------------+
| Database |
+--------------------+
| Information_schema |
| MySQL |
| Performance_schema |
| Test |
+--------------------+
4 rows in Set (0.07 sec)

Mysql> exit;
Bye
[[Email protected] mysql]# service MySQL stop
Shutting down MySQL. Determine

6. Other:
View process Commands Ps–ef|grep mysqld
Kill process Command KILL–9 process number


Compiling MySQL appears cmake error at cmake/readline.cmake:83 (MESSAGE)

--Could not find Curses (missing:curses_library curses_include_path)
CMake Error at cmake/readline.cmake:83 (MESSAGE):
Curses Library not found. Please install the appropriate package,

Remove CMakeCache.txt and rerun CMake. On Debian/ubuntu, package name was Libncurses5-dev, on Redhat and derivates it was ncurses-devel.
Call Stack (most recent call first):
cmake/readline.cmake:127 (find_curses)
cmake/readline.cmake:217 (Mysql_use_bundled_libedit)
cmakelists.txt:257 (Mysql_check_readline)

--Configuring incomplete, Errors occurred!

The reason for this error is that Ncurses-devel is not installed, run the following command
First step: Install
#yum-y Install Ncurses-devel

Step Two: Delete CMakeCache.txt
Find the location of all the CMakeCache.txt documents by using the Find command
#find/-name CMakeCache.txt
Then delete all:
# Rm-rf/usr/local/src/cmake-2.8.6/tests/complex/cache/cmakecache.txt
# Rm-rf/usr/local/src/cmake-2.8.6/tests/complexoneconfig/cache/cmakecache.txt
# Rm-rf/usr/local/src/cmake-2.8.6/tests/complexrelativepaths/cache/cmakecache.txt
# Rm-rf/usr/local/src/mysql-5.5.18/cmakecache.txt


Workaround:

1. Change the table method.

It may be that your account is not allowed to log on remotely, only on localhost. This time, as long as the computer on the localhost, log in to MySQL, change the "MySQL" Database in the "User" table "host", from "localhost" to "%"

Mysql-u root-pvmwaremysql>use MySQL; Www.2cto.com

Mysql>update User Set host = '% ' where user = ' root ';

Mysql>select host, user from user;

2. Authorization law.

For example, if you want to myuser use MyPassword to connect to a MySQL server from any host.

GRANT all privileges on * * to ' myuser ' @ ' percent ' identified by ' MyPassword ' with GRANT OPTION;

FLUSH privileges;

If you want to allow users to connect to the MySQL server from a host myuser IP 192.168.1.6 and use MyPassword as the password

GRANT all privileges on * * to ' myuser ' @ ' 192.168.1.3 ' identified by ' MyPassword ' with GRANT OPTION; Www.2cto.com

FLUSH privileges;

If you want to allow users to connect to the MySQL server's DK database myuser from the IP-192.168.1.6 host, and use MyPassword as the password

GRANT all privileges the dk.* to ' myuser ' @ ' 192.168.1.3 ' identified by ' MyPassword ' with GRANT OPTION;

FLUSH privileges;

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.