CentOS6.7中安装mysql5.7.23(rpm方式)(远程连接,注意关闭防火墙:chkconfig iptables off)

1、 查以前是否装过Mysql(以前装过,注意将之前的文件删除,见文件最后列表)

     rpm -qa|grep -i mysql

2、 发现有的话就都卸载

    rpm -e --nodeps mysql-libs-5.1.73-5.el6_6.x86_64

3、 删除老版本 mysql 的开发头文件和库

   rm -rf /usr/lib/mysql

   rm -rf /usr/include/mysql

   rm -rf /etc/my.cnf

   rm -rf /var/lib/mysql

4.下载:mysql-5.7.23-1.el6.x86_64.rpm-bundle

网址: https://dev.mysql.com/downloads/mysql/5.7.html

5.上传到linux,文件夹自定义,解压:

6.安装:

rpm -ivh mysql-community-common-5.7.23-1.el6.x86_64.rpm

rpm -ivh mysql-community-libs-5.7.23-1.el6.x86_64.rpm

rpm -ivh mysql-community-libs-compat-5.7.23-1.el6.x86_64.rpm

rpm -ivh mysql-community-client-5.7.23-1.el6.x86_64.rpm

rpm -ivh mysql-community-server-5.7.23-1.el6.x86_64.rpm

7.初始化启动:

mysql5.7.23是有区别的:可能会出现错错误:

[root@hadoop04 log]# service mysqld start
Initializing MySQL database:                               [FAILED]
[root@hadoop04 log]# mysqld --initialize
2018-09-28T17:05:43.190726Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-09-28T17:05:43.193357Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2018-09-28T17:05:43.193388Z 0 [ERROR Aborting

这时需要将my.cnf进行修改:

vi /etc/my.cnf

添加如下信息:explicit_defaults_for_timestamp=true

[root@hadoop04 etc]# service mysqld start
Starting mysqld:                                           [  OK  ]

8.启动成功,进行登陆:进入日志文件查看随机登陆密码:vim /var/log/mysqld.log

[root@hadoop04 etc]# service mysqld start
Starting mysqld:                                           [  OK  ]
[root@hadoop04 etc]# vim /var/log/mysqld.log
2018-09-28T17:04:57.173921Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is
 deprecated. Please use --explicit_defaults_for_timestamp server option (see doc
umentation for more details).
2018-09-28T17:04:59.663198Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-09-28T17:04:59.849122Z 0 [Warning] InnoDB: Creating foreign key constraint
system tables.
2018-09-28T17:05:00.129041Z 0 [Warning] No existing UUID has been found, so we a
ssume that this is the first time that this server has been started. Generating
a new UUID: a231b50b-c340-11e8-9cdb-000c29d3d125.
2018-09-28T17:05:00.132428Z 0 [Warning] Gtid table is not ready to be used. Tabl
e 'mysql.gtid_executed' cannot be opened.
2018-09-28T17:05:00.134282Z 1 [Note] A temporary password is generated for root@
localhost:
cj#%j.=19#vC
2018-09-28T17:05:02.345952Z 1 [ERROR] Failed to open the bootstrap file /var/lib
/mysql-files/install-validate-password-plugin.RdxfeP.sql
2018-09-28T17:05:02.345987Z 1 [ERROR] 1105  Bootstrap file error, return code (0
). Nearest query: 'LSE SET @sys.tmp.table_exists.SQL = CONCAT('SELECT COUNT(*) F
ROM `', in_db, '`.`', in_table, '`'); PREPARE stmt_select FROM @sys.tmp.table_ex
ists.SQL; IF (NOT v_error) THEN DEALLOCATE PREPARE stmt_select; SET out_exists =
 'TEMPORARY'; END IF; ENd IF; END;

登陆进来后:无法进行查看操作,这是MySQL5.7.23的设置,需要我们先设置密码:

[root@hadoop04 etc]# mysql -uroot -pcj#%j.=19#vC
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.23

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statshent befo

注意:可能会出现这样的问题:解决方法为在"YoFg;zl)_3D("加上双引号。

[root@hadoop01 soft]# mysql -uroot -pYoFg;zl)_3D(
-bash: syntax error near unexpected token `)'

[root@hadoop01 soft]# mysql -uroot -p"YoFg;zl)_3D("
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.23

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

设置密码:

mysql> set password for 'root'@'localhost'=password('root');
Query OK, 0 rows affected, 1 warning (0.00 sec)

授予任何ip通过root用户访问权限:

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;         
Query OK, 0 rows affected, 1 warning (0.00 sec)

#刷新,使权限生效:
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

9.到此安装完成。

多次安装注意删除的文件(这些文件实在安装过程中生成的,再次安装需要删除,不然会出错):

日志文件:rm -rf /etc/log/mysql.log

数据库目录:rm -rf /var/lib/mysql/
 命令配置:rm -rf /usr/share/mysql 
  启动脚本:rm -rf /etc/rc.d/init.d/  
 系统配置:rm -rf /etc/my.conf

猜你喜欢

转载自blog.csdn.net/qq_15508167/article/details/82887406