linux-mysql8.0安装

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档


一、下载mysql 8.0 安装包

cd /usr/local/src
wget https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.11-linux-glibc2.12-x86_64.tar

二、安装数据库

1.解压

cd /usr/local/src
tar xvf mysql-8.0.11-linux-glibc2.12-x86_64.tar
#/usr/local/mysql
mv /usr/local/src/mysql-8.0.11-linux-glibc2.12-x86_64 /usr/local/mysql
[root@ecs-3921 mysql]# pwd
/usr/local/mysql
[root@ecs-3921 mysql]# ls
bin  docs  include  lib  LICENSE  man  README  share  support-files
[root@ecs-3921 mysql]# 

2.创建用户及用户组

[root@ecs-3921 mysql]# groupadd mysql
[root@ecs-3921 mysql]# useradd -g mysql mysql
[root@ecs-3921 mysql]# 

3.初始化

[root@ecs-3921 bin]# mkdir -p /usr/local/mysql/data
[root@ecs-3921 bin]# ./mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
2020-12-25T10:27:06.784472Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2020-12-25T10:27:06.784625Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.11) initializing of server in progress as process 18905
2020-12-25T10:27:09.638202Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Ufgnhh5e3I)%
2020-12-25T10:27:11.215502Z 0 [System] [MY-013170] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.11) initializing of server has completed
Ufgnhh5e3I)% 为数据库密码,记得保存

问题一:./mysqld: error while loading shared libraries: libaio.so.1:cannot open shared object file: No such file or directory
解决:yum install -y libaio

4.启动

  • 设置启动命令
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
export PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --list mysqld //查看是否添加成功
  • 编辑/etc/my.cnf
[mysqld]
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
#symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
log-error=/usr/local/mysql/log/mysql.log
pid-file=/usr/local/mysql/mariadb.pid
#
# include all files from the config directory
#
#!includedir /etc/my.cnf.d
  • 设置权限
chown -R mysql:mysql /usr/local/mysql //权限
chmod -R 777 /usr/local/mysql //权限
chmod 777 /etc/my.cnf
  • 启动命令
service mysql start
  • 修改root密码
mysql -uroot -p
ALTER user 'root'@'localhost' IDENTIFIED BY '你的密码';

设置远程访问

#登录数据库
use mysql;
update user set host = "%" where user='root';
FLUSH PRIVILEGES;

问题总结

问题一:
Starting MySQL.2020-12-25T10:37:54.786524Z mysqld_safe error:log-error set to ‘/usr/local/mysql/log/mysql.log’, however file don’t…ser ‘mysql’
解决:
chown -R mysql:mysql /usr/local/mysql
chmod -R 777 /usr/local/mysql
chmod 777 /etc/my.cnf #这个一定执行

问题二
./mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
yum install -y libaio*
sudo ln -s /usr/lib64/libtinfo.so.6.1 /usr/lib64/libtinfo.so.5

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值