系统城装机大师 - 固镇县祥瑞电脑科技销售部宣传站!

当前位置:首页 > 数据库 > Mysql > 详细页面

MySQL8.0.19安装教程

时间:2020-01-27来源:电脑系统城作者:电脑系统城

官网下载安装包:mysql-8.0.19-linux-glibc2.12-x86_64.tar.xz

安装环境:CentOS Linux release 7.5.1804 (Core)

解压安装包:


 
  1. xz -d mysql-8.0.19-linux-glibc2.12-x86_64.tar.xz
  2. tar -xvf mysql-8.0.19-linux-glibc2.12-x86_64.tar

环境变量:


 
  1. yum install -y gcc gcc-c++ make cmake automake ncurses-devel bison bison-devel tcp_wrappers-devel libaio libaio-devel perl-Data-Dumper net-tools

创建相关用户和组:


 
  1. [root@localhost ~]# groupadd mysql
  2. [root@localhost ~]# useradd -g mysql -d /home/mysql -m -p mysql mysql

创建相关目录:


 
  1. [root@localhost ~]# mkdir -p /data/mysql/;chown -R mysql.mysql /data/mysql/
  2. [root@localhost ~]# mkdir -p /data/tmp/;chown -R mysql.mysql /data/tmp/

编辑配置文件:


 
  1. [root@localhost tmp]# vim /etc/my.cnf
  2. [root@localhost mysql]# cat /etc/my.cnf
  3. [client]
  4. port= 3306
  5. socket = /tmp/mysql.sock
  6. ## The MySQL server
  7. [mysqld]
  8. port = 3306
  9. socket = /tmp/mysql.sock
  10. user = mysql
  11. skip-external-locking
  12. skip-name-resolve
  13. #skip-grant-tables
  14. #skip-networking
  15. ###################################### dir
  16. basedir=/usr/local/mysql
  17. datadir=/data/mysql
  18. tmpdir=/data/tmp
  19. secure_file_priv=/data/tmp
  20. ###################################### some app
  21. log-error=mysql.err
  22. pid-file=/data/mysql/mysql.pid
  23. local-infile=1
  24. event_scheduler=0
  25. federated
  26. default-storage-engine=InnoDB
  27. #default-time-zone= '+8:00'
  28. log_timestamps=SYSTEM
  29. character-set-client-handshake = FALSE
  30. character-set-server = utf8mb4
  31. collation-server = utf8mb4_unicode_ci
  32. init_connect='SET NAMES utf8mb4'
  33. #fulltext
  34. innodb_optimize_fulltext_only
  35. ft_min_word_len=1
  36. #ft_max_word_len
  37. innodb_ft_min_token_size=1
  38. ###################################### memory allocate and myisam configure
  39. max_connections=3000
  40. max_connect_errors=10000
  41. key_buffer_size = 16M
  42. max_allowed_packet = 16M
  43. table_open_cache = 10240
  44. sort_buffer_size = 2M
  45. read_buffer_size = 2M
  46. read_rnd_buffer_size = 2M
  47. join_buffer_size=2M
  48. myisam_sort_buffer_size = 4M
  49. #net_buffer_length = 2M
  50. thread_cache_size = 24
  51. tmp_table_size=1G
  52. max_heap_table_size=1G
  53. #thread_concurrency =48
  54. ###################################### replication
  55. server-id = 101096
  56. log-bin=mysql-bin
  57. binlog_format=mixed
  58. max_binlog_size=1G
  59. log_slave_updates=true
  60. log_bin_trust_function_creators=true
  61. binlog_expire_logs_seconds=259200 #binlog过期时间,单位秒
  62. replicate-ignore-db=mysql
  63. replicate-ignore-db=test
  64. replicate-ignore-db=information_schema
  65. replicate-ignore-db=performance_schema
  66. replicate-wild-ignore-table=mysql.%
  67. replicate-wild-ignore-table=test.%
  68. replicate-wild-ignore-table=information_schema.%
  69. replicate-wild-ignore-table=performance_schema.%
  70. lower_case_table_names = 1
  71. #read_only=1
  72. master_info_repository=TABLE
  73. relay_log_info_repository=TABLE
  74. ###################################### slow-query
  75. long_query_time=1
  76. slow_query_log=1
  77. slow_query_log_file=/data/mysql/slow-query.log
  78. interactive_timeout=600
  79. wait_timeout=600
  80. ###################################### innodb configure
  81. innodb_file_per_table
  82. innodb_data_home_dir = /data/mysql
  83. innodb_log_group_home_dir = /data/mysql
  84. innodb_buffer_pool_size =4G
  85. innodb_log_file_size = 1G
  86. innodb_log_files_in_group = 3
  87. innodb_log_buffer_size = 32M
  88. innodb_flush_log_at_trx_commit = 1
  89. sync_binlog=0
  90. sql-mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO"
  91. ##########################################
  92. [mysqldump]
  93. quick
  94. max_allowed_packet = 16M
  95. [mysql]
  96. no-auto-rehash
  97. default-character-set = utf8mb4
  98. prompt=\\U \\h \\R:\\m:\\s \\d>
  99. [myisamchk]
  100. key_buffer_size = 20M
  101. sort_buffer_size = 20M
  102. read_buffer = 2M
  103. write_buffer = 2M
  104. [mysqlhotcopy]
  105. interactive-timeout

根目录:


 
  1. [root@localhost ~]# mv mysql-8.0.19-linux-glibc2.12-x86_64 /usr/local/mysql
  2. [root@localhost ~]# chown -R mysql.mysql /usr/local/mysql

进行初始化,默认密码为空:


 
  1. [root@localhost ~]# /usr/local/mysql/bin/mysqld --initialize-insecure --basedir=/usr/local/mysql --datadir=/data/mysql/ --user=mysql

查看日志有没有报错:


 
  1. [root@localhost ~]# cat /data/mysql/mysql.err
  2. 2020-01-20T15:11:46.156633+08:00 0 [System] [MY-013169] [Server]/usr/local/mysql/bin/mysqld (mysqld 8.0.19) initializing of server in progress as process 14822
  3. 100 200 300 400 500 600 700 800 900 1000
  4. 100 200 300 400 500 600 700 800 900 1000
  5. 100 200 300 400 500 600 700 800 900 1000
  6. 2020-01-20T15:12:31.118120+08:00 5 [Warning] [MY-010453] [Server] root@localhost iscreated with an empty password ! Please consider switching off the --initialize-insecure option.

环境变量与开机自启:


 
  1. [root@localhost mysql]# vim /etc/profile
  2. #在最后添加
  3. export MYSQL_HOME=/usr/local/mysql
  4. PATH=$PATH:$MYSQL_HOME/bin/
  5. [root@localhost mysql]# source /etc/profile
  6.  [root@localhost mysql]# cd /usr/local/mysql
  7.  [root@localhost mysql]# cp -f support-files/mysql.server /etc/init.d/mysqld
  8.  
  9.  [root@localhost mysql]# chmod 755 /etc/init.d/mysqld
  10.  
  11.  [root@localhost mysql]# chkconfig --add mysqld
  12.  
  13.  [root@localhost mysql]# chkconfig mysqld on

启动数据库:


 
  1. [root@localhost mysql]# /etc/init.d/mysqld start

修改密码与创建用户,8.0已取消grant权限自动创建用户,要用create user创建用户再用grant赋予权限:


 
  1. [root@localhost ~]# mysql -uroot -p
  2. Enter password:
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 8
  5. Server version: 8.0.19 MySQL Community Server - GPL
  6.  
  7. Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
  8.  
  9. Oracle is a registered trademark of Oracle Corporation and/or its
  10. affiliates. Other names may be trademarks of their respective
  11. owners.
  12.  
  13. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  14. root@localhost localhost 15:43:29 (none)>ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';
  15. Query OK, 0 rows affected (0.01 sec)
  16. root@localhost localhost 15:49:30 (none)>CREATE USER ceshi@'localhost' IDENTIFIED BY 'password';
  17. Query OK, 0 rows affected (0.01 sec)
  18.  
  19. root@localhost localhost 15:50:07 (none)>grant SELECT on *.* to 'ceshi'@'localhost';
  20. Query OK, 0 rows affected, 1 warning (0.00 sec)
  21.  
  22. root@localhost localhost 15:51:10 (none)>show grants for ceshi@localhost;
  23. +--------------------------------------------+
  24. | Grants for ceshi@localhost |
  25. +--------------------------------------------+
  26. | GRANT SELECT ON *.* TO `ceshi`@`localhost` |
  27. +--------------------------------------------+
  28. 1 row in set (0.00 sec)

ps:MySql8.0.19 安装采坑记录

1、ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

解决方式如下:


 
  1. mysql> ALTER USER USER() IDENTIFIED BY 'Xiaoming250';

2、修改root密码


 
  1. ALTER user 'root'@'localhost' IDENTIFIED BY '新密码';

总结

以上所述是小编给大家介绍的MySQL8.0.19安装教程,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对我们网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!

分享到:

相关信息

系统教程栏目

栏目热门教程

人气教程排行

站长推荐

热门系统下载