Summary of the problems encountered when installing Mysql5.7.16 on the centOS6.5 platform of the aliyun platform

Problems encountered in installing mysql5.7

1. At the beginning of the installation, the tar package installation method was used. After decompression, it was directly a folder and then the configuration method encountered many problems and failed.

2. Install using yum --success 

Highlight 2 The problems encountered in this way

1. Official download address: http://dev.mysql.com/downloads/mysql/ Package name: mysql-5.7.16-1.el6.x86_64.rpm-bundle.tar Platform: red hat (because the aliyun platform is centOS6 .5)

2. Articles referenced by the installation process: http://blog.163.com/ky_199/blog/static/1431760201671710520468/

3. After the installation is complete, the default path where the startup script is placed is: /usr/sbin/

4. Several commands are commonly used: service mysqld start/stop [start/stop] service mysqld restart [restart] mysql -uroot -p [root user login, the same as on windows]  Note: the password needs to be enclosed in single quotes, I remember it was No need to add. Suppose the set mysql login password is: 123abc, then the login command: mysql -uroot -p'123abc';

Execute the SQL file: mysql> source /home/xxx.sql

5. As described in the 2 tutorial, a random password will be printed in the log during the installation process for the subsequent login path: /var/log/mysqld.log but it is not generated during the installation process (the tutorial version is: 5.7. 14 And I downloaded the latest version 5.7.16)

   There are also articles saying that it will be generated in the cat /root/.mysql_secret directory. There is indeed this file in this directory, and there is a random password in it, but this password is generated during the installation process of method 1, not during the execution of the yum method.

6. After the installation is complete, log in to mysql and if it reports [Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'], then open /etc/my.cnf to view the attribute socket=/var/lib/ mysql/mysql.sock

Whether the value of mysql.sock is the same as the error path, if it is inconsistent, modify it to be consistent, after restarting the service, the mysql.sock file will be automatically generated under the error path. Login successful

 

7. According to the normal logic, a random password for the root user should be generated after the installation is completed. After logging in to MySQL with this password, modify the default password, but because it has not been generated, it cannot be logged in. If you add to the my.cnf file: skip- grant-tables

    option, you can log in successfully without entering a password, but if you want to change the root user password after success, you will be prompted that it is not allowed. How to fix: Reference: 8

 

8. Reference article: https://my.oschina.net/zvc/blog/610377

(1) delete from mysql.user where user='root' and host='localhost'; delete the root user, mysql will automatically re-establish the user

(2) GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'V(password)' WITH GRANT OPTION; Modify the root user password to solve

 

9. The 'INFORMATION_SCHEMA.SESSION_VARIABLES' error will be reported when using the client connection after the MySQL installation is successful

The reason is: since mysql5.7.6, information_schema.global_status has been discarded. For compatibility, it is necessary to open the relevant configuration in the system table at this time.

 

(1) View attribute values

mysql> show variables like '%show_compatibility_56%';

+-----------------------+-------+

| Variable_name         | Value |

+-----------------------+-------+

| show_compatibility_56 | OFF   |

+-----------------------+-------+

 

//修改值

(2)mysql> set global show_compatibility_56=on;

Query OK, 0 rows affected (0.00 sec)

 

(3)再次查看

mysql> show variables like '%show_compatibility_56%';

+-----------------------+-------+

| Variable_name         | Value |

+-----------------------+-------+

| show_compatibility_56 | ON    |

+-----------------------+-------+

1 row in set (0.00 sec)

 

 

 

补充:

1、使用mysqldump命令备份

该命令使用时不是登录mysql后在 >mysql 命令行下使用, 默认情况下安装到/usr/bin/路径,在该路径下操作

格式:

mysqldump -u 用户名-p 密码 数据库名 > /home/sqlbak/bak.sql(备份路径)

注意:当密码中含有 &等特殊字符时, 要按照如下格式写:  - u root - p'abc&def' 否则 &会将命令截断产生异常。

 

2、通过迁移数据文件方式,完成数据恢复

linux系统下,mysql的数据文件默认放置在/var/lib/mysql 下,如欲将B机器数据迁移到A机器,则 在A机器安装完成数据后,首先停止A B 的mysql service 然后将B机器/var/lib/mysql 文件夹 mv到 A机器的相关文件目录(为何是mv 不是cp,因为mv会保留原来文件所有属性,防止出现其他问题)

注意: 如果B机器的mysql文件夹mv到A机器上之后,没有放置在A机器mysql读取的路径下,需要修改A机器mysql相关配置文件,使其能找到相关文件,否则将报服务启动失败,另外在迁移过程中还遇到过权限问题【文件夹mv后,启动服务报找不到文件】,使用命令 chomd -R 777 *  对 mysql文件夹全部赋予权限后,服务启动成功

 

3、修改root用户密码

use mysql; --切换数据库

--以下2选1

①:update user set password=passworD("123") where user='root';

②:update user set authentication_string=password("123") where user='root';

 

具体使用 set password  或者  set authentication_string 要看具体的数据库版本,在较新的版本中将password字段修改为了 authentication_string

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326541468&siteId=291194637