centos7 + mysql5.7 tar包解压安装

先执行wget https://dev.mysql.com//Downloads/MySQL-5.7/mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz命令

这是别人的文章,咱只是收藏一下,亲试可用。

#卸载系统自带的Mariadb
[root@hdp265dnsnfs ~]# rpm -qa|grep mariadb
mariadb-libs-5.5.44-2.el7.centos.x86_64
[root@hdp265dnsnfs ~]# rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64 #删除etc目录下的my.cnf文件 [root@hdp265dnsnfs ~]# rm /etc/my.cnf
rm: cannot remove ?etc/my.cnf? No such file or directory #检查mysql是否存在
[root@hdp265dnsnfs ~]# rpm -qa | grep mysql
[root@hdp265dnsnfs ~]# #检查mysql组和用户是否存在,如无创建
[root@hdp265dnsnfs ~]# cat /etc/group | grep mysql
[root@hdp265dnsnfs ~]# cat /etc/passwd | grep mysql #创建mysql用户组
[root@hdp265dnsnfs ~]# groupadd mysql
#创建一个用户名为mysql的用户并加入mysql用户组
[root@hdp265dnsnfs ~]# useradd -g mysql mysql
#制定password 为111111
[root@hdp265dnsnfs ~]# passwd mysql
Changing password for user mysql.
New password:
BAD PASSWORD: The password is a palindrome
Retype new password:
passwd: all authentication tokens updated successfully. #由于我的/usr/local空间不足,所以我安装到/var
[root@hdp265dnsnfs var]# tar -zxvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
[root@hdp265dnsnfs var]# mv mysql-5.7.18-linux-glibc2.5-x86_64/ mysql57 #更改所属的组和用户
[root@hdp265dnsnfs var]# chown -R mysql mysql57/
[root@hdp265dnsnfs var]# chgrp -R mysql mysql57/
[root@hdp265dnsnfs var]# cd mysql57/ [root@hdp265dnsnfs mysql57]# mkdir data [root@hdp265dnsnfs mysql57]# chown -R mysql:mysql data

在etc下新建配置文件my.cnf,并在该文件内添加以下配置

[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
skip-name-resolve
#设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=/var/mysql57
# 设置mysql数据库的数据的存放目录
datadir=/var/mysql57/data
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
lower_case_table_names=1
max_allowed_packet=16M

安装和初始化

[root@hdp265dnsnfs mysql57]# bin/mysql_install_db --user=mysql --basedir=/var/mysql57/ --datadir=/var/mysql57/data/
2017-04-17 17:40:02 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2017-04-17 17:40:05 [WARNING] The bootstrap log isn't empty:
2017-04-17 17:40:05 [WARNING] 2017-04-17T09:40:02.728710Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead
2017-04-17T09:40:02.729161Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2017-04-17T09:40:02.729167Z 0 [Warning] Changed limits: table_open_cache: 407 (requested 2000)
[root@hdp265dnsnfs mysql57]# cp ./support-files/mysql.server /etc/init.d/mysqld
[root@hdp265dnsnfs mysql57]# chown 777 /etc/my.cnf
[root@hdp265dnsnfs mysql57]# chmod +x /etc/init.d/mysqld
[root@hdp265dnsnfs mysql57]# /etc/init.d/mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS! #设置开机启动 [root@hdp265dnsnfs mysql57]# chkconfig --level 35 mysqld on
[root@hdp265dnsnfs mysql57]# chkconfig --list mysqld [root@hdp265dnsnfs mysql57]# chmod +x /etc/rc.d/init.d/mysqld
[root@hdp265dnsnfs mysql57]# chkconfig --add mysqld
[root@hdp265dnsnfs mysql57]# chkconfig --list mysqld
[root@hdp265dnsnfs mysql57]# service mysqld status
SUCCESS! MySQL running (4475)

etc/profile/

export PATH=$PATH:/var/mysql57/bin

[root@hdp265dnsnfs mysql57]# source /etc/profile

获得初始密码

[root@hdp265dnsnfs bin]# cat /root/.mysql_secret
# Password set for user 'root@localhost' at 2017-04-17 17:40:02
_pB*3VZl5T<6

修改密码

[root@hdp265dnsnfs bin]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.18 Copyright (c) 2000, 2017, 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('111111');
Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> flush privileges;
Query OK, 0 rows affected (0.01 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> select host,user from user;
+-----------+-----------+
| host | user |
+-----------+-----------+
| % | root |
| localhost | mysql.sys |
+-----------+-----------+
2 rows in set (0.00 sec) create user 'xxx'@'%' identified by '123';  这里 @‘%’ 表示在任何主机都可以登录

重启生效

/bin/systemctl restart  mysql.service

[root@hdp265dnsnfs bin]# /etc/init.d/mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!

为了在任何目录下可以登录mysql

ln -s /var/mysql57/bin/mysql   /usr/bin/mysql

最新文章

  1. jQuery的选择器中的通配符[id^=&#39;code&#39;]
  2. 【代码笔记】iOS-点评内容
  3. 6-10k招几个.NET开发工程师(工作地点:成都)
  4. iOS-CAShapelayer
  5. 初识数据字典【weber出品必属精品】
  6. 设计适用于SOA的类型(二)
  7. JavaBean,List,Map转成json格式
  8. 201521123062《Java程序设计》第2周学习总结
  9. 关于模块安装及cmd安装pip3模块失败的 Read timed out.的补救方法
  10. 此博客不再更新和分享UiPath文章
  11. [Spark][Python]Spark 访问 mysql , 生成 dataframe 的例子:
  12. Jackson 时间格式化,时间注解 @JsonFormat 用法、时差问题说明
  13. SVN中的Trunk、Tag、Brance的用法
  14. Python 学习笔记(十四)Python类(一)
  15. 关于java.lang.Exception:No tests found matching的一系列解决方法
  16. HTML基础信息笔记
  17. sqlserver 构架与性能优化
  18. Azkaban安装配置
  19. Tensorflow之合并tensor
  20. Tornado抽象方法抽象类

热门文章

  1. CSS 技巧汇总
  2. 从未来看 C#
  3. CSS——NO.6(盒模型)
  4. Sublime Text3 旧版本下载以及破解激活方式
  5. 软件工程实验一 Git代码版本管理
  6. 使用Properties配置文件进行配置读取
  7. Ubuntu18.04LTS安装docker报错:Command &#39;lsb_release&#39; not found
  8. jsvascript篮球梦
  9. 2020 新个税算的头疼?会 python,这都不是事儿...
  10. 使用Navicat Premiun远程连接MySQL失败,报错(10038)