mysql二进制格式_二进制格式安装 MySQL

二进制格式安装 MySQL

什么是通用二进制格式?

已经编译进行过编译的软件包, 下载到本机直接解压到特定的目录下就可以使用的格式.

1. 查询本地是否安装 mysql 数据库相关的软件包 (卸载之)rpm-qa"mysql*"(centos6)

rpm-qa"mariaDB*"(cetos7)

2.mariadb.org 下载源码二进制包带有 linux 字样的已经编译过的包:

mariadb-10.2.12-linux-x86_64.tar.gz(大小 440M 左右因为已经编译过)

3. 准备用户

getent passwd mysql 查询 passwd 是否有 mysql 用户

useradd -r mysql -s /sbin/nologin 创建 mysql 系统用户[root@centos7~13]#id mysql

uid=990(mysql)gid=305(mysql)groups=305(mysql)

生产环境建议置后一个版本至少.

4. 解压 mariadb-10.2.12-linux-x86_64.tar.gz

4-1. tar xvf mariadb-10.2.12-linux-x86_64.tar.gz -C /usr/local/

注意: 解压目录指定, 因为这是已经编译过的源码包所以路径很重要需要解压到 / usr/local / 下

4-2. 需要改名因为编译之前的目录叫 mysql;

建议创建软连接:

ln -s mariadb-10.2.12-linux-x86_64/ mysql

5. 修改文件权限默认没有属主属组:(可以不做修改)

chown -R mysql.mysql mysql/

6. 导出环境变量:echo PATH=/usr/local/mysql/bin:$PATH>/etc/profile.d/mysql.sh

cat/etc/profile.d/mysql.sh

./etc/profile.d/mysql.sh(重读配置文件)

7. 准备数据目录; 建议使用逻辑卷

7-1. 创建逻辑卷:

fdiak /dev/sda

7-2. 同步磁盘:

partprobe (6 使用 pertx)

7-3. 创建 PV 物理卷:

pvcreate /dev/sda6

7-4. 创建卷组:

vgcreate vg0-mysqldata /dev/sda6 -s 16M

7-5. 查看卷组:

vgdisplay

7-6. 创建 LVM

lvcreate -n lv_mysqldata -l 100%FREE vg0mysqldata

7-7. 创建逻辑卷的文件系统:

mkfs.xfs /dev/vg0mysqldata/lv_mysqldata

8. 创建挂载点并且挂载添加 / etc/fstab 条目 (请注意当前所在的工作目录. 我当前的路径是在 / usr/local/mysql/bin)mkdir-pv/data/mysqldb

echo UUID=98833275-08ee-446f-b888-3e03557deedf/data/mysqldb xfs defaults00>>/etc/fstab(建议别这么添加清空了这个文件就尴尬了)

mount -a 重读 / etc/fsatb

9. 这连个就是 mysql 的数据库目录了安全起见建议修改权限为 770

chmod 770 /data/mysqldb/

10. 初始化数据库:cd scripts/

scripts/mysql_install_db--datadir=/data/mysqldb--user=mysql

注意: 这个脚本一定要在它的上一级目录执行否则会报错

11. 由于默认的配置文件过于简陋而且数据库路径也不对, 可参考 / usr/local/mysql/support-files / 目录下以. cnf 结尾的模版配置文件.

11-1.cp my-huge.cnf /etc/my.cnf (覆盖目标文件)

修改如下:

12. 运行 / usr/local/mysql/mysql-server 服务脚本

cp mysql.server /etc/init.d/mysqld 复制并改名 mysqld

chkconfig --add mysqld 添加到系统脚本开机启动

13. 启动服务:

service mysqld start

源码安装结束

14. 查看是否有错误信息

15. 查看端口 3306

ss -tnl

16.mysql 安装完成默认没有密码需要运行一个安全脚本:./mysql_secure_installation(交互式设置密码及删除匿名用户)

[root@centos7/usr/local/mysql/bin178]#./mysql_secure_installation

NOTE:RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALLMariaDB

SERVERS IN PRODUCTION USE!PLEASE READ EACH STEP CAREFULLY!

Inorder to logintoMariaDBto secure it,well need the current

passwordforthe root user.Ifyouve just installedMariaDB,and

you haventsetthe root password yet,the password will be blank,

so you should just press enter here.

Enter current password for root (enter for none): 输入 root 旧口令 (没有直接回车)OK,successfully used password,moving on...

Settingthe root password ensures that nobody can logintotheMariaDB

root user without the proper authorisation.

Set root password? [Y/n] y 是否设置 root 口令

New password: 密码

Re-enter new password: 确认密码Passwordupdated successfully!

Reloadingprivilege tables..

...Success!

Bydefault,aMariaDBinstallation has an anonymous user,allowing anyone

to logintoMariaDBwithout having to have a user account createdfor

them.Thisisintended onlyfortesting,andto make the installation

go a bit smoother.Youshouldremovethem before movingintoa

production environment.

Remove anonymous users? [Y/n] y 删除匿名用户...Success!

Normally,root should only be allowed to connectfromlocalhost.This

ensures that someone cannot guess at the root passwordfromthe network.

Disallow root login remotely? [Y/n] n 是否禁用 root 远程等...skipping.

Bydefault,MariaDBcomeswitha database named test that anyone can

access.Thisisalso intended onlyfortesting,andshould be removed

before movingintoa production environment.

Remove test database and access to it? [Y/n] y 是否删除 test 测试数据库 (随机附带的测试数据库)-Droppingtest database...

...Success!

-Removingprivileges on test database...

...Success!

Reloadingthe privilege tables willensurethat all changes made so far

will take effect immediately.

Reload privilege tables now? [Y/n] y 是否重新加载并且生效...Success!

Cleaningup...

Alldone!Ifyouve completed all of the above steps,yourMariaDB

installation should now be secure.

ThanksforusingMariaDB!

启动服务:

service mysqld start

本地安装 mysql 的 Mysql-client 命令行测试连接

来源: http://www.bubuko.com/infodetail-2530696.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值