一丶安装前的准备
- 检查是否已经安装或者安装过
mysql 以及mariadb
[root@root ~]
[root@root ~]
这里需要卸载删除mariadb ,注意:在删除的时候还需要删除他的依赖包postfix 命令:rpm -e mariadb-libs postfix
- MySQL依赖于
libaio 库,检查是否已经安装此库
[root@root ~]
- 查看系统位数
命令:uname -m ,看自己Linux是多少位,选择libaio,我这里是x86_64 - 选择合适版本的libaio库进行yum在线安装,我这里是安装
libaio.x86_64
[root@root mysql]
二丶使用wget 下载二进制发布包
-
选择合适版本下载,mysql官网下载地址 查看Linux系统glibc版本,命令:ldd --version -
复制下载链接使用wget 进行下载 命令:wget 刚才复制的链接地址
三丶解压、创建软连接、添加组
- 添加
user 以及group 添加组:groupadd mysql 添加用户:useradd -r -g mysql -s /bin/false mysql
[root@yaoyao db-mysql]
[root@yaoyao db-mysql]
[root@yaoyao db-mysql]
- 解压
tar xvf mysql-8.0.21-linux-glibc2.17-x86_64-minimal.tar.xz
[root@yaoyao db-mysql]
- 添加软连接
ln -s 刚才解压出的mysql文件夹所在目录 mysql
[root@yaoyao db-mysql]
total 46652
drwxr-xr-x 9 7161 31415 4096 Jun 17 2020 mysql-8.0.21-linux-glibc2.17-x86_64-minimal
-rw-r--r-- 1 root root 47765660 Jun 17 2020 mysql-8.0.21-linux-glibc2.17-x86_64-minimal.tar.xz
[root@yaoyao db-mysql]
/usr/local/ProgrammingSoftware/db-mysql
[root@yaoyao db-mysql]
[root@yaoyao db-mysql]
total 46656
lrwxrwxrwx 1 root root 83 Mar 7 21:28 mysql -> /usr/local/ProgrammingSoftware/db-mysql/mysql-8.0.21-linux-glibc2.17-x86_64-minimal
drwxr-xr-x 9 7161 31415 4096 Jun 17 2020 mysql-8.0.21-linux-glibc2.17-x86_64-minimal
-rw-r--r-- 1 root root 47765660 Jun 17 2020 mysql-8.0.21-linux-glibc2.17-x86_64-minimal.tar.xz
[root@yaoyao db-mysql]
四丶创建文件夹,修改权限,初始化安装
-
进入软链接目录 cd mysql -
创建mysql-files 目录 mkdir mysql-files -
赋予mysql-files 文件夹用户和组为mysql chown mysql:mysql mysql-files -
修改mysql-files 文件夹的操作权限 chmod 750 mysql-files -
初始化mysql数据库,这里要注意初始化的临时密码,记录后面登录用 bin/mysqld --initialize --user=mysql -
初始化指定数据存放目录data bin/mysql_ssl_rsa_setup --datadir=data文件夹的实际目录/
[root@yaoyao mysql]
-
启动mysql服务 bin/mysqld_safe --user=mysql & -
查看mysql进程 ps -ef | grep mysql -
密码登录mysql bin/mysql -uroot -p'临时密码' -
修改密码 alter user root@localhost identified by '自定义密码'; -
在etc/profile 文件中设置环境变量 export PATH=$PATH:mysql的bin目录
export PATH=$PATH:/usr/local/ProgrammingSoftware/db-mysql/mysql-8.0.21-linux-glibc2.17-x86_64-minimal/bin/
至此安装完成!!!!!!!!!!!!!!!!!!!!!
五丶纯代码操作总结
[root@yaoyao ~]
[root@yaoyao local]
[root@yaoyao local]
[root@yaoyao ProgrammingSoftware]
[root@yaoyao db-mysql]
[root@yaoyao db-mysql]
[root@yaoyao db-mysql]
[root@yaoyao db-mysql]
[root@yaoyao db-mysql]
[root@yaoyao db-mysql]
[root@yaoyao db-mysql]
[root@yaoyao db-mysql]
[root@yaoyao db-mysql]
[root@yaoyao mysql]
[root@yaoyao mysql]
[root@yaoyao mysql]
[root@yaoyao mysql]
"这里请复制初始化的临时密码"
[root@yaoyao mysql]
[root@yaoyao mysql]
[root@yaoyao mysql]
[root@yaoyao mysql]
mysql> alter user root@localhost identified by 'root';
mysql> quit
Bye
[root@yaoyao mysql]
export PATH=$PATH:/usr/local/ProgrammingSoftware/db-mysql/mysql-8.0.21-linux-glibc2.17-x86_64-minimal/bin/
:wq
[root@yaoyao mysql]
[root@yaoyao ~]
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.21 MySQL Community Server - GPL
Copyright (c) 2000, 2020, 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>
"安装完成,此教程完全参考于官网,网上找了一大堆二进制发布版的mysql安装方式,emmm,不是这个错误就是那个错误。只有走官网才能完美安装"
"本帖子完全取自官网,其中自测安装自定义目录,各位大侠可以放心参考,除非官网也错了!!"
最后附上官网参考链接: 官网mysql8.0参考链接
|