MySQL server and client installation under Linux

Source: Internet
Author: User
Tags gz file

First, installation method

There are two main ways to install MySQL: one is to compile and install through the source code, which is suitable for advanced users to customize the MySQL feature, and the other is to install it using the compiled binaries. Binary files are also installed into a generic installation method that is not specific to a particular platform, namely. tar.gz compressed files, or installation using RPMs or other packages, which automatically completes the configuration of the system. This record uses the. tar.gz file installation process.

Second, download the file

Mysql-5.5.45-linux2.6-x86_64.tar.gz (included in annex)

Http://dev.mysql.com/downloads/mysql/5.5.html

Third, check whether it is installed, grep-i option means ignoring case when matching

[[email protected]/]# rpm-qa|grep-i MySQL
Perl-dbd-mysql-4.013-3.el6.x86_64
Mysql-libs-5.1.61-1.el6_2.1.x86_64
Mysql-5.1.61-1.el6_2.1.x86_64

You can see that the library file is already installed and should be uninstalled first to avoid overwriting errors. Use the--nodeps option when uninstalling, ignoring dependencies:

[Email protected]/]# rpm-e mysql-5.1.61-1.el6_2.1.x86_64--nodeps

[Email protected]/]# rpm-e perl-dbd-mysql-4.013-3.el6.x86_64--nodeps

[Email protected]/]# rpm-e mysql-libs-5.1.61-1.el6_2.1.x86_64--nodeps

Iv. add MySQL group and MySQL user to set MySQL installation directory file owner and owning group

[[email protected]/]# Groupadd MySQL
[[email protected]/]# useradd-r-g MySQL MySQL (-r parameter indicates that the MySQL user is a system user and is not available for login system)

Five, installation

1. Extract the binary files to the specified directory, such as/usr/local

[Email protected]/]# cd/usr/local

[Email protected]/usr/local]# tar zxf mysql-5.5.45-linux2.6-x86_64.tar.gz

Folder name is too long to make a symbolic link [[email protected]/usr/local]# ln-s mysql-5.5.45-linux2.6-x86_64 MySQL

2. View the directory structure under/usr/local/mysql/

Directory

Contents of Directory

Bin

Client programs and the MYSQLD server

Data

Log files, databases

Docs

Manual in Info format

Mans

Unix manual Pages

Include

Include (header) files

Lib

Libraries

Scripts

mysql_install_db

Share

Miscellaneous support files, including error messages, sample configuration files, SQL for database installation

Sql-bench

Benchmarks

3. Change the group and user to which they belong

[[email protected]/usr/local/mysql]# chown-r MySQL.
[[email protected]/usr/local/mysql]# chgrp-r MySQL.

4. Execute the mysql_install_db script to initialize the data directory in MySQL and create some system tables. The process of the MySQL service mysqld to access the data directory at runtime, so this script must be executed by the mysqld user (MySQL previously set), or by root and with the parameter--user=mysql:

[Email protected]/usr/local/mysql]# scripts/mysql_install_db--user=mysql

Status of implementation:

Installing MySQL system tables ...
150809 11:20:06 [Note]./bin/mysqld (mysqld 5.5.45) starting as Process 28004 ...
Ok
Filling Help Tables ...
150809 11:20:06 [Note]./bin/mysqld (mysqld 5.5.45) starting as Process 28011 ...
Ok

To start mysqld at boot time with to copy
Support-files/mysql.server to the right place for your system

REMEMBER to SET A PASSWORD for the MySQL root USER!
To does so, start the server, then issue the following commands:

./bin/mysqladmin-u root password ' new-password '
./bin/mysqladmin-u root-h devtj-todo-15070919100 password ' new-password '

Alternatively you can run:
./bin/mysql_secure_installation

Which would also give you the option of removing the test
Databases and anonymous user created by default. This is
Strongly recommended for production servers.

See the Manual for more instructions.

You can start the MySQL daemon with:
Cd. ;./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
CD./mysql-test; Perl mysql-test-run.pl

Problems at http://bugs.mysql.com/

PS: If the MySQL installation directory (extract directory) is not/usr/local/mysql, then you must also specify the directory parameters, such as

[Email protected]/usr/local/mysql]# scripts/mysql_install_db--user=mysql \

--basedir=/opt/mysql/mysql \

--datadir=/opt/mysql/mysql/data

5. Change all files in the mysql/directory except the data/directory back to the root user, and the MySQL user only needs to be the owner of all files in the Mysql/data directory.

[Email protected]/usr/local/mysql]# chown-r root.
[[email protected]/usr/local/mysql]# chown-r mysql data.

6. Copy the configuration file to/etc/my.cnf

[email protected]/usr/local/mysql]# CP support-files/my-medium.cnf/etc/my.cnf

7. Add the MYSQLD service to the boot entry.

A. Copy the Scripts/mysql.server service script to/ETC/INIT.D and rename it to Mysqld

[email protected]/usr/local/mysql]# CP support-files/mysql.server/etc/init.d/mysqld

B. Adding the MYSQLD service to the boot-up service via the Chkconfig command

[Email protected]/usr/local/mysql]# chkconfig--add mysqld

To see if the add was successful:

[Email protected]/usr/local/mysql]# chkconfig--list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Six, modify the configuration, start

1. Modify the configuration

[email protected]/usr/local/mysql]# VIM/ETC/MY.CNF

The initial configuration is only:

Can be configured according to individual needs.

2. Start.

A. Reboot the system mysqld will start automatically, or manually start the mSQL directly.

[[Email protected]/usr/local/mysql]# service mysqld start
Starting MySQL ... success!

B. Add users and restart MySQL.

Add, install MySQL client

[[email protected]] #rpm-IVH mysql-client-5.5.28-1.linux2.6.x86_64.rpm

MySQL server and client installation under Linux

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.