首页 > 数据库 >Kylin-最小化编译安装MySQL

Kylin-最小化编译安装MySQL

时间:2022-12-16 11:11:46浏览次数:40  
标签:Kylin local MySQL usr mysql 最小化 root localhost

Kylin-最小化编译安装MySQL

编译环境部署

  • 安装编译软件
[root@server2 local]# dnf install gcc gcc-c++ ncurses ncurses-devel cmake bison perl make tar -y
Installed:
  bison-3.6.4-1.ky10.x86_64                    cmake-3.16.5-4.p01.ky10.x86_64                             cmake-data-3.16.5-4.p01.ky10.noarch            cmake-filesystem-3.16.5-4.p01.ky10.x86_64
  cmake-help-3.16.5-4.p01.ky10.noarch          cmake-rpm-macros-3.16.5-4.p01.ky10.noarch                  emacs-filesystem-1:27.1-4.ky10.noarch          gcc-c++-7.3.0-20190804.35.p02.ky10.x86_64
  jsoncpp-1.9.3-2.ky10.x86_64                  libstdc++-devel-7.3.0-20190804.35.p02.ky10.x86_64          ncurses-devel-6.2-1.ky10.x86_64                rhash-1.4.0-1.ky10.x86_64
  tar-2:1.32-1.ky10.x86_64
Complete!
  • 下载解压源码包
[root@server2 ~]# cd /usr/local
[root@server2 local]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.16.tar.gz
[root@server2 local]# wget http://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz
[root@server2 local]# tar xzvf mysql-5.7.16.tar.gz
[root@server2 local]# tar xzvf boost_1_59_0.tar.gz
  • 创建管理用户和软件放置目录
[root@server2 local]# useradd mysql -M -s /sbin/nologin
[root@server2 local]# id mysql
uid=1000(mysql) gid=1000(mysql) groups=1000(mysql
[root@localhost ~]# mkdir -p /usr/local/mysql/var
[root@localhost ~]# chown mysql:mysql -R /usr/local/mysql/
[root@localhost ~]# ll /usr/local
total 0
drwxr-xr-x 2 root  root   6 Mar  6  2021 bin
drwxr-xr-x 2 root  root   6 Mar  6  2021 etc
drwxr-xr-x 2 root  root   6 Mar  6  2021 games
drwxr-xr-x 2 root  root   6 Mar  6  2021 include
drwxr-xr-x 2 root  root   6 Mar  6  2021 lib
drwxr-xr-x 3 root  root  17 Dec 15 07:41 lib64
drwxr-xr-x 2 root  root   6 Mar  6  2021 libexec
drwxr-xr-x 3 mysql mysql 17 Dec 16 10:28 mysql
drwxr-xr-x 2 root  root   6 Mar  6  2021 sbin
drwxr-xr-x 5 root  root  49 Dec 15 07:41 share
drwxr-xr-x 2 root  root   6 Mar  6  2021 src
[root@localhost ~]#

编译安装MySQL

  • 编译安装MySQL
[root@server2 mysql]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/var -DSYSCONFDIR=/etc -DWITH_BOOST=/usr/local/boost_1_59_0
[root@localhost mysql-5.7.16]# make && make install
[  0%] Building C object zlib/CMakeFiles/zlib.dir/adler32.c.o
[  0%] Building C object zlib/CMakeFiles/zlib.dir/compress.c.o
[  0%] Building C object zlib/CMakeFiles/zlib.dir/crc32.c.o
  • 初始化MySQL指定文件存放目录
[root@localhost mysql-5.7.16]# cd /usr/local/mysql
[root@localhost mysql]# bin/mysql_install_db --user mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var
  • 添加MySQL配置文件
[root@localhost mysql]# rm -rf /etc/my.cnf
[root@localhost mysql]# cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
[root@localhost mysql]# cat /etc/my.cnf
# 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]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[root@localhost mysql]#
  • 将MySQL添加进入启动项
[root@localhost mysql]# cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@localhost mysql]# chmod a+x /etc/rc.d/init.d/mysqld
[root@localhost mysql]# chkconfig --add mysqld
[root@localhost mysql]# chkconfig mysqld on
  • 将MySQL命令添加进入环境变量
[root@localhost mysql]# echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
[root@localhost mysql]# source /etc/profile
[root@localhost mysql]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin:/root/bin:/usr/local/mysql/bin
[root@localhost mysql]# systemctl restart mysqld
  • MySQL安全加固
[root@localhost mysql]# mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL server using password in '/root/.mysql_secret'

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
验证密码插件可以用来测试密码
并提高安全性。它检查密码的强度
并允许用户只设置那些
足够安全。您要设置验证密码插件吗?

Press y|Y for Yes, any other key for No: y
按y|Y表示是,按任何其他键表示否:Y

There are three levels of password validation policy:
密码验证策略有三个级别:

LOW    Length >= 8
长度下限> = 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
中等长度> = 8,数字,混合大小写和特殊字符
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file
强长度> = 8,数字,混合大小写,特殊字符和字典

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Using existing password for root.
使用根用户的现有密码。
Estimated strength of the password: 100
密码的估计强度:100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y
更改root用户的密码?((按y|Y表示是,按任何其他键表示否):Y
New password: TEXT123haha

Re-enter new password: TEXT123haha

Estimated strength of the password: 100
密码的估计强度:100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : yes
您希望使用提供的密码继续吗?(按y|Y表示是,按任何其他键表示否) :是
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
默认情况下,MySQL安装有一个匿名用户,
允许任何人登录MySQL,而不需要
为他们创建的用户帐户。这仅用于
测试,并使安装进行顺利一点。
您应该在进入生产之前删除它们
环境。

Remove anonymous users? (Press y|Y for Yes, any other key for No) : yes
删除匿名用户?(按y|Y表示是,按任何其他键表示否) :
Success.

Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
通常,应该只允许root用户从
“本地主机”。这确保了某人不能猜测
来自网络的root密码。

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : yes
不允许远程root登录?(按y|Y表示是,按任何其他键表示否) :
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
默认情况下,MySQL附带一个名为“test”的数据库
任何人都可以访问。这也只是为了测试,
并且应该在进入生产之前移除
环境。

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : yes
 - Dropping test database...
是否删除测试数据库并访问它?(按y|Y表示是,按任何其他键表示否) :是
 - 删除测试数据库...
Success.

 - Removing privileges on test database...
 - 删除测试数据库的权限...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
重新加载权限表将确保所有更改
到目前为止所做的将立即生效。

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : yse
现在重新加载权限表吗?(按y|Y表示是,按任何其他键表示否):yse
Success.

All done!

项目验证

[root@localhost mysql]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.16

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> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'MMS12ge**hao';
Query OK, 0 rows affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql>

标签:Kylin,local,MySQL,usr,mysql,最小化,root,localhost
From: https://www.cnblogs.com/wm-plengong/p/16986756.html

相关文章

  • MySQL系列之什么是CROSS JOIN
    文章目录​​1.crossjoin简介​​​​2.crossjoin用法​​本博客例子自两篇博客的:​​http://www.mysqltutorial.org/mysql-cross-join/​​​​https://www.w3resourc......
  • mysql
    MySQL管理工具......
  • 5:数据类型-MySQL
    (目录)5.1数据库的数据类型问题企业中的数据类型定义没有统一的标准,每一个公司会根据自己的产品需要和需求来定制属于自己的数据类型5.2int数值类型在企业中要使用到......
  • MySQL技术内幕—第一章 体系结构和存储引擎
    MySQL被设计为一个单进程多线程架构的数据库,数据库实例在系统上的表现就是一个进程。当启动实例时,MySQL数据库会去读取配置文件,根据配置文件的参数来启动数据库实例。而......
  • 基于Java+Swing+mysql图书管理系统
    @目录一、系统介绍二、功能展示1.用户登陆2.系统主页3.图书查询4.图书添加5.图书修改6.图书删除7.办理借书8.办理还书9.历史查询10.用户查询、删除(管理员)三、数据库四、其......
  • 基于Java+Swing+mysql图书管理系统 (1)
    @目录一、系统介绍二、功能展示1.用户登陆2.图书管理3.图书添加4.图书类别管理5.图书类别添加三、数据库四、其它1.其他系统实现五、获取源码一、系统介绍程序中实现了登......
  • Java+Swing+mysql员工工资管理系统
    @目录一、系统介绍二、功能展示1.主页2.员工工资查询3.员工工资添加4.员工工资修改5.员工工资删除三、系统实现1.salary.java四、其它1.其他系统实现五、获取源码一、系统......
  • MySQL kill进程后出现killed
    一.问题描述拷贝一个大表的表数据的时候,等待时间太久,就在前台通过CTRL+C的方式停掉了   通过showprocesslist查找到对应的进程,然后进行kill,结果kill完了,依旧在进......
  • ssm报错Could not open JDBC Connection for transaction; nested exception is com.m
    HTTPStatus500-Requestprocessingfailed;nestedexceptionisorg.springframework.transaction.CannotCreateTransactionException:CouldnotopenJDBCConnecti......
  • mysql安装系统错误
    一.看到一篇博客解决二.替换掉增加文件2.1替换位置2.2分享链接链接:https://pan.baidu.com/s/1tig9d7-_HCMYcrIz2SYQpg?pwd=8zzp提取码:8zzp......