CentOS installation and deployment Mysql 5.7
1. If you do not install wget, first install
yum -y install wget
2. Download the MySQL official Yum Repository
wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm
3. Use the top command we downloaded to Yum Repository, then we can use yum to install.
yum -y install mysql57-community-release-el7-10.noarch.rpm
4. Installation mysql server
yum -y install mysql-community-server
5. Start mysql
systemctl start mysqld.service
6. Check the status of running mysql
systemctl status mysqld.service
7. At this point, we have the database up and running, but we have to enter the database, then we also need to find our root user's password in the log. In the new version, the default root password is generated.
grep "passsword" /var/log/mysqld.log
We can look to our root user's password through the top order.
mysql -uroot -p
Enter the password to access the database.
Enter the initial password, this time can not do anything, because the default MySQL database to operate after the password must be changed:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
Here the password to have a certain complexity. To include numbers, uppercase letters, lowercase letters, special characters.
After completion we can change the password for normal operation of the.
But if you want to set short-answer password can be set as follows:
First, change the value of the parameter validate_password_policy
set global validate_password_policy=0;
Then modify the length of the password
set global validate_password_length=1;
Modify the password again to perform on it
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
8. But this time there is a problem, because the Yum Repository installation, yum after each operation will automatically update, you need to uninstall this:
yum -y remove mysql80-community-release-el7-1.noarch
9. Set of two boot command
systemctl enable mysqld
systemctl daemon-reload
10. Add a remote user login
By default only allow the root account to log on locally, if you want to connect mysql on another machine, you must modify the root allow remote connections, or add an account to allow remote connections, for security reasons, I add a new account:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
Parsing:
grant all privileges on 库名.表名 to 用户名@"%" identified by "密码"
;The database name. If the name written in the table. Authorized representatives of all database
flush privileges
; # Just refresh content
11. Configure default encoding is utf8
/Etc/my.cnf profile change, add [mysqld] the encoding scheme, as follows:
[mysqld] character_set_server=utf8 init_connect='SET NAMES utf8'
12. Restart the mysql service
systemctl restart mysqld