安装MySql
mysql-cluster-8.0.24-linux-glibc2.12-x86_64.tar.gz
1,将mysql文件放在/usr/local/
2,解压
[root@localhost local]
3,将解压后的文件改名为mysql
[root@localhost local]
4,在mysql文件加下创建data
[root@localhost mysql]
5,进入/usr/local目录下,创建用户和用户组并授权
[root@Mysql-server local]
/usr/local
[root@Mysql-server local]
[root@Mysql-server local]
[root@Mysql-server local]
6,安装libaio,
[root@localhost mysql]
[root@localhost mysql]
7,初始化数据库
[root@Mysql-server mysql]
8,初始话完成之后会随机生成密码
2021-06-09T03:24:40.794365Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: rrDNP4=g;H>g
9,修改/usr/local/mysql当前目录的用户
[root@Mysql-server mysql]
[root@Mysql-server mysql]
10,创建my.cnf
[root@Mysql-server mysql]
[root@Mysql-server support-files]
[root@Mysql-server support-files]
[root@Mysql-server support-files]
总用量 20
-rwxrwxrwx. 1 root root 0 6月 9 11:38 my-default.cnf
-rwxr-xr-x. 1 root root 1061 3月 26 12:24 mysqld_multi.server
-rw-r--r--. 1 root root 2027 3月 26 13:07 mysql-log-rotate
-rwxr-xr-x. 1 root root 10576 3月 26 13:07 mysql.server
[root@Mysql-server support-files]
cp: 无法获取"support-files/my-default.cnf" 的文件状态(stat): 没有那个文件或目录
[root@Mysql-server support-files]
cp:是否覆盖"/etc/my.cnf"? yes
11,配置my.cnf
[root@Mysql-server support-files]
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
init-connect='SET NAMES utf8'
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
max_connections=200
character-set-server=utf8
default-storage-engine=INNODB
12,开机自启,进入/usr/local/mysql/support-files进行设置
[root@Mysql-server support-files]
[root@Mysql-server support-files]
13,注册服务
[root@Mysql-server support-files]
[root@Mysql-server support-files]
注:该输出结果只显示 SysV 服务,并不包含
原生 systemd 服务。SysV 配置数据
可能被原生 systemd 配置覆盖。
要列出 systemd 服务,请执行 'systemctl list-unit-files'。
查看在具体 target 启用的服务请执行
'systemctl list-dependencies [target]'。
mysql 0:关 1:关 2:开 3:开 4:开 5:开 6:关
14,etc/ld.so.conf要配置路径,不然报错
[root@Mysql-server support-files]
文件添加内容
/usr/local/mysql/lib
15,配置环境变量
[root@Mysql-server support-files]
文件最后添加内容
export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib
16,更新环境变量
[root@Mysql-server support-files]
17,启动MySQL服务
[root@Mysql-server ~]
Starting MySQL SUCCESS!
18,登录mysql
[root@Mysql-server ~]
Enter password:
19,修改密码
mysql> alter user 'root'@'localhost' identified by 'sin-8023';
Query OK, 0 rows affected (0.02 sec)
20,开启远程访问
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> select host, user, authentication_string, plugin from user;
4 rows in set (0.00 sec)
mysql> CREATE USER 'root'@'%' IDENTIFIED BY 'root';
Query OK, 0 rows affected (3.51 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
Query OK, 0 rows affected (0.24 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.34 sec)
21,重启服务器
[root@Mysql-server ~]
Shutting down MySQL..... SUCCESS!
Starting MySQL.......... SUCCESS!
22,防火墙开放3306端口
[root@Mysql-server ~]
success
[root@Mysql-server ~]
[root@Mysql-server ~]
3306/tcp