mysql

1.安装MySQL

解压:

[root@13 ~]# tar -xvf mysql-8.0.33-linux-glibc2.12-x86_64.tar

mysql-test-8.0.33-linux-glibc2.12-x86_64.tar.xz

mysql-8.0.33-linux-glibc2.12-x86_64.tar.xz

mysql-router-8.0.33-linux-glibc2.12-x86_64.tar.xz

继续解压:

[root@13 ~]# tar -xf mysql-8.0.33-linux-glibc2.12-x86_64.tar.gz

2.进入解压后目录:

[root@13 ~]# cd mysql-8.0.33-linux-glibc2.12-x86_64/

[root@13 mysql-8.0.33-linux-glibc2.12-x86_64]#

[root@13 mysql-8.0.33-linux-glibc2.12-x86_64]# ls

bin docs include lib LICENSE man README share support-files

[root@13 mysql-8.0.33-linux-glibc2.12-x86_64]#

3.配置文件:

[root@13 mysql-8.0.33-linux-glibc2.12-x86_64]# vim support-files/mysql.server

4.移动文件

[root@13 ~]# cp -r mysql-8.0.33-linux-glibc2.12-x86_64/ /usr/local/mysql/

5.创建用户:
useradd -r -s /sbin/nologin mysql

6.创建目录:
[root@13 ~]# cd /usr/local/mysql
[root@13 mysql]# mkdir mysql-files

7.修改新创建的目录mysql-files权限:
[root@13 mysql]# chown mysql:mysql /usr/local/mysql/mysql-files/
[root@13 mysql]# chmod 750 /usr/local/mysql/mysql-files/

  1. 初始化数据库,找初始密码

[root@13 ~]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/

2024-08-05T02:02:50.656813Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: s_LdCqDX-3q/

9.安全加密:

[root@13 ~]# /usr/local/mysql/bin/mysql_ssl_rsa_setup --datadir=/usr/local/mysql/data

10.其他配置:

方便启动:

[root@13 ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql8

11.启服务:

[root@13 mysql]# service mysql8 start

Starting MySQL... SUCCESS!

12.创建用户:

create user '用户名'@'%' identified by '密码'

mysql> create user 'hh'@'%' identified by '1Mysql@1'

-> ;

Query OK, 0 rows affected (0.29 sec)

mysql> exit

Bye

13.登录hh用户,查看全部表:

[root@15 ~]# mysql -u hh -p

Enter password:1Mysql@1

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| performance_schema |

+--------------------+

2 rows in set (0.03 sec)

mysql> exit

Bye

14.退出hh用户,进入root给hh用户添加权限:

[root@15 ~]# mysql -u root -p

mysql> grant all on *.* to "hh";

Query OK, 0 rows affected (0.06 sec)

mysql> exit

15.进入hh用户,查看全部表:

[root@15 ~]# mysql -u hh -p

Enter password: 1Mysql@1

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

| sys |

| test |

+--------------------+

5 rows in set (0.01 sec)

mysql>

相关推荐
是程序喵呀8 小时前
MySQL备份
android·mysql·adb
暗碳15 小时前
adb无线连接手机后scrcpy连接报错ERROR: Could not find any ADB device
adb·智能手机
咸芝麻鱼1 天前
Android Studio | 连接手机设备后,启动App时出现:Waiting For DebuggerApplication (App名)...
android·adb·智能手机·android studio
Future_yzx2 天前
Mybatis中使用MySql触发器报错:You have an error in your SQL syntax; ‘DELIMITER $$
adb
牵牛老人3 天前
Qt调用adb对嵌入式设备的配置文件进行修改,写入多行内容
数据库·qt·adb
LuckyTHP4 天前
蓝叠模拟器adb连接并配置网络代理
网络·adb
Epiphanywh4 天前
Ubuntu 20.04 卸载和安装 MySQL8.0
linux·ubuntu·adb
木子欢儿5 天前
Windows Server 2019 配置PHP环境(图文教程)
开发语言·windows·adb·php
会飞的爱迪生5 天前
mysql优化
android·mysql·adb
云计算老王6 天前
MySQL 数据类型
android·mysql·adb