Production environment Deployment node record (iii): CentOS 7 installation of MySQL and MongoDB

Source: Internet
Author: User
Tags install perl mysql login

"installation of MySQL":

CentOS7 default database is MARIADB, now to install MySQL


1. Download the installation package here to download the four installation packages, which will be used later

Yum-y Install Perl perl-devel autoconf Libaio

2. Move the installation package to/usr/local/

mv/root/mysql-5.7.19-1.el7.x86_64.rpm-bundle.tar/usr/local/

3. Unzip

TAR-XVF Mysql-5.7.19-1.el7.x86_64.rpm-bundle.tar

4. Installation

RPM-IVH mysql-community-common-5.7.19-1.el7.x86_64.rpm

5. The original software mariadb-devel and mariadb have conflicts, delete

Rpm-qa | grep mariadb#mariadb-libs-5.5.52-1.el7.x86_64rpm-e--nodeps mariadb-libs-5.5.52-1.el7.x86_64

6. Start the installation again

RPM-IVH mysql-community-common-5.7.19-1.el7.x86_64.rpm

RPM-IVH mysql-community-libs-5.7.19-1.el7.x86_64.rpm

RPM-IVH mysql-community-embedded-5.7.19-1.el7.x86_64.rpm

RPM-IVH mysql-community-devel-5.7.19-1.el7.x86_64.rpm

RPM-IVH mysql-community-embedded-devel-5.7.19-1.el7.x86_64.rpm

RPM-IVH mysql-community-client-5.7.19-1.el7.x86_64.rpm

5. Database initialization in order to ensure that the database directory is the owner of the file with the MySQL login user, if you are running the MySQL service as root, you need to perform the following command initialization
Mysqld--initialize--user=mysqlmysqld--initialize-insecure--user=mysql

In addition, the--initialize option is initialized in "safe" mode by default, a password is generated for the root user and the password is marked as expired, and you need to set a new password after logging in, while using the--initialize-insecure command does not use Safe mode. The root user generates a password. This demo uses the--initialize initialized, will generate a root account password, the password in the log file, the blue area is the auto-generated password
Cat/var/log/mysqld.log

6. Start the database

Systemctl Start Mysqld.servicemysql-uroot-p

In addition to several errors during installation:

"Error One". Start database times wrong error 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:yes)

Resolve---This error is caused by a password error, the solution is naturally reset password. The first step in resetting the password is to skip the MySQL password authentication process, as follows
#vi/etc/my.cnf
Add "skip-grant-tables" to skip password verification on any line after [mysqld] to save the document and exit: #:wq! Need to restart MySQL

The next step is to use SQL to modify the root password.

mysql> use mysql;mysql> Update user set Password=password ("Your new password") where user= "root";

"Error Two" Then again error: Error 1054 (42S22): Unknown column ' Password ' in ' field List ' cause: There is no password this field in the MySQL database, password The field is changed to authentication_string so the change statement is replaced with the update mysql.user set Authentication_string=password (' root ') where user= ' root ';

Continue running

ALTER USER ' root ' @ ' localhost ' identified by ' 123456 ';

Error three 1290 (HY000): The MySQL server is running with the--skip-grant-tables option so it cannot execute this statem Ent This time we just need to flush privileges a bit, and then continue to change the password on the line

7. Refresh, exit

mysql> Flush privileges;mysql> quit;

8. Edit the my.cnf, remove the content you just added, and then restart MySQL.

Vi/etc/my.cnf

Restart and sign in with the new password

The database installation is complete and can be successfully logged in.

9. Connect the database locally and import the SQL file

Open navicat on your own computer, create a new connection

input IP, Port 3306, enter account password, login, find connection error ....  continue to resolve:MySQL remote connection database Two methods one, connect to the remote database: 1, display password

For example: MySQL connection remote Database (192.168.5.116), port "3306", username "root", password "123456"

C:/>mysql-h 192.168.5.116-p 3306-u root-p1234562, hidden password

such as: MySQL connection to the local database, the user named "root",

C:/>mysql-h Localhost-u Root-p
Enter Password: Second, configure MySQL to allow remote links by default, the MySQL account is not allowed to log on remotely from remote, only on localhost. This article provides two ways to set up MySQL to connect through a remote host. I. Change of Table method

After localhost log in MySQL, change "host" in "User" table in "MySQL" database, rename "localhost" to "%"

For example: #mysql-u root-p Enter password: ... mysql>

Mysql>update User Set host = '% ' where user = ' root ';

Mysql>select host, user from user;

Ii. the law of authorization

For example: you want to myuser use MyPassword (password) from any host to connect to the MySQL server.

Mysql>grant all privileges on * * to ' myuser ' @ '% ' identified by ' MyPassword ' with GRANT OPTION;

If you want to allow users to connect to the MySQL server from a host myuser IP 192.168.1.6 and use MyPassword as the password

Mysql>grant all privileges on * * to ' myuser ' @ ' 192.168.1.3 ' identified by

' MyPassword ' with GRANT OPTION;

Mysql>flush Privileges

Make the changes effective, you can.

Problems:
1, after the adoption of the law two authorization law, can not log on locally mysql (such as: #mysql-u root-p-H 192.168.5.116
Enter Password:
ERROR 1045 (28000): Access denied for user ' root ' @ ' loadb116 ' (using Password:yes)
In the example above, loadb116 is the host name.
Workaround:
1, you can use: Mysql-u root-p login, enter after MySQL.
Mysql> Grant all privileges on * * to ' root ' @ ' loadb116 '
Identified by ' 123456 ' with GRANT option;
Query OK, 0 rows Affected (0.00 sec)
mysql> flush Privileges;
Query OK, 0 rows Affected (0.00 sec)
2. Log on locally using an IP address
# mysql-u Root-p-H 192.168.5.116
Enter Password:
Welcome to the MySQL Monitor. Commands End With; Or/g.
Your MySQL Connection ID is 60
Server version:5.1.45 MySQL Community Server (GPL)

Type ' help; ' or '/h ' for help. Type '/C ' to clear the buffer.

Mysql>All right, we're done, we can finally connect, and we can import the table.Delete MySQLView the packages that have the MySQL installed
Rpm-qa | Grep-i MySQL

Use the command to delete, have dependencies, need to be deleted according to the dependency on the reverse side if you can not delete the back plus--nodeps

Rpm-e mysql-client-5.1.49-1.glibc23 ... and so on.

See if there is a MySQL service

Chkconfig--list | Grep-i MySQL

Delete MySQL Service

[[email protected] ~]# chkconfig--del MySQL

c) Delete the distributed MySQL folder

[[email protected] ~]# Whereis MySQL
MySQL:/usr/lib/mysql/usr/share/mysql

Delete separately

[Email protected] lib]# rm-rf/usr/lib/mysql/
[Email protected] lib]# Rm-rf/usr/share/mysql

Through the steps above, MySQL should have been completely uninstalled "MongoDB" according to the official website tutorial: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/ First create a Mongodb-org-3.4.repo file

Move the file to/etc/yum.repos.d/

Enter the file and edit the file using VI

Press ESC and press I to enter insert mode, copy the following code to write to the file

[Mongodb-org-2.6]name=mongodb 2.6 repositorybaseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/ Gpgcheck=0enabled=1

Install the latest stable version of MongoDB

sudo yum install-y mongodb-org

MongoDB Instances store their data files by default /var/lib/mongoand its log files /var/log/mongodb, and use mongodThe user account runs . where You can specify the alternate log and data files directory /etc/mongod.conf. Start MongoDB:
sudo service Mongod start

Verify that MongoDB has started successfully by checking the logs under/var/log/mongodb/mongod.log to verify that the port is started successfully and the bound IP goes into the/etc/mongod.conf file view

View Log/var/log/mongodb/mongod.log

CD  /var/log/mongodb/cat Mongod.log

Automatically start MongoDB when the server restarts:

sudo chkconfig mongod on

To stop the MongoDB service:

sudo service Mongod stop

To restart MongoDB:

sudo service mongod restart

Production environment Deployment node record (iii): CentOS 7 installation of MySQL and MongoDB

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.