重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 886|回复: 0
打印 上一主题 下一主题

[安装] Linux下安装mysql8.0

[复制链接]
跳转到指定楼层
楼主
发表于 2022-10-24 09:15:21 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
上传mysql软件包
sftp> cd /setup
sftp> lcd D:\
sftp> put my
MyDrivers/           mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz
sftp> putmysql-8.0.11-linux-glibc2.12-x86_64.tar.gz
Uploadingmysql-8.0.11-linux-glibc2.12-x86_64.tar.gz to /setup/mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz
100% 588886KB  36805KB/s00:00:16     
D:/mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz:603019898 bytes transferred in 16 seconds (36805 KB/s)
解压mysql安装包
[root@sztech setup]# tar xzfmysql-8.0.11-linux-glibc2.12-x86_64.tar.gz
重命名文件夹
[root@sztech setup]# ll
total 588888
drwxr-xr-x. 9 root root       129 Oct 20 14:29mysql-8.0.11-linux-glibc2.12-x86_64
-rw-r--r--. 1 root root 603019898 Sep  3  2020mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz
[root@sztech setup]#
[root@sztech setup]# mvmysql-8.0.11-linux-glibc2.12-x86_64 /usr/local/mysql
[root@sztech mysql]# pwd
/usr/local/mysql
[root@sztech mysql]# ll
total 308
drwxr-xr-x. 2 root root    4096 Oct 20 14:29bin
drwxr-xr-x. 2 root root      55 Oct 20 14:29docs
drwxr-xr-x. 3 root root     266 Oct 20 14:29include
drwxr-xr-x. 5 root root     272 Oct 20 14:29lib
-rw-r--r--. 1 7161 31415 301518 Apr  8  2018 LICENSE
drwxr-xr-x. 4 root root      30 Oct 20 14:29man
-rw-r--r--. 1 7161 31415    687 Apr  8  2018README
drwxr-xr-x. 28 root root    4096 Oct 20 14:29 share
drwxr-xr-x. 2 root root      90 Oct 20 14:29support-files
创建DATA存储文件
[root@sztech mysql]# mkdir data
[root@sztech mysql]# pwd
/usr/local/mysql
创建用户授权权限
[root@sztech mysql]# groupadd mysql
[root@sztech mysql]# useradd -g mysql mysql
[root@sztech mysql]# chown -R mysql.mysql/usr/local/mysql/
切换到/usr/local/mysql/bin目录下
[root@sztech bin]# cd/usr/local/mysql/mysql/bin
[root@sztech bin]# pwd
/usr/local/mysql/mysql/bin
初始化基础信息
./mysqld --user=mysql --basedir=/usr/local/mysql--datadir=/usr/local/mysql/data/ –lower-case-table-names=1–initialize
–lower-case-table-names=1表示表名不区分大小写
  
[root@sztech  bin]# ./mysqld --user=mysql --basedir=/usr/local/mysql  --datadir=/usr/local/mysql/data/ --initialize
  
2022-10-20T06:39:31.261426Z  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.
  
2022-10-20T06:39:31.261582Z  0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.11)  initializing of server in progress as process 3931
  
2022-10-20T06:39:33.665682Z  5 [Note] [MY-010454] [Server] A temporary password is generated for  root@localhost: jahqe<a+e0pR
  
2022-10-20T06:39:34.881715Z  0 [System] [MY-013170] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.11)  initializing of server has completed
  
[root@sztech  bin]#
  
编辑my.cnf文件
[root@sztech ~]# cat /etc/my.cnf
#[mysqld]
#datadir=/var/lib/mysql
#socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommendedto prevent assorted security risks
#symbolic-links=0
# Settings user and group are ignored whensystemd is used.
# If you need to run mysqld under adifferent user or group,
# customize your systemd unit file formariadb according to the
#[mysqld_safe]
#log-error=/var/log/mariadb/mariadb.log
#pid-file=/var/run/mariadb/mariadb.pid
#
# include all files from the configdirectory
#
!includedir /etc/my.cnf.d
[mysqld]
    basedir = /usr/local/mysql   
    datadir = /usr/local/mysql/data
    socket = /usr/local/mysql/mysql.sock
    character-set-server=utf8
    port = 3306
  sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[client]
   socket = /usr/local/mysql/mysql.sock
   default-character-set=utf8
[root@sztech ~]#
添加mysqld服务到系统
[root@sztech mysql]# cp -a./support-files/mysql.server /etc/init.d/mysql
[root@sztech mysql]# chmod +x/etc/init.d/mysql
[root@sztech mysql]# chkconfig --add mysql
[root@sztech mysql]# pwd
/usr/local/mysql
检查服务是否生效
[root@sztech mysql]# chkconfig --list mysql
Note: This output shows SysV services onlyand does not include native
     systemd services. SysV configuration data might be overridden by native
     systemd configuration.
     If you want to list systemd services use 'systemctl list-unit-files'.
     To see services enabled on particular target use
     'systemctl list-dependencies [target]'.
mysql           0:off   1:off  2:on    3:on    4:on   5:on    6:off
[root@sztech mysql]#
配置全局环境变量
编辑 / etc/profile 文件
# vi /etc/profile
profile 文件底部添加如下两行配置,保存后退出
exportPATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib
export PATH
设置环境变量立即生效
[root@sztech ~]# source /etc/profile
启动mysql
[root@sztech ~]#service mysql start
StartingMySQL.Logging to '/usr/local/mysql/data/sztech.err'.
. SUCCESS!
[root@sztech ~]#
[root@sztech ~]#ps -ef | grep mysql
root       4203     1  0 14:50 pts/2    00:00:00 /bin/sh/usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data--pid-file=/usr/local/mysql/data/sztech.pid
mysql      4369  4203  2 14:50 pts/2    00:00:01 /usr/local/mysql/bin/mysqld--basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin--user=mysql --log-error=sztech.err --pid-file=/usr/local/mysql/data/sztech.pid--socket=/usr/local/mysql/mysql.sock --port=3306
root       4422  3991  0 14:51 pts/2    00:00:00 grep --color=auto mysql
登录mysql
[root@sztech ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.11
Copyright (c) 2000, 2018, Oracle and/or itsaffiliates. All rights reserved.
Oracle is a registered trademark of OracleCorporation and/or its
affiliates. Other names may be trademarksof their respective
owners.
Type 'help;' or '\h' for help. Type '\c' toclear the current input statement.
mysql>
修改root密码
mysql> alter user 'root'@'localhost'identified by 'Wangjia';
Query OK, 0 rows affected (0.05 sec)
设置可以远程登录
mysql> use mysql
Reading table information for completion oftable and column names
You can turn off this feature to get aquicker startup with -A
Database changed
mysql> select database();
+------------+
| database() |
+------------+
| mysql     |
+------------+
1 row in set (0.00 sec)
mysql> update user set host='%' whereuser='root' limit 1;
Query OK, 1 row affected (0.05 sec)
Rows matched: 1  Changed: 1 Warnings: 0
刷新权限
mysql> flush privileges;
Query OK, 0 rows affected (0.01sec)
mysql> select distinct concat('user: ''',user,'''@''',host,''';') as query frommysql.user;
+---------------------------------------+
| query                                 |
+---------------------------------------+
| user: 'root'@'%';                     |
| user: 'mysql.infoschema'@'localhost'; |
| user: 'mysql.session'@'localhost';    |
| user: 'mysql.sys'@'localhost';        |
+---------------------------------------+
4 rows in set (0.00 sec)
查看所有数据库数据库
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)
mysql> select database();
+--------------------+
| database()         |
+--------------------+
| information_schema |
+--------------------+
1 row in set (0.00 sec)

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2024-4-25 19:12 , Processed in 0.081257 second(s), 20 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表