MySQL database server (YUM) installation

Source: Internet
Author: User

1. Overview
2. Deployment process
2.1 NFS server-side configuration for virtual machine console
2.2 NFS Client Configuration for virtual machine NODE15
2.3 Virtual machine installation MySQL environment
2.4 Configuring MySQL
3. Errors and resolutions
3.1 Failed to start

1. Overview

This blog post mainly records how to deploy a MySQL database server. This is just the basic installation and configuration of the MySQL database.

2. Deployment process

This blog takes the KVM virtual machine node15 as the MySQL database server.
In the previous blog, it has been agreed to/mnt/data/db the directory of the virtual machine console as a persistent storage directory for the global database service
(Note-in-chain: Virtual Machine Console Infrastructure deployment-working directory preparation. MD ", Blog Park Address: https://www.cnblogs.com/liwanliangblog/p/9193891.html)

2.1 NFS server-side configuration for virtual machine console
    1. Create MySQL users and groups
      In-note chain: LDAP-OPENLDAP Service Deployment and testing (Yum installation). MD, Blog Park address: https://www.cnblogs.com/liwanliangblog/p/9193916.html
    2. Create a Database storage directory
      Under the/mnt/data/db directory of the virtual machine console, execute the command to create the directory:mkdir node15_mysql_data
    3. Share this directory with the NFS file system
      Edit the configuration file/etc/exportfs, add the following:/mnt/data/db/node15_mysql_data 192.168.10.15 (Rw,no_root_squash,no_all_squash)
    4. Restart NFS server in effect
    • Mode one: Execute exportfs -r , reload the configuration to take effect, exportfs or showmount -e localhost see if it takes effect
    • Mode two: Execute service nfs restart , restart the service to take effect exportfs ; showmount -e localhost
2.2 NFS Client Configuration for virtual machine NODE15

In the virtual machine node15, execute the command: rpm -qa | egrep "nfs-utils|rpcbind" to see if an NFS environment is installed, or to execute the command if it is not installed:yum -y install nfs-utils rpcbind

2.3 Virtual machine installation MySQL environment

Virtual machine node15, execute command: yum -y install mysql mysql-client mysql-server execution complete, install dependent packages PERL-DBI and Perl-dbd-mysql
After the installation is complete, do not start the MYSQLD service, do the following:
Mount the virtual machine console shared directory and execute the command: mount -t nfs 192.168.10.8:/mnt/data/db/node15_mysql_data /var/lib/mysql
Because the owner of the/mnt/data/db/node15_mysql_data is root, when it is mounted to NODE15 via NFS, there is an NFS no_root_squash option, so the NODE15 is also the root user's
On the virtual machine console, modify the/mnt/data/db/node15_mysql_data owner to MySQL

Note: In the execution of service mysqld start times wrong, error resolution method see

Once you've completed the above configuration, you can service mysqld start start the service and do it later

2.4 Configuring MySQL
  1. Configure the root password of MySQL and log in
    to execute MySQL into the MySQL database system;
    Execute Grant all privileges on * * to ' root ' @ ' localhost ' Identified by ' Liwanliang '; , authorization root local can password access;
    Execute Grant all privileges on *. * to ' root ' @ ' 127.0.0.1 ' Identified by ' Liwanliang '; , authorization root local can password access;
    Execute Grant all privileges on *. * to ' root ' @ ' 192.168.80.8 ' Identified by ' Liwanliang '; , authorization root can be accessed from the virtual machine console using a password;
    Execute Grant all privileges on *. * to ' root ' 192.168.80.15 ' identified by ' Liwanliang '; , the authorization root can be accessed from the virtual machine node15 using a password;
    executes the select User,password,host from Mysql.user; , view the current authorization without password access and delete it;
    Execute delete from Mysql.user where user= ' and host= ' localhost ';
    Execute delete from Mysql.user where user= ' root ' and host= ' node15 ';
    Execute Delete from Mysql.user where user= ' and host= ' node15 ';
  2. Configuring the MySQL default storage engine
    View current storage engine, for example, display as M has ISAM as default storage engine


    From the above query, you can see that MySQL is currently the default storage engine is MyISAM, in this series of blogs, the default storage engine needs to be changed to InnoDB. The operation is as follows:

    Repeating the above query again, you can see that the storage engine has been modified, such as:

  3. Configuring the storage directory for MySQL
    Slightly. This blog does not modify the storage directory, just want to attach other directories to the directory.

  4. Configure default characters for MySQL
    Execute command show varibales like ‘%char%‘; Query the current database supports and the default character set used

    View all the character sets supported by the current MySQL system, such as:

    Modify configuration file/etc/my.cnf, save exit, perform service msyqld restart restart service
3. Error and resolution 3.1 startup failure

After the Mount completes NFS, after modifying the directory properties, the first service mysqld start error, the error is as follows:

"Workaround": Execute service iptables stop shutdown firewall; setenforce 0

Continue execution service mysql start , still start failed, view log/var/log/mysqld.log

"Workaround": Execute mysql_install_db , and then execute service mysqld restart successfully, such as:

MySQL database server (YUM) installation

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.