linux 安装mysql5.7.15

3 篇文章 0 订阅
3 篇文章 0 订阅

本方法也适用于mysql8安装

一、检查系统原有mysql,并卸载

[root@localhost ~]# rpm -qa | grep -i mysql

mysql-libs-5.1.66-2.el6_3.x86_64
[root@localhost ~]# rpm -e --nodeps mysql-libs-5.1.66-2.el6_3.x86_64


二、删除原有mysql用户、组,创建新用户、组

[root@localhost ~]# userdel mysql

userdel: user 'mysql' does not exist
[root@localhost ~]# groupdel mysql
groupdel: group 'mysql' does not exist

[root@localhost ~]# groupadd mysql

[root@localhost ~]# useradd -g mysql -d /home/mysql mysql


三、创建安装目录、复制系统到安装目录

[root@localhost ~]# mkdir -p /usr/local/mysql/data

[root@localhost ~]# cd /root/Downloads/
[root@localhost Downloads]# tar -xzvf  mysql-5.7.15-linux-glibc2.5-x86_64.tar.gz


[root@localhost Downloads]# cd mysql-5.7.15-linux-glibc2.5-x86_64
[root@localhost mysql-5.7.15-linux-glibc2.5-x86_64]# mv ./* /usr/local/mysql/


四、初始化

[root@localhost mysql-5.7.15-linux-glibc2.5-x86_64]# cd /usr/local/mysql/
[root@localhost mysql]# ls
bin  COPYING  data  docs  include  lib  man  README  share  support-files


[root@localhost mysql]# ./bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
2016-10-06T15:48:20.417452Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-10-06T15:48:21.839527Z 0 [Warning] InnoDB: New log files created, LSN=45790
2016-10-06T15:48:22.139307Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-10-06T15:48:22.278445Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 4f69e1f6-8bdc-11e6-9b6d-000c295b4d3a.
2016-10-06T15:48:22.281625Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2016-10-06T15:48:22.304765Z 1 [Note] A temporary password is generated for root@localhost:PT#oG<q16i.q


五、测试启动,关闭
[root@localhost mysql]# ./support-files/mysql.server start
Starting MySQL..                                           [  OK  ]

[root@localhost mysql]# ./bin/mysql -uroot -p'PT#oG<q16i.q'
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 2
Server version: 5.7.15


Copyright (c) 2000, 2016, 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> set password=password('root');    ## 注:mysql8:set password='root';  
Query OK, 0 rows affected, 1 warning (0.00 sec)

七、设置远程可访问

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)


mysql> quit

Bye

[root@iz2ze288qvorkygkv4riv9z mysql]# ./support-files/mysql.server stop

Shutting down MySQL..                                      [  OK  ]


[root@localhost mysql]# iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport  3306 -j ACCEPT


[root@localhost mysql]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]

[root@localhost mysql]# service iptables restart


八、作成服务、开机启动

[root@localhost mysql]# cp ./support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql]# service mysqld start
Starting MySQL.                                            [  OK  ]

[root@localhost mysql]# chkconfig --add mysqld

[root@localhost mysql]# chkconfig --list mysqld
mysqld         0:off1:off2:on3:on4:on5:on6:off
[root@localhost mysql]# chkconfig mysqld on



补充:

1 报 /var/lib/mysql/xxxx.pid 无法更新时  -- 删除 /etc/my.cnf

2 安装方法也适应于 5.7.16,5,7.17,  5.7.18,8.0.11 其它版本未经测试

3 navicat 连接mysql8时由于加密方式报错:


ALTER USER 'root'@'%' IDENTIFIED BY 'root' PASSWORD EXPIRE NEVER;
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值