Use non-root to install MySQL in CentOS6.0

Source: Internet
Author: User
Tags mysql command line
Here detailed introduction with non-root account to compile and install mysql: 1. First Use root to create a new mysql account useradd-mmysql2. Go to the official website to download mysql-5.1.58.ta

Here a detailed introduction to the use of non-root account to compile and install mysql: 1. First Use root to create a new mysql account useradd-m mysql 2. Go to the official website to download the mysql-5.1.58.ta

Here we will introduce in detail how to compile and install mysql with a non-root Account:

1. Create a mysql account with root
Useradd-m mysql

2. Download mysql-5.1.58.tar.gz from the official website and put it in/home/mysql/software. Unzip the package:
Tar xzvf mysql-5.1.58.tar.gz
Then enter the mysql-5.1.58 directory
Run./configure -- prefix =/home/mysql/local/mysql5.1.58 -- with-charset = utf8
-- Prefix indicates the directory to be installed in mysql. You must create a directory in advance.
Then execute make and make install.
If the package or compiler is missing during this process, install the dependency package using the yum command by referring to the last step in the CentOS 6.0 installation step file (SEE.

3. Enter/home/mysql/local/mysql5.1.58, create the etc directory, and then
Cp/home/mysql/local/mysql5.1.58/share/mysql/my-huge.cnf/home/mysql/local/mysql5.1.58/etc
Finally change the my-huge.cnf TO my. cnf, the key is to edit this file later:
Vim my. cnf
In [mysqld ],
Socket =/tmp/mysql. sock
Change
Socket =/home/mysql/local/mysql5.1.58/tmp/mysql. sock
Add the following sentence:
Log-error =/home/mysql/local/mysql5.1.58/var/mysql. err
Pid-file =/home/mysql/local/mysql5.1.58/var/mysqld. pid
Datadir =/home/mysql/local/mysql5.1.58/var/

This is mainly because mysql does not have the permission to create directories and files under/var and/etc by default. After this, mysql creates these files in its own directory.

Ps: mysql searches for my. cnf in the order of/etc/my. cnf/etc/mysql/my. cnf/home/mysql/local/mysql5.1.58/etc/my. cnf ~ /. My. cnf, which can be executed in/home/mysql/local/mysql5.1.58/libexec
./Mysqld -- verbose -- help | grep-A 1 'default options' can be seen. Because neither my. cnf nor my. cnf exists in/etc or/etc/mysql, I will find it under/home/mysql/local/mysql5.1.58/etc/my. cnf.

4. Go to the/home/mysql/local/mysql5.1.58/bin directory and run
./Mysql_install_db install the database
Then run./mysqld_safe & to start the database.

5. log on to the database with the root account
./Mysql-uroot

6. allow users to remotely access mysql
By default, mysql does not allow remote access.
Now you need to add a mysql account with original access (you need to enter the mysql Command Line ):
Grant all privileges on *. * TO remote @ "%" identified by 'plaintext password for remote logon 'with grant option;

Execute the following statement to take effect:
Flush privileges;

In centos, iptables is enabled by default, but port 3306 is not enabled. You need to manually specify this parameter.
Log out of mysql and enter:
Vi/etc/sysconfig/iptables
Add the following string
-A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport 3306-j ACCEPT

Restart iptables:
/Etc/rc. d/init. d/iptables restart
Now you can connect to the remote mysql database.

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.