安装mysql数据库时的一顿操作

记录最近按照mysql的一顿操作。

安装包:mysql-8.0.18-linux-x86_64-minimal.tar
下载地址:
https://dev.mysql.com/downloads/mysql/
https://dev.mysql.com/downloads/file/?id=490304

详细步骤:
解压:
tar -xvf mysql-8.0.18-linux-x86_64-minimal.tar
解压出三个文件:
mysql-8.0.18-linux-x86_64-minimal.tar.xz
mysql-router-8.0.18-linux-x86_64-minimal.tar.xz
mysql-test-8.0.18-linux-x86_64-minimal.tar.xz
只使用:mysql-8.0.18-linux-x86_64-minimal.tar.xz
再解压:
xz -d mysql-8.0.18-linux-x86_64-minimal.tar.xz
tar -xvf mysql-8.0.18-linux-x86_64-minimal.tar
得到目录:mysql-8.0.18-linux-x86_64-minimal

移动目录:
mv mysql-8.0.18-linux-x86_64-minimal /usr/local/mysql

groupadd mysql 创建mysql组
useradd -r -g mysql mysql 在mysql组中创建mysql用户
touch /etc/my.cnf

vi /etc/my.cnf

[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/var/lib/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=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

[client]
default-character-set=utf8
socket=/tmp/mysql/mysql.sock

[mysql]
default-character-set=utf8
socket=/tmp/mysql/mysql.sock

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

cd /usr/local/
chown -R mysql:mysql mysql //指定目录的拥有者

cd mysql
./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data //指定数据目录,注意root@localhost后的密码
192.168.91.171 root@localhost: +cwceuxtg@5YG

./bin/mysql_ssl_rsa_setup --datadir=/usr/local/mysql/data

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

vi /etc/init.d/mysql
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data

mkdir /tmp/mysql
mkdir /var/log/mariadb
touch /var/log/mariadb/mariadb.log
chown -R mysql:mysql /var/log/mariadb //授予mysql用户组访问权限
chown -R mysql:mysql /tmp/mysql

service mysql start
mysql -uroot -p
输入密码

mysql> use mysql;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
需要修改密码:
alter user ‘root’@‘localhost’ identified by ‘+cwceuxtg@5YO’;

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
OK!!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

weixin_44764006

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值