设为首页 收藏本站
查看: 490|回复: 0

[经验分享] mysql8安装记录

[复制链接]

尚未签到

发表于 2018-10-2 11:43:36 | 显示全部楼层 |阅读模式
  运行环境:centos6.6+mysql8.0.12
1.下载官方打包好的二进制安装包:
  #wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz
  可以看到这个版本采用了tar.xz的打包压缩方式,文件只有350M左右,下载还是满方便的。
  du -sh mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz
  339M    mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz
2.解压文件:
  #tar -xJvf mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz -C /usr/local/
  mv /usr/local/mysql-8.0.12-linux-glibc2.12-x86_64/ /usr/local/mysql
3.配置参数文件:
  cat /etc/my.cnf
  [mysqld]
  server-id                      = 1
  port                           = 3306
  mysqlx_port                    = 33060
  mysqlx_socket                  = /tmp/mysqlx.sock
  datadir                        = /data/mysql
  socket                         = /tmp/mysql.sock
  pid-file                       = /tmp/mysqld.pid
  log-error                      = error.log
  slow-query-log                 = 1
  slow-query-log-file            = slow.log
  long_query_time                = 0.2
  log-bin                        = bin.log

  relay-log                      =>  binlog_format                 =ROW
  relay_log_recovery            = 1
  character-set-client-handshake = FALSE
  character-set-server           = utf8mb4
  collation-server               = utf8mb4_unicode_ci
  init_connect                   ='SET NAMES utf8mb4'
  innodb_buffer_pool_size        = 1G
  join_buffer_size               = 128M
  sort_buffer_size               = 2M
  read_rnd_buffer_size           = 2M
  log_timestamps                 = SYSTEM
  lower_case_table_names         = 1
  default-authentication-plugin  =mysql_native_password
4.创建目录授权等:
  groupadd mysql
  useradd mysql
  mkdir -p /data/mysql
  chown -R mysql:mysql /data/mysql/
  chmod -R 775 /data/mysql/
5.初始化数据库:
  #/usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql --initialize-insecure
  官方推荐使用--initialize,会在错误日志中生成难以输入的临时密码,我这里使用的免密码的方式。
  cat /data/mysql/error.log | grep -i password
  2018-07-29T02:06:41.253856+08:00 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: wquR3-Kxlg1d
6.设置启动文件和环境变量:
  #cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysql
--启动数据库:
  /etc/init.d/mysql start
  Starting MySQL.Logging to '/data/mysql/error.log'.
  SUCCESS!
  vim /etc/profile.d/mysql.sh
  cat /etc/profile.d/mysql.sh
  export PATH=$PATH:/usr/local/mysql/bin
  source /etc/profile.d/mysql.sh
  mysqld --version
  mysqld  Ver 8.0.12 for linux-glibc2.12 on x86_64 (MySQL Community Server - GPL)
  [root@node4 mysql]# /usr/local/mysql/bin/mysql -p -S /tmp/mysql.sock
  Enter password:
  Welcome to the MySQL monitor.  Commands end with ; or \g.

  Your MySQL connection>  Server version: 8.0.12 MySQL Community Server - GPL
  Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  Oracle is a registered trademark of Oracle Corporation and/or its
  affiliates. Other names may be trademarks of their respective
  owners.
  Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  mysql> select version();
  +-----------+
  | version() |
  +-----------+
  | 8.0.12    |
  +-----------+
  1 row in set (0.00 sec)
7.设置可以远程登录的账号:
  mysql> show variables like '%valid%pass%';
  Empty set (0.00 sec)

  mysql> create user root@'%'>  ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
  mysql> show variables like '%valid%pass%';

  ERROR 1820 (HY000): You must reset your password using>
  mysql>>  Query OK, 0 rows affected (0.07 sec)
  mysql> show variables like '%valid%pass%';
  Empty set (0.01 sec)
--创建可以远程登录的用户:

  mysql> create user root@'%'>  Query OK, 0 rows affected (0.06 sec)
  mysql> grant all privileges on . to root@'%' with grant option;
  Query OK, 0 rows affected (0.07 sec)
  mysql> flush privileges;
  Query OK, 0 rows affected (0.00 sec)
记录
  解压
  用量 930616
  -rw-r--r--. 1 root root  50345454 6月   5 18:44 grafana-4.5.2-1.x86_64.rpm
  -rw-r--r--. 1 root root  17067970 6月   5 18:41 influxdb-1.2.0.x86_64.rpm
  -rw-r--r--. 1 root root 185646832 8月  24 22:57 jdk-8u181-linux-x64.tar.gz
  -rw-r--r--. 1 root root 344964868 8月   1 19:44 mysql-8.0.12-linux-glibc2.12-i686.tar.xz
  -rw-r--r--. 1 root root 354913940 8月  25 10:01 mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz
  [root@localhost home]#
  [root@localhost home]# tar -xJvf mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz -C /usr/local/
  复制到
  root@localhost home]# mv /usr/local/mysql-8.0.12-linux-glibc2.12-x86_64/ /usr/local/mysql
  [root@localhost home]#
  配置文件:
  [root@localhost mysql]#
  [root@localhost mysql]#
  [root@localhost mysql]# cd /etc/
  [root@localhost etc]# mv my.cnf my.cnf.bak
  [root@localhost etc]# vim my.cnf
  [mysqld]
  server-id                      = 1
  port                           = 3306
  mysqlx_port                    = 33060
  mysqlx_socket                  = /tmp/mysqlx.sock
  datadir                        = /data/mysql
  socket                         = /tmp/mysql.sock
  pid-file                       = /tmp/mysqld.pid
  log-error                      = error.log
  slow-query-log                 = 1
  slow-query-log-file            = slow.log
  long_query_time                = 0.2
  log-bin                        = bin.log

  relay-log                      =>  binlog_format                 =ROW
  relay_log_recovery            = 1
  character-set-client-handshake = FALSE
  character-set-server           = utf8mb4
  collation-server               = utf8mb4_unicode_ci
  init_connect                   ='SET NAMES utf8mb4'
  innodb_buffer_pool_size        = 1G
  join_buffer_size               = 128M
  sort_buffer_size               = 2M
  read_rnd_buffer_size           = 2M
  log_timestamps                 = SYSTEM
  lower_case_table_names         = 1
  default-authentication-plugin  =mysql_native_password
  ~
  "my.cnf" [新] 27L, 1083C 已写入
  [root@localhost etc]#
  [root@localhost etc]#
  [root@localhost etc]#
  [root@localhost etc]#
  [root@localhost etc]# mkdir -p /data/mysql
  [root@localhost etc]# chown -R mysql:mysql /data/mysql/
  [root@localhost etc]# chmod -R 775 /data/mysql/
  [root@localhost etc]#
  /usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql --initialize-insecure
  [root@localhost etc]# cat /data/mysql/error.log | grep -i password
  2018-08-25T21:10:11.470522+08:00 5 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
  ~
  "profile.d/mysql.sh" [新] 2L, 69C 已写入
  [root@localhost etc]#
  [root@localhost etc]# source /etc/profile.d/mysql.sh
  [root@localhost etc]#
  [root@localhost etc]# mysqld --version
  mysqld  Ver 8.0.12 for linux-glibc2.12 on x86_64 (MySQL Community Server - GPL)
  [root@localhost etc]# /usr/local/mysql/bin/mysql -p -S /tmp/mysql.sock
  Enter password:
  Welcome to the MySQL monitor.  Commands end with ; or \g.

  Your MySQL connection>  Server version: 8.0.12 MySQL Community Server - GPL
  Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  Oracle is a registered trademark of Oracle Corporation and/or its
  affiliates. Other names may be trademarks of their respective
  owners.
  Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  mysql> select version();
  +-----------+
  | version() |
  +-----------+
  | 8.0.12    |
  +-----------+
  1 row in set (0.00 sec)
  mysql> show variables like '%valid%pass%';
  Empty set (0.02 sec)
  mysql> show variables like '%valid%pass%';
  Empty set (0.02 sec)

  mysql> create user root@'%'>  Query OK, 0 rows affected (0.10 sec)

  mysql>>  Query OK, 0 rows affected (0.05 sec)
  mysql> show variables like '%valid%pass%';
  Empty set (0.01 sec)

  mysql> create user root@'%'>  ERROR 1396 (HY000): Operation CREATE USER failed for 'root'@'%'
  mysql> grant all privileges on . to root@'%' with grant option;
  Query OK, 0 rows affected (0.08 sec)
  mysql> flush privileges;
  Query OK, 0 rows affected (0.00 sec)
  mysql>


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-607521-1-1.html 上篇帖子: mysql权限机制2-yong 下篇帖子: mysql配置主从时报错及处理
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

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