centos7 mounting MySQL (full configuration) at
1. Download and install the MySQL official Yum Repository
[root@localhost ~]# wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
- 1
Mounted directly above commands Yum Repository
[root@localhost ~]# yum -y install mysql57-community-release-el7-10.noarch.rpm
- 1
Installing MySQL Server
root@localhost ~]# yum -y install mysql-community-server
- 1
2. MySQL database is set
to start MySQL
[root@localhost ~]# systemctl start mysqld.service
- 1
View MySQL running state
[root@localhost ~]# systemctl status mysqld.service
- 1
At this time, MySQL has started running properly, we need to find out the root password
[root@localhost ~]# grep "password" /var/log/mysqld.log
- 1
Following command to log mysql
# mysql -uroot -p
- 1
Enter the initial password, this time can not do anything, because MYSQL default password must be changed to normal use
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
# 这里会遇到一个问题,新密码设置过于简单会报错
- 1
- 2
- 3
See the full initial password rules with the following command
mysql>show variables like 'validate_password';
- 1
Command may be modified by
mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=1;
- 1
- 2
Another problem is that Yum Repository, yum after each operation will automatically update, you need to uninstall this
[root@localhost ~]# yum -y remove mysql57-community-release-el7-10.noarch
- 1
Telnet database following error message appeared
ERROR 2003 (HY000): MySQL of Can not Connect to Server ON ' xxx.xxx.xxx.xxx ',
the appropriate authority is no reason to grant
#任何主机
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
#指定主机
mysql>GRANT ALL PRIVILEGES ON *.* TO 'jack'@’10.10.50.127’ IDENTIFIED BY '654321' WITH GRANT OPTION;
# 然后刷新权限
mysql>flush privileges;
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
The overall user table to modify the phase of the mysql database user login from a host
mysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>select host, user from user;
- 1
- 2
- 3
MYSQL client provides the environment, but does not support Chinese, you can view the mysql character set by the following command
mysql>show variables like 'character_set%';
- 1
It is shown below:
To get MySQL support Chinese, need to change the character set UTF-8, as follows
# vim /etc/my.cnf
- 1
Into the following
[client]
port=3306
socket=/var/lib/mysql/mysql.sock
default-character-set=utf8
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
character-set-server=utf8
[mysql]
no-auto-rehash
default-character-set=utf8
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
Restart mysql service
# service mysqld restart
- 1
Re-check the database coding
show variables like 'character_set%';
- 1
The following effects can be seen to have utf-8