1. Features of version 57
MySQL 5.7 is an exciting milestone. On the basis of the default InnoDB engine, ssl, json, virtual columns, etc. are added New features. Compared with postgreSQL and MariaDB, MySQL 5.7 has done a lot of "filling in" operations. Although mysql58 has come out on the market, only the upgraded version of windows has been pushed, and there is no real mysql5.8 installation package, indicating that it is still in the testing stage. When mysql58 is stable, I will write the 58 installation tutorial later.
2. Installation operation
1、 Uninstall the old version
1.1、 View MySQL
|1 2|rpm -qa|grep mysql rpm -qa|grep mariadb|
|--------|--------|
1.2、 Uninstall MySQL
|1 2 3 4|rpm -e --nodeps mysql-5.1.73-7.el6.x86_64 rpm -e --nodeps mysql-connector-odbc-5.1.5r1144-7.el6.x86_64 rpm -e --nodeps mysql-libs-5.1.73-7.el6.x86_64 rpm -qa|grep mysql|
|--------|--------|
1.3、 Delete data directory
|1 2|ls -l /var/lib|grep mysql rm -rf /var/lib/mysql|
|--------|--------|
The data directory can be backed up and removed. The mysqld service checks whether the data directory exists when it is initialized: if the data directory does not exist, mysqld will create it; if the data directory exists and is not an empty directory (that is, contains files or subdirectories), mysqld will display an error message and Abort:
[ ERROR] --initialize specified but the data directory exists. Aborting.
2、 Install MySQL5.7
2.1、 Unzip MySQL5.7
1 | tar -xvf mysql-5.7.14-1.el6.x86_64.rpm-bundle.tar |
---|
The mysql package is ready (including cent6, cent7)
Link: https://pan.baidu.com/s/1egdiiO2q1lOXtoHWd1yQvQ
Extraction code: 11j1
**By the way, the installation environment is CentOS6.5, so you should use the el6 installation package; CentOS7 should use the el7 installation package. **
If the system version corresponding to the installation package is incorrect, a dependency error about glibc will appear during installation:
**warning: **mysql-community-libs-5.7.14-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
libc.so.6(GLIBC_2.14)(64bit) is needed by mysql-community-libs-5.7.14-1.el7.x86_64
2.2、 Install rpm packages in turn according to dependencies
The dependency relationship is common→libs→client→server
1 2 3 4 | rpm -ivh mysql-community-common-5.7.14-1.el6.x86_64.rpm rpm -ivh mysql-community-libs-5.7.14-1.el6.x86_64.rpm rpm -ivh mysql-community-client-5.7.14-1.el6.x86_64.rpm rpm -ivh mysql-community-server-5.7.14-1.el6.x86_64.rpm |
---|
3、 Initialize MySQL5.7
3.1、 Start the mysqld service
1 2 | cd ../sbin is the /usr/sbin directory service mysqld start |
---|
No need to manually initialize, longer startup time, wait patiently
3.2、 Check the running status of mysqld
1 | service mysqld status |
---|
So far, it can be judged that MySQL is basically installed successfully
3.3、 Find the temporary login password
1 | vi /var/log/mysqld.log |
---|
You can also use this command to quickly find cat /var/log/mysqld.log | grep password and find a random password to log in to MySQL
3.4、 log in
1 | mysql -uroot -p |
---|
4、 Configure MySQL remote access
4.1、 Change root password
1 | alter user 'root'@'localhost' identified by 'abc@123'; |
---|
After 5.6, MySQL has a built-in password enhancement mechanism, and low-strength passwords will report an error:
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
4.2、 Add remote login user
1 2 | use mysql; GRANT ALL PRIVILEGES ON . TO 'root'@'%' IDENTIFIED BY 'abc@123' WITH GRANT OPTION; |
---|
' %'represents any address, you can also specify IP
4.3、 Check user table, refresh memory permissions
1 2 | select host, user from user; FLUSH PRIVILEGES; |
---|
4.4、 Set up firewall
1 | vi /etc/sysconfig/iptables |
---|
Before -A RH-Firewall-1-INPUT -j REJECT –reject-with icmp-host-prohibited, add
1 | - A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT |
---|
4.5、 Restart firewall
1 | service iptables restart |
---|
4.6、 Debug mysql57 encoding format
Enter the mysql command line and enter: show variables like'character%';
We need to adjust the database and server to utf8;
First we find the my.cnf file
Modify the content of my.cnf: just add it under the corresponding label (as shown in the figure below), add it without the [mysql] label;
[ mysql]
default-character-set=utf8
[ mysqld]
character_set_server=utf8
collation_server=utf8_general_ci
Restart mysql after saving; service mysqld restart; log in to mysql command line again after restart
Type show variables like'character%';
The following figure shows that the database configuration is complete;
Recommended Posts