Installing the MySQL database from a non-root user

Source: Internet
Author: User

One, Root user operation

1. Create a regular user

[[email protected] ~]# useradd ipdev[[email protected] ~]# echo "Ipdev" |passwd--stdin ipdev >/dev/null

2. Create a user running the MySQL service

[[email protected] ~]# useradd MySQL

3. Verify that the user is created successfully

[[email protected] ~]# ID ipdevuid=500 (ipdev) gid=500 (Ipdev) group =500 (Ipdev) [[email protected] ~]# ID mysqluid=501 (mysql) GI d=501 (MySQL) group =501 (MySQL)

4, give ordinary users ipdev to execute sudo permissions

[[email protected] ~]# echo "Ipdev all= (All:all) All" >/etc/sudoers.d/ipdev[[email protected] ~]# chmod 400/etc/sudoe Rs.d/ipdev

5, the first time to initialize the database when the dependency package installed first

[Email protected] ~]# yum-y install Libaio

Second, Indev user operation | Normal User

1. Preparatory work

[Email protected] ~]$ whoroot tty1 2014-12-04 23:24root pts/0 2014-12-04 23:25 (192.168.0.103) Ipde V pts/1 2014-12-04 23:31 (192.168.0.103) [[email protected] ~]$ pwd/home/ipdev[[email protected] ~]$ lsmysql-5.6. 12-linux-glibc2.5-x86_64.tar.gz

2. Unzip the MySQL installation package

[Email protected] ~]$ tar xf mysql-5.6.12-linux-glibc2.5-x86_64.tar.gz [[email protected] ~]$ ln-s mysql-5.6.12-linux-g libc2.5-x86_64 Mysql[[email protected] ~]$ ll total dosage 299028lrwxrwxrwx 1 Ipdev ipdev 34 December 4 23:35 mysql-mysql-  5.6.12-linux-glibc2.5-x86_64drwxrwxr-x Ipdev ipdev 4096 December 4 23:35 mysql-5.6.12-linux-glibc2.5-x86_64-rw-rw-r-- 1 Ipdev ipdev 306192671 December 4 23:33 mysql-5.6.12-linux-glibc2.5-x86_64.tar.gz

3. Create a data store directory

[Email protected] ~]$ mkdir data

4. Give MySQL installer directory and data directory permissions

#重点标记: Data storage Directory The permissions must be controlled, or subsequent initialization of the database will be error

[[email protected] ~]$ chown -r mysql datachown:  changing the owner of the "data/"  :   Operations not allowed [[Email protected] ~]$ sudo chown -r mysql datawe trust  you have received the usual lecture from the local  Systemadministrator. it usually boils down to these three things:      #1)  Respect the privacy of others.     #2)  Think before you type.     #3)  With great power  Comes great responsibility. [Sudo] password for ipdev: [[email protected] ~]$ sudo chown -r Total dosage of  mysql mysql[[email protected] ~]$ ll  299032drwxrwxr-x  2  Mysql mysql      4096 12 Month   4 23:35 datalrwxrwxrwx& NBsp; 1 mysql ipdev        34 12 Month   4  23:35 mysql -> mysql-5.6.12-linux-glibc2.5-x86_64drwxrwxr-x 13 mysql  Ipdev      4096 12 Month   4 23:35  Mysql-5.6.12-linux-glibc2.5-x86_64-rw-rw-r--  1 ipdev ipdev 306192671 12 month    4 23:33 mysql-5.6.12-linux-glibc2.5-x86_64.tar.gz

5. Initialize the database

[Email protected] ~]$/mysql/scripts/mysql_install_db--user=mysql--datadir=/home/ipdev/data/--basedir=/home/ ipdev/mysql/

When initializing the database, I encountered two errors as follows

Encountered error ***********************************************************installing MySQL system tables ... 2014-12-04 23:37:26 0 [Warning] TIMESTAMP with implicit the DEFAULT value is deprecated. --explicit_defaults_for_timestamp server option (see documentation for more details). 2014-12-04 23:37:26 1438 [ Warning] can ' t create test file/home/ipdev/data/localhost.lower-test error 12014-12-04 23:37:26 1438 [Warning] can ' t create t EST file/home/ipdev/data/localhost.lower-test2014-12-04 23:37:26 1438 [Warning] Buffered warning:changed limits:max_ open_files:1024 (requested 5000) error 2***************************************************************************** ****************************

Solutions

Workaround for Error 1: sudo chown-r mysql.mysql data instead of sudo chown-r mysql.mysql data error 2 workaround # sudo vim/etc/security/limits.conf end line added as Next information * Soft nofile 65535 * Hard nofile 65535 normal users need to log back in order to take effect, view commands Umilit-n

6. Modify the supplemental MySQL configuration file

$ vim ~/mysql/my.cnf [mysqld] Add the following line user = Mysqlport = 3306server_id = 1socket =/tmp/mysql.sockbasedir =/home/ipdev/mysql/ DataDir =/home/ipdev/data/log-error =/home/ipdev/data/mysql-error.logpid-file =/home/ipdev/data/mysql.pidlog-bin = /home/ipdev/data/mysql-bin.logopen-files-limit = 10240skip_name_resolve=1innodb_file_per_table=1

7. Start the MySQL service

Note: It is also important to start, otherwise it will make many mistakes.

[[email protected] ~]$ sudo sed-i ' s#/usr/local#/home/ipdev#g ' ~/mysql/bin/mysqld_safe[[email protected] ~]$ ~/mysql/ Bin/mysqld_safe--DEFAULTS-FILE=/HOME/IPDEV/MYSQL/MY.CNF &

8. Configure the MySQL environment variable

[Email protected] ~]$ echo "Export path=\ $PATH:/home/ipdev/mysql/bin/" >> ~/.bash_profile[[email protected] ~]$ SOURCE ~/.bash_profile

9. Landing Test

[Email protected] ~]$ mysql-uroot-p-e ' show databases; ' Enter Password: +--------------------+| Database |+--------------------+| Information_schema | | MySQL | | Performance_schema | | Test |+--------------------+

10, because the time is relatively hasty, here is not much modification service startup script

Killall-9 Mysqlpid | or | Kill Mysqlpid

There are several places to note:

1, directory permissions issues (such as data storage directory, various log directory)

2. Execute permissions issues (such as Sudo)

3. Suggest the path to the configuration file when starting the service

4, the biggest problem is to initialize the database default./bin/mysqld_safe MySQL path is/usr/local/mysql, but ordinary users do not have access to/usr/local, so this place must be replaced by MySQL directory


I thought it was simple, but it was really a hassle to do.

All right, let's get here today! The follow-up will continue to add to everyone good night

This article is from the "Zheng" blog, make sure to keep this source http://467754239.blog.51cto.com/4878013/1586491

Installing the MySQL database from a non-root user

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.