Linux下Mysql的安装步骤
(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)
Linux下Mysql的安装步骤的更多相关文章
- Window/Linux下Mysql的安装步骤
Windows下Mysql安装教程 首先讲一下Windows环境下安装Mysql,我使用的安装包版本是mysql-8.0.26-winx64 下载地址:MySQL下载 1.点击上面的下载地址得到zip ...
- .Neter玩转Linux系列之六:Linux下MySQL的安装、配置、使用
一.Linux安装MySQL (1)下载安装包:https://dev.mysql.com/downloads/mysql/ (2)解压并安装 命令:tar zxvf 文件名 解压完成之后,重名一下文 ...
- linux下mysql的安装
一.下载 http://dev.mysql.com/downloads/mysql/ 选择对应的版本,这里选择“Linux-Generic” 以64位系统为例,这里需要下载如下两个文件: MySQL- ...
- linux下Mysql 的安装、配置、数据导入导出
MySQL是一种开放源代码的关系型数据库管理系统(RDBMS),虽然功能未必很强大,但因它的免费开源而广受欢迎. 这次,接着上一篇<CentOs minimal安装和开发环境部署>,讲下L ...
- Linux中MySQL二进制安装步骤
MySQL二进制安装步骤 安装依赖环境 [root@node3 ~]# yum -y install libaio 将mysql-5.7.26-linux-glibc2.12-x86_64.tar.g ...
- linux 下mysql的安装,并设置必要的密码
首先,我使用的是redhat linux ,版本号为: [root@localhost init.d]# cat /proc/version Linux version - (bhcompile@po ...
- (0.2)linux下Mysql的安装配置与管理入门(目录篇)
本章学习内容: 1.基于Linux平台的Mysql项目场景介绍 1.1.互联网各类网站.购物网站.门户网站.博客系统.IDC,云平台,VPS,虚拟主机空间,论坛,嵌入式. 2.mysql数据库运行环境 ...
- 自学linux——13.Linux下mysql的安装
MySQL数据库 1.数据库联系 2.软件安装 (1)源码包安装 优点:开源,可以修改源代码编译安装,更加适合自己的系统,稳定高效 缺点:安装步骤较多,容易出错编译过程时间较长 常用语法: #tar ...
- Linux下mysql的安装和使用(C语言)
1 mysql的安装 我使用的ubuntu在线安装,非常简单,命令为: sudo apt-get install mysql-client mysql-server 2 mysql命令集合 网络太多了 ...
随机推荐
- EF提供的3中查询方式
1. Linq to Entities using (TestEntities te = new TestEntities()) { var user = from a in te.User wher ...
- GL 纹理 格式 资料备份
分别转载至:http://www.tuicool.com/articles/qAbYfq 和 http://www.verydemo.com/demo_c161_i114362.html 在手机 ...
- linux 环境 tomcat 莫名奇妙挂掉
::-exec-] org.apache.coyote.http11.Http11Processor.service Error processing request java.lang.NullPo ...
- Android去掉标题的方法
我们写程序的时候经常要全屏显示或者不显示标题.比如我们做地图导航的时候就不要标题了,下面介绍三种方法来实现Android去掉标题. 第一种:也一般入门的时候经常使用的一种方法 在setContentV ...
- spring定时器的cronexpression表达式
转自:https://www.cnblogs.com/yaowen/p/3779284.html 相关配置: import com.alibaba.dubbo.config.annotation.Se ...
- HYSBZ 2565 最长双回文串 (回文树)
2565: 最长双回文串 Time Limit: 10 Sec Memory Limit: 128 MB Submit: 1377 Solved: 714 [Submit][Status][Dis ...
- Connecting to Shares And Common Shares
Now that you have these shares, how do people use them? Assuming that you have a share called Apps o ...
- git "Could not read from remote repository.Please make&n
git "Could not read from remote repository.Please make sure you have the correct access rights. ...
- C++ 常见字符处理 收录
1.string字符串删除 字符串中 指定字符 std::string& HTTPRequestHandlerImpl::replace_all_distinct(std::string&am ...
- Json反序列化Map的key不能是Object
使用json作为数据传输格式,碰到一个问题.我希望传输的是一个Map<Target, TargetInfo>其中Target是一个对象,作为map的一个key public class T ...