To Java, so the service side also toss a bit of Linux.
The following content are relatively novice, do not spray, forgive me.
Installation of CentOS.
- Installation interface has a network settings, be sure to choose to connect, or enter the system after no network, a little bit of trouble, because my Hyper virtual machine is DHCP, IP address is more difficult to remember, so set up more unprepared.
Mysql Installation
Then there is the installation of MySQL, and now there is no MySQL in the Yum repository (who made it an open source Oracle acquisition). ), so you need to manually add one first.
Download the rpm file directly:
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
Tip wget is not installed, install wget and reinstall.
sudo yum install wget
Add the source from RPM to Yum.
sudo rpm -ivh mysql57-community-release-el7-9.noarch.rpm
Then take a look at the list and you'll find Mysql-community-server
Then run the Yum installation. (Note that the download may be slow, you need to install a few dependencies, that is, the installation needs to enter multiple Yes, so do not have the operation, patience to wait for the input y can, if not a small press key causes the next prompt appears to skip directly, re-execute the installation command.
MySQL Startup and configuration
Run the following command to start the MySQL service
sudo systemctl start mysqld
And see if it started successfully.
sudo systemctl status mysqld
Note: This service startup will default to boot, of course, I will not deal with, this happens.
Then check MySQL's default password
sudo grep ‘temporary password‘ /var/log/mysqld.log
You can then reset MySQL with the default password.
Input
sudo mysql_secure_installation
You are prompted to reenter your password, where the default password rule is 12-bit or more including uppercase and lowercase letters and characters. You will then be alerted to the strength of your password and let you confirm that you can enter Y.
Then there will be a few questions that can be answered by the situation, namely:
Whether to delete anonymous users (recommended y)
Whether to allow root users to log on remotely
Whether to delete the test library
Do you want to overload the permissions table now (enter Y)
Test MySQL
After the configuration we tested MySQL.
mysqladmin -u root -p version
If you enter the database version information, then congratulations, MySQL is installed.
CentOS Configuration
The main is open 3306 ports so that can be accessed externally.
This is the default port of MySQL, I did not modify, so I no longer query.
The default CentOS firewall is already firewalld, open port 3306 using the following command:
sudo firewall-cmd --zone=public --add-port=3306/tcp --permanent sudo systemctl restart firewalld
MySQL Basic use
Finally, we introduce the basic use of MySQL.
Let's go to MySQL and test the SQL statement.
mysql -u root -p show databases; use mysql; show tables; select * from user;
These outputs should be fine, but for security purposes, we'll build a separate library and user.
First create the User:
CREATE USER ‘username‘ @ ‘%‘ IDENTITENTY BY ‘password‘ PASSWORD EXPIRE NEVER; create database ‘dbname’; -- 给予用户某库的全部权限 grant all privileges on dbname.* to ‘username‘@‘%‘ identified by ‘password‘
The other content is the MySQL category, no more in-depth discussion.
Complete.
MySQL installation record on CentOS