Novice learning Linux (eight) ---- MySql installation (Centos7)

Recently, the project applied for Cloud Server. The boss asked me to set up the environment. I encountered a little bit more pits when installing MySql, so I will make a record here. My installation method is not to install through the installation package, but through yum to install, so that can save a lot of things, let's talk about the specific installation process.

1. Uninstall the original mysql

Because the mysql database is so popular on Linux now, the mainstream Linux system versions currently downloaded basically integrate the mysql database in it, we can use Use the following command to check whether the mysql database has been installed on our operating system;

rpm -qa | grep mysql  //This command will check whether the mysql database has been installed on the operating system

If yes, we will uninstall it through rpm -e command or rpm -e --nodeps command

rpm -e mysql  //Normal delete mode
rpm -e --nodeps mysql  //Forced deletion mode, if you use the above command to delete other files that are dependent on it, you can use this command to delete it forcefully

After deleting, we can use the rpm -qa | grep mysql command to check whether mysql has been uninstalled successfully! !

Two, install mysql through yum

At the beginning, it was installed directly through this command:

yum install mysql mysql-server mysql-devel

The installation of mysql and mysql-devel were successful, but the installation of mysql-server failed, as follows:

[ localhost ~]# yum install mysql-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.sina.cn
 * extras: mirrors.sina.cn
 * updates: mirrors.sina.cn
No package mysql-server available.
Error: Nothing to do

Checking the information found that the CentOS 7 version removed the MySQL database software from the default program list. There are two ways to solve it. Use **MariaDB instead, the other way is from the official website Download and install

 wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm     //Download the YUM library

 yum localinstall -y mysql57-community-release-el7-7.noarch.rpm  //Install YUM library

 yum install -y mysql-community-server   //Install the database

 systemctl start mysqld.service  //Start the database service

 mysql -uroot -p   //Default empty password

Restart the mysql service after resetting the root password:

update mysql.user set authentication_string=password("yourpassword") where user="root" and Host="localhost";
flush privileges;
quit;
systemctl restart mysqld;

At this time there was a problem:

ERROR 1045(28000): Access denied for user 'root'@'localhost'(using password: NO)

Please modify my.cnf and add skip-grant-tables and skip-networking:

vi /etc/my.cnf

[ mysqld]

skip-grant-tables

skip-networking

Restart mysql and repeat the above steps to modify the password. Remember to remove the two lines added by my.cnf after the modification. If you have other questions, you can refer to this blog for details: http://www.cnblogs.com/ivictor/p/5142809.html

Three, add remote login users

After completing the above steps, that is to use locally, if you want to connect remotely, you need to do specific configuration.

use mysql;

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Your password' WITH GRANT OPTION;

Note:'%'Represents any address, IP can also be specified

Check user table, refresh memory permissions

select host, user from user;

FLUSH PRIVILEGES;

Now, the database is ready for use. In the future, you can set up a firewall or encoding format.

Turn off the firewall

centos 7:
systemctl stop firewalld.service #stop
systemctl disable firewalld.service #Disable
previous version:
service iptables stop #stop
chkconfig iptables off #Disable

View the status of mysql:

* View current mysql running status

mysql>status

Parameter Description:

haracter_set_client: The character set of the data requested by the client.

character_set_connection: The character set of the data received from the client and then transmitted.

character_set_database: The character set of the default database, no matter how the default database is changed, it is this character set; if there is no default database, use character_set_The character set specified by the server, this parameter does not need to be set.

character_set_filesystem: Convert the file name on the operating system into this character set, that is, the character_set_client conversion character_set_filesystem, the default is binary.

character_set_results: The character set of the result set.

character_set_server: The default character set of the database server.

character_set_system: This value is always utf8 and does not need to be set. The character set for storing system metadata.

Recommended Posts

Novice learning Linux (eight) ---- MySql installation (Centos7)
Mysql8.0.15 installation configuration (centos7)
Linux notes (1): CentOS-7 installation
Linux CentOS 7 installation tutorial
CentOS 6.x installation mysql5.7 record
CentOS8 Linux 8.0.1905 installation process (illustration)
Installation under centos6.9 of jenkins learning
Install MySQL on Linux CentOS7 (Windows)
The latest Centos7 installation Mysql8 guide
Centos7 mysql database installation and configuration
[Switch] CentOS7 64-bit installation mysql tutorial
2019-07-09 CentOS7 installation
centos7_1708 installation
Installation and use of Mysql under CentOS
MySQL 8.0 installation, deployment and configuration under CentOS 6/7
Linux kernel compilation and CentOS system installation
Install mysql8.0.13 version under Linux CentOS7 system
Linux environment construction: CentOs + Apache + MySQL + PHP
Centos5 installation guide
CentOS7.2 install Mysql5.7.13
CentOS7 install MySQL
Python - centos6 installation
Linux (CentOS7) using RPM to install mysql 8.0.11 tutorial
CentOS install mysql
Linux basics-centOS7 installation
Linux learning 11-CentOS install ab for stress test
Docker installation (CentOS7 installation)
CentOS7 install mysql
CentOS 7 install MySQL 5.6
CentOS8 install MySQL8.0
CentOS7 install mysql8
CentOS7 docker installation
MySQL 8.0 installation and deployment under CentOS, super detailed!
CentOS7 install MySQL8
Centos MySQL8 configuration
centos 7.5 install mysql5.7.17
MySQL 8.0 installation, deployment and configuration tutorial on CentOS 8
Detailed tutorial on installing JDK8 on Linux system (CentOS7 installation)
CentOS online installation RabbitMQ3.7
Linux Network Foundation (CentOS7)
Zabbix 2.2.20 installation details (Centos6.9)
Install MySQL5.7 in centos7
Install mysql5.7 under CentOS7
Centos source installation Python3
Linux system-Centos7 installation tutorial
lamp (centos7) installation lamp environment
Linux Centos7 install jdk1.8
CentOS 7.2 Yum install MySQL 5.6
CentOS (linux) install PostgreSQL
Centos7 install Mysql8 tutorial
Centos7 mqtt cluster installation
Graphical installation of CentOS8
Centos manually install mysql8
CentOS7 reset MySQL8.0 password
Centos7 install Mysql database
Redis3 installation under Centos7
Docker CentOS installation method
Centos 7 install JDK (Linux install jdk)
Centos7 docker installation details
Introduction to CentOS7 installation process of openjdk, tomcat and mysql