MySQL compilation-free installation and user management

Source: Internet
Author: User

MySQL installation methods include rpm and source code compilation and installation. This article will demonstrate installation without compilation.
I. installation and configuration

1. Create a mysql user and decompress the mysql installation package
[Root @ mysql local] # groupadd-r mysql
[Root @ mysql local] # useradd-g mysql-r-M-s/sbin/nologin mysql
[Root @ mysql local] # tar-zxvf mysql-5.6.14-linux-glibc2.5-x86_64.tar.gz-C/usr/local/
[Root @ mysql local] # cd/usr/local/
[Root @ mysql local] # ln-sv mysql-5.6.14-linux-glibc2.5-x86_64 mysql
[Root @ mysql local] # chown-R mysql: mysql mysql-5.6.14-linux-glibc2.5-x86_64/

2. Create a folder to store mysql data files. You 'd better put it in an independent partition. I will put it directly under /.
[Root @ mysql local] # mkdir-p/mysql/data
[Root @ mysql local] # chown-R mysql: mysql! $

3. Start database Initialization
[Root @ mysql media] # cd/usr/local/mysql/scripts/
[Root @ mysql scripts] #./mysql_install_db -- user = mysql -- basedir =/usr/local/mysql -- datadir =/mysql/data/
WARNING: The host 'mysql' could not be looked up with/usr/local/mysql/bin/resolveip.
This probably means that your libc libraries are not 100% compatible
With this binary MySQL version. The MySQL daemon, mysqld, shocould work
Normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
When specifying MySQL privileges!
Installing MySQL system tables.../usr/local/mysql/bin/mysqld: error while loading shared libraries: libaio. so.1: cannot open shared object file: No such file or directory
# Because my linux installation is minimized, the following error is reported: The Shared library file is missing. It doesn't matter. Just install it.
[Root @ mysql scripts] # yum install-y libaio
[Root @ mysql scripts] #./mysql_install_db -- user = mysql -- basedir =/usr/local/mysql -- datadir =/mysql/data/
# This execution is successful.

4. Modify the PATH variable
[Root @ mysql scripts] # vim/etc/profile
Export PATH = $ PATH:/usr/local/mysql/bin
# Add this line at the end
[Root @ mysql scripts] #.! $

5. Modify MANPATH so that the man command can find the mysql help document.
[Root @ mysql scripts] # vim/etc/man. config
MANPATH/usr/local/mysql/man/
# Add this line

6. Add the library file path
[Root @ mysql scripts] # vim/etc/ld. so. conf. d/mysql-x86_64.conf
/Usr/local/mysql/lib # Add this line
[Root @ mysql scripts] # ldconfig-v

7. Add the header file path
[Root @ mysql scripts] # ln-sv/usr/local/mysql/include/usr/include/mysql
'/Usr/include/mysql'->'/usr/local/mysql/include'

8. Modify the mysql owner to root.
[Root @ mysql local] # chown-R root mysql-5.6.14-linux-glibc2.5-x86_64/

9. modify the configuration file
[Root @ mysql] # vi/etc/my. cnf
[Mysqld]
Datadir =/mysql/data
Socket =/var/lib/mysql. sock
User = mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
Symbolic-links = 0
[Mysqld_safe]
Log-error =/var/log/mysqld. log
Pid-file =/var/run/mysqld. pid
[Root @ mysql] # cp support-files/mysql. server/etc/init. d/mysqld

10. Set automatic start upon startup
[Root @ mysql] # chkconfig -- add mysqld
[Root @ mysql] # chkconfig -- list mysqld
Mysqld 0: off 1: off 2: on 3: on 4: on 5: on 6: off

Ii. User Management
Mysql users are composed of 'user' @ 'host'. When the host is %, the host can be any host.

1. Modify the root password
Method 1:
# Mysqladmin-u root password 'new-password'
# Mysqladmin-u root-h this_host_name password 'new-password'

Method 2
Mysql> set password for 'root' @ 'localhost' = PASSWORD ('new-password ');
Mysql> select host, user, password from mysql. user;
Mysql> flush privileges;

Method 3:
Mysql> update mysql. user set password = PASSWORD ('new-password') where host = 'localhost ';
Mysql> flush privileges;

2. Delete Anonymous Users
Mysql> drop user ''@ localhost;
Mysql> drop user ''@ mysql;

3. Create a user
Mysql> grant all privileges on *. * to 'user01' @ 'localhost' identified by 'mysql ';

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.