Centos7.2 install mysql and centos7.2mysql on 64-bit linux
1Online InstallationMysql
Enter the command line in the terminal (download mysql from the official website ):
# Wget https://dev.mysql.com/downloads/repo/yum/mysql57-community-release-el7-11.noarch.rpm
# Sudo rpm-ivh mysql-community-release-el7-5.noarch.rpm
(The system prompts that the permission is insufficient at the beginning. You can enter the user password of the system when you execute the command again)
After installing this package, you will get the yum repo source for both mysql:/etc/yum. repos. d/mysql-community.repo,/etc/yum. repos. d/mysql-community-source.repo.
# Sudo yum install mysql-community-server (start the installation command)
After the installation is complete, run the command in the figure to check whether the installation is correct.
After successful installation, restart the mysql service.
# Service mysqld (service name) restart
2, ModifyRootPassword:
The first time mysql is installed, the root account does not have a password. In the MySQL Installation Log information, you can see that MySQL generates a random password for the root user (as shown below) and places the random password in/root/. mysql_secret. And force the root user's password to be changed during the first login. Mysql 5.6 and later versions come from security considerations. The root password is not empty. Therefore, a random password is generated during MySQL installation.
Use: grep 'temporary password'/var/log/mysqld. log to view the randomly generated password.
Find the random password and use mysql-u root-p to log on to the database and change the password:
Change Password:
Validate_password_policy: Password Policy. The default value is MEDIUM.
Validate_password_dictionary_file: password policy file, which is required only when the password policy is STRONG.
Validate_password_length: Minimum Password Length
Validate_password_mixed_case_count: case-sensitive length, at least 1
Validate_password_number_count: at least one number
Validate_password_special_char_count: at least one special character
The above parameters are the password check rules of the Default policy MEDIUM.
When you view the database again, it is displayed as successful:
3Modify the character encoding of a database:
View the database character encoding: show variables like "% char % ";
Mysql> set character_set_client = utf8;
Mysql> set character_set_connection = utf8;
Mysql> set character_set_database = utf8;
Mysql> set character_set_results = utf8;
Mysql> set character_set_server = utf8;
Mysql> set character_set_system = utf8;
4, Set boot start:
Shell> systemctl enable mysqld
Shell> systemctl daemon-reload
5Remote connection settings
Assign all permissions for all tables in all databases to the root user at all IP addresses.
Mysql> grant all privileges on *. * to root @ '%' identified by 'Password ';
6Open3306Port Number :
Firewalld firewall (centos-7) run the command and restart:
Firewall-cmd -- zone = public -- add-port = 3306/tcp -- permanent
Firewall-cmd -- reload
7, ChangeMysqlFolder Permissions
When you create a database, if the message "ERROR 1006 (HY000): Can't create database 'mydb' (errno: 15689408)" is displayed, one important reason is that the permission is insufficient, run "chown-R mysql: mysql/var/lib/mysql" in the terminal command.
8Use a terminal to test the connection on other machines: