MySQL数据库的优势及安装方法

发布时间:2020-05-14 10:47:15 作者:三月
来源:亿速云 阅读:235

下面一起来了解下MySQL数据库的优势及安装方法,相信大家看完肯定会受益匪浅,文字在精不在多,希望MySQL数据库的优势及安装方法这篇短内容是你想要的。

数据库的基本概念

数据

数据库

数据库系统发展史

第一代数据库

第二代数据库

第三代数据库

当今主流数据库介绍

SQL Server (微软公司产品)

Oracle (甲骨文公司产品)

DB2 (IBM公司产品)

MySQL (甲骨文公司收购)

关系数据库

MySQL数据库的优势及安装方法

实体

属性

联系

所有实体及实体之间联系的集合构成一个关系数据库

关系数据库的存储结构是二维表格,反映事物及其联系的数据是以表格形式保存的

在每个二维表中, 每一行称为一条记录,用来描述一个对象的信息;每一列称为一个字段,用来描述对象的一个属性

关系数据库应用

关系型数据库

关系型数据库应用举例

非关系数据库介绍

非关系型数据库存储方式

非关系数据库产品

redis应用举例

MySQL数据库介绍

MySQL商业版与社区版

MySQL产品阵营

MySQL安装实例

[root@localhost ~]# yum install gcc gcc-c++ make ncurses ncurses-devel bison cmake -y    //安装环境包
已加载插件:fastestmirror, langpacks
base                                                               | 3.6 kB  00:00:00     
extras                                                             | 2.9 kB  00:00:00
...
已安装:
  bison.x86_64 0:3.0.4-2.el7                          cmake.x86_64 0:2.8.12.2-2.el7       
  gcc.x86_64 0:4.8.5-39.el7                           gcc-c++.x86_64 0:4.8.5-39.el7       
  ncurses-devel.x86_64 0:5.9-14.20130511.el7_4       

作为依赖被安装:
  cpp.x86_64 0:4.8.5-39.el7               glibc-devel.x86_64 0:2.17-292.el7              
  glibc-headers.x86_64 0:2.17-292.el7     kernel-headers.x86_64 0:3.10.0-1062.4.3.el7    
  libmpc.x86_64 0:1.0.1-3.el7             libstdc++-devel.x86_64 0:4.8.5-39.el7          
  m4.x86_64 0:1.4.16-10.el7              

更新完毕:
  make.x86_64 1:3.82-24.el7             ncurses.x86_64 0:5.9-14.20130511.el7_4            

作为依赖被升级:
  glibc.x86_64 0:2.17-292.el7                 glibc-common.x86_64 0:2.17-292.el7         
  libgcc.x86_64 0:4.8.5-39.el7                libgomp.x86_64 0:4.8.5-39.el7              
  libstdc++.x86_64 0:4.8.5-39.el7             ncurses-base.noarch 0:5.9-14.20130511.el7_4
  ncurses-libs.x86_64 0:5.9-14.20130511.el7_4

完毕!
[root@localhost ~]# useradd -s /sbin/nologin mysql     //创建MySQL程序型用户
[root@localhost ~]# mount.cifs //192.168.100.8/shares /mnt/       //将宿主机中MySQL压缩包路径挂载到Linux系统中
Password for root@//192.168.100.8/shares:  
[root@localhost ~]# cd /mnt/     //进入挂载点目录
[root@localhost mnt]# tar zxvf mysql-boost-5.7.20.tar.gz -C /opt      //解压MySQL压缩包到opt目录
......
mysql-5.7.20/boost/boost_1_59_0/boost/unordered/detail/extract_key.hpp
mysql-5.7.20/boost/boost_1_59_0/boost/unordered/detail/buckets.hpp
mysql-5.7.20/boost/boost_1_59_0/boost/unordered/detail/allocate.hpp
mysql-5.7.20/boost/boost_1_59_0/boost/unordered/detail/util.hpp
mysql-5.7.20/boost/boost_1_59_0/boost/unordered/unordered_map.hpp
mysql-5.7.20/boost/boost_1_59_0/boost/unordered/unordered_set.hpp
mysql-5.7.20/boost/boost_1_59_0/boost/unordered/unordered_set_fwd.hpp
mysql-5.7.20/boost/boost_1_59_0/boost/unordered/unordered_map_fwd.hpp
mysql-5.7.20/boost/boost_1_59_0/boost/timer.hpp
[root@localhost mnt]# cd /opt/mysql-5.7.20/
[root@localhost mysql-5.7.20]# cmake \        //配置mysql
> -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \        //指定安装路径
> -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \  //指定mysql.sock.路径
> -DSYSCONFDIR=/etc \                               //指定配置文件存放位置
> -DSYSTEMD_PID_DIR=/usr/local/mysql \             //指定pid文件存放为位置
> -DDEFAULT_CHARSET=utf8 \                         //字符集格式utf-8
> -DDEFAULT_COLLATION=utf8_general_ci \          
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \             //开启存储引擎
> -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
> -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
> -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
> -DMYSQL_DATADIR=/usr/local/mysql/data \      //指定数据存放位置
> -DWITH_BOOST=boost \                          //关联支持c++运行库
> -DWITH_SYSTEMD=1                            //开启systemd
....
-- CMAKE_C_LINK_FLAGS: 
-- CMAKE_CXX_LINK_FLAGS: 
-- CMAKE_C_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF
-- Configuring done
-- Generating done
-- Build files have been written to: /opt/mysql-5.7.20
[root@localhost mysql-5.7.20]# make                       //make过程(时间比较长,耐心等待)
....
[100%] Building CXX object libmysqld/examples/CMakeFiles/mysql_embedded.dir/__/__/client/readline.cc.o
Linking CXX executable mysql_embedded
[100%] Built target mysql_embedded
Scanning dependencies of target mysqltest_embedded
[100%] Building CXX object libmysqld/examples/CMakeFiles/mysqltest_embedded.dir/__/__/client/mysqltest.cc.o
Linking CXX executable mysqltest_embedded
[100%] Built target mysqltest_embedded
Scanning dependencies of target my_safe_process
[100%] Building CXX object mysql-test/lib/My/SafeProcess/CMakeFiles/my_safe_process.dir/safe_process.cc.o
Linking CXX executable my_safe_process
[100%] Built target my_safe_process
[root@localhost mysql-5.7.20]# make install     //安装
...
-- Installing: /usr/local/mysql/./COPYING-test
-- Installing: /usr/local/mysql/./README-test
-- Up-to-date: /usr/local/mysql/mysql-test/mtr
-- Up-to-date: /usr/local/mysql/mysql-test/mysql-test-run
-- Installing: /usr/local/mysql/mysql-test/lib/My/SafeProcess/my_safe_process
-- Up-to-date: /usr/local/mysql/mysql-test/lib/My/SafeProcess/my_safe_process
-- Installing: /usr/local/mysql/mysql-test/lib/My/SafeProcess/Base.pm
-- Installing: /usr/local/mysql/support-files/mysqld_multi.server
-- Installing: /usr/local/mysql/support-files/mysql-log-rotate
-- Installing: /usr/local/mysql/support-files/magic
-- Installing: /usr/local/mysql/share/aclocal/mysql.m4
-- Installing: /usr/local/mysql/support-files/mysql.server
[root@localhost mysql-5.7.20]# cd /usr/local/           //进入安装目录
[root@localhost local]# chown -R mysql.mysql mysql/     //mysql目录更改用户与组
[root@localhost local]# mv /etc/my.cnf /etc/my.cnf.bak     //更改配置文件名称
[root@localhost local]# vim /etc/my.cnf         //重新编辑配置文件
[client]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock

[mysql]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock

[mysqld]
user = mysql
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
character_set_server=utf8
pid-file = /usr/local/mysql/mysqld.pid
socket = /usr/local/mysql/mysql.sock
server-id = 1

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES
:wq
[root@localhost local]# vim /etc/profile
...
PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH     
export PATH                                //重新声明环境变量
:wq
[root@localhost local]# source /etc/profile      //重新执行
[root@localhost local]# cd /usr/local/mysql/bin          //进入MySQL命令目录
[root@localhost bin]# mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data                  //初始化数据库
2019-12-02T11:51:28.112082Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-12-02T11:51:28.263398Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-12-02T11:51:28.287408Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-12-02T11:51:28.341284Z 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: 131f32df-14fa-11ea-87e6-000c297265cb.
2019-12-02T11:51:28.342106Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-12-02T11:51:28.342452Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
[root@localhost ~]# cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service  /lib/systemd/system/ 
//将MySQL启动脚本夫复制到系统system目录下
[root@localhost ~]# systemctl enable mysqld.service      //设置MySQL为开机自启动
Created symlink from /etc/systemd/system/multi-user.target.wants/mysqld.service to /usr/lib/systemd/system/mysqld.service.
[root@localhost ~]# systemctl start mysqld.service          //启动MySQL
[root@localhost ~]# mysqladmin -u root -p password     //设置MySQL数据库密码
Enter password:                  //没有原始密码,直接回车
New password:                   //输入新密码
Confirm new password:           //再次输入密码
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.  
//安全提示
[root@localhost ~]# mysql -u root -p      //登录MySQL
Enter password:          输入密码
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.20 Source distribution

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> show databases;     //查看数据库
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+

4 rows in set (0.00 sec)

看完MySQL数据库的优势及安装方法这篇文章后,很多读者朋友肯定会想要了解更多的相关内容,如需获取更多的行业信息,可以关注我们的行业资讯栏目。

推荐阅读:
  1. nginx的安装方法
  2. 了解MySQL数据库特点和优势

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

mysql

上一篇:vim退出命令介绍

下一篇:c语言的特点是什么?

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》