(1)、下载安装包

https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.23-linux-glibc2.12-x86_64.tar

[root@localhost local]# wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.23-linux-glibc2.12-x86_64.tar
---- ::-- https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.23-linux-glibc2.12-x86_64.tar
Resolving dev.mysql.com (dev.mysql.com)... 137.254.60.11
Connecting to dev.mysql.com (dev.mysql.com)|137.254.60.11|:... connected.
HTTP request sent, awaiting response... Found
Location: https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.23-linux-glibc2.12-x86_64.tar [following]
---- ::-- https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.23-linux-glibc2.12-x86_64.tar
Resolving cdn.mysql.com (cdn.mysql.com)... 23.36.193.224
Connecting to cdn.mysql.com (cdn.mysql.com)|23.36.193.224|:... connected.
HTTP request sent, awaiting response... OK
Length: (643M) [application/x-tar]
Saving to: 鈥榤ysql-5.7.-linux-glibc2.-x86_64.tar鈥 %[========================================================================>] ,, 191KB/s in 53m 15s -- :: ( KB/s) - 鈥榤ysql-5.7.-linux-glibc2.-x86_64.tar鈥saved [/] [root@localhost local]# ls
bin etc games include lib lib64 libexec mysql-5.7.-linux-glibc2.-x86_64.tar sbin share src
[root@localhost local]# mv mysql-5.7.-linux-glibc2.-x86_64.tar src/

(2)、解压到/usr/local/下,重命名为mysql

[root@localhost src]# tar xvf mysql-5.7.-linux-glibc2.-x86_64.tar -C /usr/local/
mysql-5.7.-linux-glibc2.-x86_64.tar.gz
mysql-test-5.7.-linux-glibc2.-x86_64.tar.gz
[root@localhost src]# cd ../
[root@localhost local]# ls
bin include libexec sbin
etc lib mysql-5.7.-linux-glibc2.-x86_64.tar.gz share
games lib64 mysql-test-5.7.-linux-glibc2.-x86_64.tar.gz src
[root@localhost local]# tar xvf mysql-5.7.-linux-glibc2.-x86_64.tar.gz
mysql-5.7.-linux-glibc2.-x86_64/bin/myisam_ftdump
mysql-5.7.-linux-glibc2.-x86_64/bin/myisamchk
mysql-5.7.-linux-glibc2.-x86_64/bin/myisamlog
mysql-5.7.-linux-glibc2.-x86_64/bin/myisampack
.
.
.
[root@localhost local]# mv mysql-5.7.-linux-glibc2.-x86_64 mysql
[root@localhost local]# ls
bin games lib libexec mysql-5.7.-linux-glibc2.-x86_64.tar.gz sbin src
etc include lib64 mysql mysql-test-5.7.-linux-glibc2.-x86_64.tar.gz share

 (3)、在mysql下创建数据库文件目录

[root@localhost local]# mkdir mysql/data

(4)、创建mysql用户组和用户,并对mysql目录设置用户组和用户

[root@localhost local]# groupadd mysql
[root@localhost local]# useradd mysql -g mysql
[root@localhost local]# cd mysql/
[root@localhost mysql]# chown -R mysql .
[root@localhost mysql]# chgrp -R mysql .

(5)、安装初始化

由于MySQL运行需要libaio库,所以需要运行以下命令进行安装

[root@localhost mysql]# yum install libaio
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.cn99.com
* extras: mirrors.shu.edu.cn
* updates: mirrors.shu.edu.cn
Package libaio-0.3.-.el7.x86_64 already installed and latest version
Nothing to do
[root@localhost bin]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
-- :: [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
-- :: [WARNING] The bootstrap log isn't empty:
-- :: [WARNING] --02T11::.811985Z [Warning] --bootstrap is deprecated. Please consider using --initialize instead
--02T11::.819990Z [Warning] Changed limits: max_open_files: (requested )
--02T11::.820064Z [Warning] Changed limits: table_open_cache: (requested )
[root@localhost support-files]# ./mysql.server start
Starting MySQL.Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
SUCCESS!

(6)、登录mysql

此版本最新版不许空密码登录,实际上有个初始化密码保存在/root/.mysql_secret这个文件里面,用这个密码第一次登录后,再修改密码。

[root@localhost support-files]# cat /root/.mysql_secret
# Password set for user 'root@localhost' at -- ::
B#ipur,uyB>a
[root@localhost support-files]# mysql -uroot -p
-bash: mysql: command not found
[root@localhost support-files]# ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
[root@localhost support-files]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.7. Copyright (c) , , 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的root密码,新密码在此为'123456'

mysql> set password=password('');
Query OK, rows affected, warning (0.00 sec)

(7)、复制配置文件

查看support-files文件夹的内容,发现并没有my-default.cnf默认的配置文件,如果没有默认的配置文件,需要手动创建一个my-default.cnf配置文件。

[root@localhost support-files]# ls -la
total
drwxr-xr-x. mysql mysql Aug : .
drwxr-xr-x. mysql mysql Aug : ..
-rw-r--r--. mysql mysql Jun : magic
-rwxr-xr-x. mysql mysql Jun : mysqld_multi.server
-rwxr-xr-x. mysql mysql Jun : mysql-log-rotate
-rwxr-xr-x. mysql mysql Jun : mysql.server

从网上找了一个配置文件,如下,上传到supp-files文件夹中,当然这个配置文件可以根据需要自行修改

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL. [mysqld]
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port =
socket = /tmp/mysql.sock
key_buffer_size=16M
max_allowed_packet=8M
character-set-server=utf8
back_log =
max_connections =
max_connect_errors =
table_open_cache =
#binlog_cache_size = 4M
max_heap_table_size = 128M
read_rnd_buffer_size = 16M
sort_buffer_size = 16M
join_buffer_size = 16M
thread_cache_size =
query_cache_size = 128M
query_cache_limit = 4M
ft_min_word_len =
thread_stack = 512K
transaction_isolation = REPEATABLE-READ
tmp_table_size = 128M
#log-bin=mysql-bin
long_query_time =
server_id=
innodb_buffer_pool_size = 1G
innodb_thread_concurrency =
innodb_log_buffer_size = 16M
innodb_log_file_size = 512M
innodb_log_files_in_group =
innodb_max_dirty_pages_pct =
innodb_lock_wait_timeout =
innodb_file_per_table = on [mysqldump]
quick
max_allowed_packet = 32M [mysql]
no-auto-rehash
connect_timeout= [client]
port=
socket = /tmp/mysql.sock
[root@localhost support-files]# cp my-default.cnf /etc/my.cnf
[root@localhost support-files]#
[root@localhost support-files]# ./mysql.server start
Starting MySQL. SUCCESS!

(8)、将mysqld服务加入开机自启动项

首先需要将support-files/mysql.server服务脚本复制到/etc/init.d/,并重命名为mysqld。

[root@localhost support-files]# cp mysql.server /etc/init.d/mysqld
[root@localhost support-files]# ls -la /etc/init.d/
total
drwxr-xr-x. root root Aug : .
drwxr-xr-x. root root Jul : ..
-rw-r--r--. root root Jan functions
-rwxr-xr-x. root root Aug : mysqld
-rwxr-xr-x. root root Jan netconsole
-rwxr-xr-x. root root Jan network
-rw-r--r--. root root Apr : README

通过chkconfig命令将mysqld服务加入到自启动服务项中

[root@localhost support-files]# chkconfig --add mysqld

查看是否添加成功

[root@localhost support-files]# chkconfig --list

Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration. If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'. mysqld :off :off :on :on :on :on :off
netconsole :off :off :off :off :off :off :off
network :off :off :on :on :on :on :off

(9)、重启系统,mysqld就会自动启动了

检查是否启动

[root@localhost ~]# netstat -anp|grep mysqld
tcp6 ::: :::* LISTEN /mysqld
unix [ ACC ] STREAM LISTENING /mysqld /tmp/mysql.sock

如果不想重新启动,那可以直接手动启动。

[root@localhost ~]# service mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!

 (10)、设定远程登录mysql

mysql> use mysql;
Database changed
mysql> select host,user from user;
+-----------+---------------+
| host | user |
+-----------+---------------+
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+---------------+
rows in set (0.00 sec)
mysql> grant all privileges on *.* to root@'%' identified by '';
Query OK, rows affected, warning (0.00 sec)
mysql> flush privileges;
Query OK, rows affected (0.01 sec)
mysql> select host,user from user;
+-----------+---------------+
| host | user |
+-----------+---------------+
| % | root |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+---------------+
rows in set (0.00 sec)

最新文章

  1. 也说析构---C++
  2. window下安装pip工具,再利用pip安装工具来安装其他的python包
  3. atitit.TokenService v3 qb1  token服务模块的设计 新特性.docx
  4. java对redis的基本操作
  5. Android实现支持缩放平移图片
  6. android通过httpClient请求获取JSON数据并且解析
  7. C#获取“所有用户桌面”的路径
  8. [LeetCode]题解(python):146-LRU Cache
  9. System timers granularity
  10. putty 中使用git
  11. psy & vr
  12. UIScrollView 和 UIPageControl
  13. javascript 面向对象设计之 Function 普通类
  14. java安全入门篇之接口验签
  15. 第九周LINUX 学习笔记
  16. linux查看与修改交换内存配置(解决zabbix-agent启动报错)
  17. Vue 给对象添加属性
  18. 十大经典排序算法+sort排序
  19. git push 报错:you are not allowed to upload merges
  20. C#自定义控件的创建

热门文章

  1. poj 3653(最短路)
  2. php 对字符串的分块处理
  3. CommonJS和AMD/CMD
  4. 两个input在一行让它们能对齐
  5. POJ 2773 Happy 2006(容斥原理+二分)
  6. root Permission denied
  7. 第09章—使用Lombok插件
  8. XML 解析之 dom4j 解析器
  9. vue事件修饰器
  10. django中的setting全局变量的导入