(该实验我在centos8的机器上操作成功)
所谓的二进制安装就相当于windoes的绿色安装 ,和编译安装的区别还是大的,要让别人提供的路安装目录)
1.创建用户 [root12:17 PMcentos7 ~] groupadd -r -g 306 mysql [root12:25 PMcentos7 ~] useradd -r -g mysql -u 306 -d /data/mysql/ mysql 2.创建逻辑卷,将逻辑卷挂载,逻辑卷里面安装 mysql5.6 [root12:27 PMcentos7 ~]#pvcreate -ff /dev/sda3 [root12:29 PMcentos7 ~]#vgcreate vg0 /dev/sda3 [root12:29 PMcentos7 ~] lvcreate -n mysql -l 100%free vg0 [root12:31 PMcentos7 ~]#mkfs.ext4 /dev/vg0/mysql 3.挂载,设置开机就挂载 [root12:31 PMcentos7 ~]#vim /etc/fstab UUID=0b7d8060-c8ad-4958-9013-5eed0f8d3cae /data/mysql ext4 defaults 0 0 [root12:35 PMcentos7 ~]#mount -a 4.解压,创建软链接 [root12:43 PMcentos7 /usr/local]#tar xvf mysql-5.6.47-linux-glibc2.12-x86_64.tar.gz ln -s mysql-5.6.47-linux-glibc2.12-x86_64 mysql 5.修改软链接的属组属主 [root11:20 AMcentos8 /usr/local]#chown -R root.root mysql/ [root11:20 AMcentos8 /usr/local]#ll mysql/ total 236 drwxr-xr-x 2 root root 4096 May 12 11:15 bin drwxr-xr-x 3 root root 18 May 12 11:15 data drwxr-xr-x 2 root root 55 May 12 11:15 docs drwxr-xr-x 3 root root 4096 May 12 11:15 include drwxr-xr-x 3 root root 316 May 12 11:15 lib -rw-r--r-- 1 root root 218394 Nov 27 2019 LICENSE drwxr-xr-x 4 root root 30 May 12 11:15 man drwxr-xr-x 10 root root 291 May 12 11:15 mysql-test -rw-r--r-- 1 root root 587 Nov 27 2019 README drwxr-xr-x 2 root root 30 May 12 11:15 scripts drwxr-xr-x 28 root root 4096 May 12 11:15 share drwxr-xr-x 4 root root 4096 May 12 11:15 sql-bench drwxr-xr-x 2 root root 136 May 12 11:15 support-files 6.指定服务器的配置文件: [root11:50 AMcentos8 /usr/local/mysql/support-files]#vim /etc/my.cnf [mysqld] datadir=/data/mysql #创建数据库 7 ./scripts/mysql_install_db 该文件创建数据库 (和bin在同一级目录,要用相对路径) [root11:26 AMcentos8 /usr/local/mysql]#./scripts/mysql_install_db --datadir=/data/mysql/ --user=mysql #此时的数据库里面已经生成了文件 [root11:29 AMcentos8 /usr/local/mysql]#ll /data/mysql/ total 110604 -rw-rw---- 1 mysql mysql 12582912 May 12 11:27 ibdata1 -rw-rw---- 1 mysql mysql 50331648 May 12 11:27 ib_logfile0 -rw-rw---- 1 mysql mysql 50331648 May 12 11:27 ib_logfile1 drwx------ 2 mysql mysql 4096 May 12 11:27 mysql drwx------ 2 mysql mysql 4096 May 12 11:27 performance_schema drwx------ 2 mysql mysql 4096 May 12 11:27 test 8. 将启动脚本的文件复制到/etc/init.d目录下 [root11:30 AMcentos8 /usr/local/mysql/support-files]#cp mysql.server /etc/init.d/ #因为bin下面全部是执行客服端的脚本文件 因此将其添加到环境变量 [root11:36 AMcentos8 /usr/local/mysql/support-files]#ls /usr/local/mysql/bin/ innochecksum mysqlbug mysqldumpslow mysqltest_embedded msql2mysql mysqlcheck mysql_embedded mysql_tzinfo_to_sql myisamchk mysql_client_test mysql_find_rows mysql_upgrade myisam_ftdump mysql_client_test_embedded mysql_fix_extensions mysql_waitpid myisamlog mysql_config mysqlhotcopy mysql_zap myisampack mysql_config_editor mysqlimport perror my_print_defaults mysql_convert_table_format mysql_plugin replace mysql mysqld mysql_secure_installation resolveip mysqlaccess mysqld-debug mysql_setpermission resolve_stack_dump mysqlaccess.conf mysqld_multi mysqlshow mysqladmin mysqld_safe mysqlslap mysqlbinlog mysqldump mysqltest 9. 为了让客服端的命令容易使用,添加环境变量 [root11:39 AMcentos8]#echo 'PATH=/usr/local/mysql/bin:$PATH' >/etc/profile.d/mysql.sh [root11:39 AMcentos8 /usr/local/mysql/support-files]#. /etc/profile.d/mysql.sh #开启服务端 [root11:40 AMcentos8 /usr/local/mysql/support-files]#service mysql.server start Starting MySQL SUCCESS! #客服端连接服务器失败 [root11:40 AMcentos8 /usr/local/mysql/support-files]#mysql mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
# 安装依赖包 yum install libncurses* yum install libaio* -y #再次客服端连接服务器 mysql> #由于没有进入mysql数据库,所以用mysql.uesr mysql> select user,password,host from mysql.user; +------+----------+-----------+ | user | password | host | +------+----------+-----------+ | root | | localhost | | root | | centos8 | | root | | 127.0.0.1 | | root | | ::1 | | | | localhost | | | | centos8 | +------+----------+-----------+ 6 rows in set (0.00 sec) 10 安全加固 [root12:04 PMcentos8]#mysql_secure_installation 11 设置开启自动启动 [root12:15 PMcentos8 ~]#vim /etc/rc.d/rc.local touch /var/lock/subsys/local /etc/init.d/mysql.server start [root12:15 PMcentos8 ~]#chmod +x /etc/rc.d/rc.local