Linux安装MySQL8.0.12之二进制安装
2018年07月29日 01:21:31 vkingnew 阅读数:6050
版权声明:本文为博主原创文章,转载请注明出处 https://blog.csdn.net/vkingnew/article/details/81267223
运行环境:centos+mysql8.0.121.下载官方打包好的二进制安装包:#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.xz339M mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz2.解压文件:#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/mysql3.配置参数文件:# cat /etc/my.cnf[mysqld]server-id = 1port = 3306mysqlx_port = 33060mysqlx_socket = /tmp/mysqlx.sockdatadir = /data/mysqlsocket = /tmp/mysql.sockpid-file = /tmp/mysqld.pidlog-error = error.logslow-query-log = 1slow-query-log-file = slow.loglong_query_time = 0.2log-bin = bin.logrelay-log = relay.logbinlog_format =ROWrelay_log_recovery = 1character-set-client-handshake = FALSEcharacter-set-server = utf8mb4collation-server = utf8mb4_unicode_ciinit_connect ='SET NAMES utf8mb4'innodb_buffer_pool_size = 1Gjoin_buffer_size = 128Msort_buffer_size = 2Mread_rnd_buffer_size = 2Mlog_timestamps = SYSTEMlower_case_table_names = 1default-authentication-plugin =mysql_native_password4.创建目录授权等:# 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 password2018-07-29T02:06:41.253856+08:00 5 [Note] [MY-010454] [Server] A temporary password is generated for root[@localhost](https://my.oschina.net/u/570656): wquR3-Kxlg1d6.设置启动文件和环境变量:#cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql--启动数据库:# /etc/init.d/mysql startStarting MySQL.Logging to '/data/mysql/error.log'.SUCCESS!# vim /etc/profile.d/mysql.sh# cat /etc/profile.d/mysql.shexport PATH=$PATH:/usr/local/mysql/bin# source /etc/profile.d/mysql.sh# mysqld --versionmysqld 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.sockEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 7Server version: 8.0.12 MySQL Community Server - GPLCopyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.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@'%' identified by 'oracle';ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statementmysql> show variables like '%valid%pass%';ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.mysql> alter user root@'localhost' identified by 'oracle';Query OK, 0 rows affected (0.07 sec)mysql> show variables like '%valid%pass%';Empty set (0.01 sec)--创建可以远程登录的用户:mysql> create user root@'%' identified by 'oracle';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)总结:官方虽然提供RPM安装方式但是不少默认参数还是不太方便平常的使用,对生产而言则需要修改更多的地方,但是很适合初级用户快速安装使用;而对二进制安装包 只需要下载按照自定义的设置安装即可 方便快捷 可自主配置,适合生产布署。


