F10-MYSQL的yum&源码
2021/7/27 2:06:07
本文主要是介绍F10-MYSQL的yum&源码,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1、部署两台数据库服务器,一台yum部署(版本5.5),一台源码部署(5.7)
yum部署(版本5.5)
yum install –y mariadb mariadb-devel mariadb-server
源码部署(5.7)(5.7版本需要2G内存,40G以上的磁盘空间)
(1)找到软件包(5.7),并下载编译器(如果没有相关的编译器,就容易出错)
[root@v3 src]# yum install gcc c ncurses-devel libaio bison gcc-c++ git cmake ncurses-devel ncurses -y
tar xf boost_1_59_0.tar.gz
mv boost_1_59_0 /usr/local/boost
[root@v3 src]# mv mysql-5.7.28.tar.gz /usr/local
(2)解压
[root@v3 local]# tar xf mysql-5.7.28.tar.gz
[root@v3 local]# cd mysql-5.7.28
(3)预编译(这个地方配置不完整就会出错,5.5与5.7配置方法不一样)
下面指定的情况与老师的有所不同
最好就是能够统一到一行,不然复制粘贴就可能被认为\为目录,然后说不存在,同时下面的预编译一个参数都不要少
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql57 -DMYSQL_UNIX_ADDR=/usr/local/data/mysql57/mysql.sock -DMYSQL_DATADIR=/usr/local/data/mysql57 -DSYSCONFDIR=/usr/local/mysql57 -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 -DWITH_XTRADB_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DWITH_EXTRA_CHARSETS=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_BIG_TABLES=1 -DWITH_DEBUG=0 -DENABLE_DTRACE=0 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost
(4)编译和安装
[root@v3 mysql-5.7.28]# make
[root@v3 mysql-5.7.28]# make install
(5)开启数据库的地方/etc/init.d/mysqld
[root@v3 mysql-5.7.28]# cp support-files/mysql.server /etc/init.d/mysqld
[root@v3 mysql-5.7.28]# chmod +x /etc/init.d/mysqld
[root@v3 mysql-5.7.28]#vim /usr/local/mysql57/my.cnf
[mysqld]
basedir = /usr/local/mysql57/
datadir = /usr/local/data/mysql57/
port = 3306
pid-file = /usr/local/mysql57/mysql.pid
socket = /usr/local/mysql57/mysql.sock
bind-address=0.0.0.0
[mysqld_safe]
log-error = /usr/local/mysql57/log/mysql.log
(6)数据库初始化
[root@v3 mysql-5.7.28]# /usr/local/mysql57/bin/mysqld --initialize --user=mysql --datadir=/usr/local/data/mysql57 --basedir=/usr/local/mysql57
(7)添加变量(先删除rm -rf /etc/profile.d/mysql.sh,再写入变量)
[root@v3 mysql-5.7.28]# echo “export PATH=/usr/local/mysql57/bin:$PATH” > /etc/profile.d/mysql.sh
(8)立即生效
[root@v3 mysql-5.7.28]# . /etc/profile.d/mysql.sh
(9)跳过权限
[root@v3 mysql-5.7.28]# vim /usr/local/mysql57/my.cnf
在[mysqld]字段下添加:
skip-grant-tables
[mysqld]
basedir = /usr/local/mysql57/
datadir = /usr/local/data/mysql57/
port = 3306
pid-file = /usr/local/mysql57/mysql.pid
socket = /usr/local/mysql57/mysql.sock
skip-grant-tables
[mysqld_safe]
log-error = /usr/local/mysql57/log/mysql.log
(10)启动数据库
[root@v3 mysql57]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS!
(11)修改数据库密码
mysqladmin -u root password xxxxx
(12)免密登录数据库
[root@v3 bin]# /usr/local/mysql57/bin/mysql
[root@v3 mysql57]# mysql -u root -p (这种模式是不用密码登录的,直接回车)
(13)登录后修改密码,以后就不用密码了
mysql> update mysql.user set authentication_string=password(’’) where user=‘mysql’;
Query OK, 0 rows affected (0.01 sec)
Rows matched: 0 Changed: 0 Warnings: 0
(14)退出mysql,关闭MySQL服务,去掉/usr/local/mysql57/my.cnf中的skip-grant-tables,重启即可密码
mysql> exit
Bye
[root@v3 ~]# /etc/init.d/mysqld stop
Shutting down MySQL… SUCCESS!
[root@v3 ~]# vim /usr/local/mysql57/my.cnf
[mysqld]
basedir = /usr/local/mysql57/
datadir = /usr/local/data/mysql57/
port = 3306
pid-file = /usr/local/mysql57/mysql.pid
socket = /usr/local/mysql57/mysql.sock
[mysqld_safe]
log-error = /usr/local/mysql57/log/mysql.log
[root@v3 ~]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS!
[root@v3 ~]# /usr/local/mysql57/bin/mysql -u root -p
Enter password:
(15)关闭MySQL服务,在/usr/local/mysql57/my.cnf中的[mysqld]下添加bind-address=0.0.0.0
重启Mysql服务,输入/usr/local/mysql57/bin/mysql直接进入,免密
[root@v3 ~]# /etc/init.d/mysqld stop
Shutting down MySQL. SUCCESS!
[root@v3 ~]# !vim
vim /usr/local/mysql57/my.cnf
[mysqld]
basedir = /usr/local/mysql57/
datadir = /usr/local/data/mysql57/
port = 3306
pid-file = /usr/local/mysql57/mysql.pid
socket = /usr/local/mysql57/mysql.sock
bind-address=0.0.0.0
[mysqld_safe]
log-error = /usr/local/mysql57/log/mysql.log
[root@v3 ~]# /etc/init.d/mysqld restart
Shutting down MySQL. SUCCESS!
Starting MySQL. SUCCESS!
[root@v3 ~]# /usr/local/mysql57/bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.28 Source distribution
Copyright © 2000, 2019, 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>
(16)查看日志
[root@node5 log]# cat /usr/local/mysql57/log/mysql.log
查看mysql的安装路径(这个反映的是编译完成后的绝对路径)
[root@node5 log]# ps -ef|grep mysql
root 77796 1659 0 Dec26 pts/0 00:00:00 /bin/sh /usr/local/mysql57/bin/mysqld_safe
mysql 77946 77796 0 Dec26 pts/0 00:00:00 [mysqld]
root 83774 1 0 Dec26 pts/1 00:00:00 /bin/sh /usr/local/mysql57//bin/mysqld_safe
–datadir=/usr/local/data/mysql57/
–pid-file=/usr/local/mysql57/mysql.pid
mysql 83953 83774 0 Dec26 pts/1 00:00:00 /usr/local/mysql57/bin/mysqld --basedir=/usr/local/mysql57/
–datadir=/usr/local/data/mysql57
–plugin-dir=/usr/local/mysql57//lib/plugin
–user=mysql
–log-error=/usr/local/mysql57/log/mysql.log --pid-file=/usr/local/mysql57mysql.pid
–socket=/usr/local/mysql57/mysql.sock
–port=3306
root 84514 81909 0 00:03 pts/1 00:00:00 grep --color=auto mysql
查看配置文件的内容
[root@node5 ~]# cat /usr/local/mysql57/my.cnf
[mysqld]
basedir = /usr/local/mysql57/
datadir = /usr/local/data/mysql57/
port = 3306
pid-file = /usr/local/mysql57/mysql.pid
socket = /usr/local/mysql57/mysql.sock
bind-address=0.0.0.0
[mysqld_safe]
log-error = /usr/local/mysql57/log/mysql.log
配置文件的内容要与安装路径一致
服务的进程
/etc/init.d/mysqld
这篇关于F10-MYSQL的yum&源码的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-16MySQL资料:新手入门教程
- 2024-11-16MySQL资料:新手入门教程
- 2024-11-15MySQL教程:初学者必备的MySQL数据库入门指南
- 2024-11-15MySQL教程:初学者必看的MySQL入门指南
- 2024-11-04部署MySQL集群项目实战:新手入门教程
- 2024-11-04如何部署MySQL集群资料:新手入门指南
- 2024-11-02MySQL集群项目实战:新手入门指南
- 2024-11-02初学者指南:部署MySQL集群资料
- 2024-11-01部署MySQL集群教程:新手入门指南
- 2024-11-01如何部署MySQL集群:新手入门教程