Install mysql5.6 in CentOS7, modify the character set to utf8, and open the port to allow remote access.

Source: Internet
Author: User
Tags character set mysql in centos iptables

Preface
Mysql's initial free strategy has been deeply rooted in the hearts of the people, and I feel I have been using mysql all the time. Download mysql in centos7 today. It was found that there was no mysql by default in centos, because it started to charge, instead of mariadb, another mysql branch, which was re-dominated by the mysql founder. But, whatever, I want mysql. So, honestly uninstall mariadb and install mysql.

Uninstall mariadb
# List all installed rpm packages
Rpm-qa | grep mariadb

# Uninstall
Rpm e mariadb-libs-5.5.37-1.el7_0.x86_64
Error: dependency check failed:
Libmysqlclient. so.18 () (64bit) is (installed ?) Postfix-2: 2.10.1-6. el7.x86 _ 64 required
Libmysqlclient. so.18 (libmysqlclient_18) (64bit) is ?) Postfix-2: 2.10.1-6. el7.x86 _ 64 required

# Force uninstall because there is no -- nodeps
Rpm-e -- nodeps mariadb-libs-5.5.37-1.el7_0.x86_64
Install mariadb
The yum in centos does not have the mysql-server installation package;
MariaDB is a branch of MySQL community development and an enhanced alternative.

Yum-y install mariadb-server mariadb-devel
Systemctl start mariadb
Systemctl enable mariadb
Mysql_secure_installation
Firewall-cmd -- permanent -- add-service mysql
Systemctl restart firewalld. service
Iptables-L-n | grep 3306
Install mysql
By default, mysql yum sources are not available in centos7 and need to be downloaded again:

1. Download the mysql repo source
$ Wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
2. Install the mysql-community-release-el7-5.noarch.rpm package
$ Sudo rpm-ivh mysql-community-release-el7-5.noarch.rpm
3. Install mysql
$ Sudo yum install mysql-server
4. Reset the password
You need to log on first:

$ Mysql-u root
I used root, but also reported the following error:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql. sock '(2), because of/var/lib/mysql access permission issues. The following command changes the owner of/var/lib/mysql to the current user:

$ Sudo chown-R OpenTracing: OpenTracing/var/lib/mysql

Restart mysql service:

$ Service mysqld restart
Next, set the password:

$ Mysql-u root

Mysql> use mysql;

Mysql> update user set password = password ('000000') where user = 'root ';

Mysql> exit;
Open port 3306
Because centos7 uses firewalld instead of iptables, so:

#3306
Firewall-cmd -- permanent -- add-port = 3306/tcp

Systemctl restart firewalld. service

# Check whether the port is open
Firewall-cmd -- query-port = 3306/tcp

# List
Firewall-cmd -- list-all
Allow remote mysql access
Mysql does not allow remote access by default.
Mysql-u root-p xxxx

Mysql> use mysql
Mysql> grant all privileges on *. * to 'root' @ '%' identified by 'xxxxx (password )';
Mysql> f

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.