这篇文章主要为大家展示了“MySQL8.0.19安装的示例分析”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“MySQL8.0.19安装的示例分析”这篇文章吧。

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

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

解压安装包:

xz-dmysql-8.0.19-linux-glibc2.12-x86_64.tar.xztar-xvfmysql-8.0.19-linux-glibc2.12-x86_64.tar

环境变量:

yuminstall-ygccgcc-c++makecmakeautomakencurses-develbisonbison-develtcp_wrappers-devellibaiolibaio-develperl-Data-Dumpernet-tools

创建相关用户和组:

[root@localhost~]#groupaddmysql[root@localhost~]#useradd-gmysql-d/home/mysql-m-pmysqlmysql

创建相关目录:

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

编辑配置文件:

[root@localhosttmp]#vim/etc/my.cnf[root@localhostmysql]#cat/etc/my.cnf[client]port=3306socket=/tmp/mysql.sock##TheMySQLserver[mysqld]port=3306socket=/tmp/mysql.sockuser=mysqlskip-external-lockingskip-name-resolve#skip-grant-tables#skip-networking######################################dirbasedir=/usr/local/mysqldatadir=/data/mysqltmpdir=/data/tmpsecure_file_priv=/data/tmp######################################someapplog-error=mysql.errpid-file=/data/mysql/mysql.pidlocal-infile=1event_scheduler=0federateddefault-storage-engine=InnoDB#default-time-zone='+8:00'log_timestamps=SYSTEMcharacter-set-client-handshake=FALSEcharacter-set-server=utf8mb4collation-server=utf8mb4_unicode_ciinit_connect='SETNAMESutf8mb4'#fulltextinnodb_optimize_fulltext_onlyft_min_word_len=1#ft_max_word_leninnodb_ft_min_token_size=1######################################memoryallocateandmyisamconfiguremax_connections=3000max_connect_errors=10000key_buffer_size=16Mmax_allowed_packet=16Mtable_open_cache=10240sort_buffer_size=2Mread_buffer_size=2Mread_rnd_buffer_size=2Mjoin_buffer_size=2Mmyisam_sort_buffer_size=4M#net_buffer_length=2Mthread_cache_size=24tmp_table_size=1Gmax_heap_table_size=1G#thread_concurrency=48######################################replicationserver-id=101096log-bin=mysql-binbinlog_format=mixedmax_binlog_size=1Glog_slave_updates=truelog_bin_trust_function_creators=truebinlog_expire_logs_seconds=259200#binlog过期时间,单位秒replicate-ignore-db=mysqlreplicate-ignore-db=testreplicate-ignore-db=information_schemareplicate-ignore-db=performance_schemareplicate-wild-ignore-table=mysql.%replicate-wild-ignore-table=test.%replicate-wild-ignore-table=information_schema.%replicate-wild-ignore-table=performance_schema.%lower_case_table_names=1#read_only=1master_info_repository=TABLErelay_log_info_repository=TABLE######################################slow-querylong_query_time=1slow_query_log=1slow_query_log_file=/data/mysql/slow-query.loginteractive_timeout=600wait_timeout=600######################################innodbconfigureinnodb_file_per_tableinnodb_data_home_dir=/data/mysqlinnodb_log_group_home_dir=/data/mysqlinnodb_buffer_pool_size=4Ginnodb_log_file_size=1Ginnodb_log_files_in_group=3innodb_log_buffer_size=32Minnodb_flush_log_at_trx_commit=1sync_binlog=0sql-mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO"##########################################[mysqldump]quickmax_allowed_packet=16M[mysql]no-auto-rehashdefault-character-set=utf8mb4prompt=\\U\\h\\R:\\m:\\s\\d>[myisamchk]key_buffer_size=20Msort_buffer_size=20Mread_buffer=2Mwrite_buffer=2M[mysqlhotcopy]interactive-timeout

根目录:

[root@localhost~]#mvmysql-8.0.19-linux-glibc2.12-x86_64/usr/local/mysql[root@localhost~]#chown-Rmysql.mysql/usr/local/mysql

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

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

查看日志有没有报错:

[root@localhost~]#cat/data/mysql/mysql.err2020-01-20T15:11:46.156633+08:000[System][MY-013169][Server]/usr/local/mysql/bin/mysqld(mysqld8.0.19)initializingofserverinprogressasprocess148221002003004005006007008009001000100200300400500600700800900100010020030040050060070080090010002020-01-20T15:12:31.118120+08:005[Warning][MY-010453][Server]root@localhostiscreatedwithanemptypassword!Pleaseconsiderswitchingoffthe--initialize-insecureoption.

环境变量与开机自启:

[root@localhostmysql]#vim/etc/profile#在最后添加exportMYSQL_HOME=/usr/local/mysqlPATH=$PATH:$MYSQL_HOME/bin/[root@localhostmysql]#source/etc/profile [root@localhostmysql]#cd/usr/local/mysql [root@localhostmysql]#cp-fsupport-files/mysql.server/etc/init.d/mysqld [root@localhostmysql]#chmod755/etc/init.d/mysqld [root@localhostmysql]#chkconfig--addmysqld [root@localhostmysql]#chkconfigmysqldon

启动数据库:

[root@localhostmysql]#/etc/init.d/mysqldstart

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

[root@localhost~]#mysql-uroot-pEnterpassword:WelcometotheMySQLmonitor.Commandsendwith;or\g.YourMySQLconnectionidis8Serverversion:8.0.19MySQLCommunityServer-GPLCopyright(c)2000,2020,Oracleand/oritsaffiliates.Allrightsreserved.OracleisaregisteredtrademarkofOracleCorporationand/oritsaffiliates.Othernamesmaybetrademarksoftheirrespectiveowners.Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement.root@localhostlocalhost15:43:29(none)>ALTERUSER'root'@'localhost'IDENTIFIEDBY'password';QueryOK,0rowsaffected(0.01sec)root@localhostlocalhost15:49:30(none)>CREATEUSERceshi@'localhost'IDENTIFIEDBY'password';QueryOK,0rowsaffected(0.01sec)root@localhostlocalhost15:50:07(none)>grantSELECTon*.*to'ceshi'@'localhost';QueryOK,0rowsaffected,1warning(0.00sec)root@localhostlocalhost15:51:10(none)>showgrantsforceshi@localhost;+--------------------------------------------+|Grantsforceshi@localhost|+--------------------------------------------+|GRANTSELECTON*.*TO`ceshi`@`localhost`|+--------------------------------------------+1rowinset(0.00sec)

ps:MySql8.0.19 安装采坑记录

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

解决方式如下:

mysql>ALTERUSERUSER()IDENTIFIEDBY'Xiaoming250';

2、修改root密码

ALTERuser'root'@'localhost'IDENTIFIEDBY'新密码';

以上是“MySQL8.0.19安装的示例分析”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!