Install MySQL using yum under CentOS6.8 and log in to MySQL remotely

Source: Internet
Author: User
Tags mysql in iptables

1th step, see if MySQL is installed under CentOS

Input command: Yum List installed | grep MySQL

2nd step, remove installed MySQL

Input command: yum-y remove mysql

Seeing complete means success.

3rd step, view MySQL in the Yum Library (not required)

Input command: Yum List | grep MySQL

4th step, installing MySQL from the Yum Library

Input command: yum-y install MySQL Mysql-servermysql-devel

5th step, verify the installation is successful

Input command: Rpm-qi mysql-server

6th step, start the MySQL service

Input command: Service mysqld start

7th step, enter MySQL

Input command: Mysql-u root

If error 2002 (HY000): Can ' t connect tolocal MySQL server through socket '/var/lib/mysql/mysql.sock ' errors, either the service is not turned on or it may be/va R/lib/mysql access rights issues.
If the service is not turned on: Services mysqld start
If this is an access issue: Chown-r Openscanner:openscanner/var/lib/mysql

8th Step, Change Password

mysql > Use MySQL;
MySQL > Update user set Password=password (' 123456 ') where user= ' root ';

9th step, login with new password

Mysql-u root–p

Note: SSH may not login, then do not password login: mysql-u root

10th step, open Telnet permission

To use the Modify table method:

Modify the user table of the MySQL library to change the host entry from localhost to%. % here is to allow any host access, if only one IP access, you can change to the corresponding IP, such as can be changed to 192.168.1.123, this means that only allow LAN 192.168.1.123 this IP remote access to MySQL.

mysql> use MySQL;

mysql> Update user Set host = '% ' where user = ' root ';

Note: May update the Times wrong, you can skip this step

Mysql> Select Host, user from user;

mysql> flush Privileges;

11th Step, open 3306 port

Input command: Vim/etc/sysconfig/iptables
Add to

-A input-p tcp-m state--state new-m TCP--dport 3306-j ACCEPT

Note: The state and dport front are two middle bars--。 and place your attention on the 80 below.


Then restart the firewall: service iptables restart

12th Step, set boot start (not required), finish.

Chkconfig mysqld on

Error Summary 1, execute install command times wrong

[Email protected] mysql-5.6.26-linux-glibc2.5-x86_64]#/scripts/mysql_install_db--user=mysql

Installing MySQL system Tables..../bin/mysqld:error while loading shared libraries:libaio.so.1:cannot open shared objec T file:no such file

Cause: The installation package Libaio and Libaio-devel are missing.
Command line #yum Install libaio*

Install these two packages automatically

2, install set root password, but login failure prompt: ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (usingpassword:no)?

#1. Stop the MySQL database

/etc/init.d/mysqld stop

#2. Execute the following command

Mysqld_safe--user=mysql--skip-grant-tables--skip-networking &

#不关闭窗口, open a separate window to perform the following steps

#3. Log in to the MySQL database using root

Mysql-u Root MySQL

#4. Update the root password

mysql> UPDATE user Setpassword=password (' newpassword ') where user= ' root ';

#最新版MySQL请采用如下SQL:

mysql> UPDATE user Setauthentication_string=password (' newpassword ') where user= ' root ';

#5. Refresh Permissions

mysql> FLUSH privileges;

#6. Quit MySQL

Mysql> quit

#7. Restart MySQL

/etc/init.d/mysqld restart

#8. Log back in to MySQL with the root user

Mysql-u root-p

Enter Password: < Enter the newly set password newpassword>

Maintenance methods

Completely uninstall MySQL under 1,centos

http://blog.csdn.net/rosten/article/details/25096159

Install MySQL using yum under CentOS6.8 and log in to MySQL remotely

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.