MySQL8.0.19安装教程
官网下载安装包:mysql-8.0.19-linux-glibc2.12-x86_64.tar.xz
安装环境:CentOSLinuxrelease7.5.1804(Core)
解压安装包:
xz-dmysql-8.0.19-linux-glibc2.12-x86_64.tar.xz tar-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=3306 socket=/tmp/mysql.sock ##TheMySQLserver [mysqld] port=3306 socket=/tmp/mysql.sock user=mysql skip-external-locking skip-name-resolve #skip-grant-tables #skip-networking ######################################dir basedir=/usr/local/mysql datadir=/data/mysql tmpdir=/data/tmp secure_file_priv=/data/tmp ######################################someapp log-error=mysql.err pid-file=/data/mysql/mysql.pid local-infile=1 event_scheduler=0 federated default-storage-engine=InnoDB #default-time-zone='+8:00' log_timestamps=SYSTEM character-set-client-handshake=FALSE character-set-server=utf8mb4 collation-server=utf8mb4_unicode_ci init_connect='SETNAMESutf8mb4' #fulltext innodb_optimize_fulltext_only ft_min_word_len=1 #ft_max_word_len innodb_ft_min_token_size=1 ######################################memoryallocateandmyisamconfigure max_connections=3000 max_connect_errors=10000 key_buffer_size=16M max_allowed_packet=16M table_open_cache=10240 sort_buffer_size=2M read_buffer_size=2M read_rnd_buffer_size=2M join_buffer_size=2M myisam_sort_buffer_size=4M #net_buffer_length=2M thread_cache_size=24 tmp_table_size=1G max_heap_table_size=1G #thread_concurrency=48 ######################################replication server-id=101096 log-bin=mysql-bin binlog_format=mixed max_binlog_size=1G log_slave_updates=true log_bin_trust_function_creators=true binlog_expire_logs_seconds=259200#binlog过期时间,单位秒 replicate-ignore-db=mysql replicate-ignore-db=test replicate-ignore-db=information_schema replicate-ignore-db=performance_schema replicate-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=1 master_info_repository=TABLE relay_log_info_repository=TABLE ######################################slow-query long_query_time=1 slow_query_log=1 slow_query_log_file=/data/mysql/slow-query.log interactive_timeout=600 wait_timeout=600 ######################################innodbconfigure innodb_file_per_table innodb_data_home_dir=/data/mysql innodb_log_group_home_dir=/data/mysql innodb_buffer_pool_size=4G innodb_log_file_size=1G innodb_log_files_in_group=3 innodb_log_buffer_size=32M innodb_flush_log_at_trx_commit=1 sync_binlog=0 sql-mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO" ########################################## [mysqldump] quick max_allowed_packet=16M [mysql] no-auto-rehash default-character-set=utf8mb4 prompt=\\U\\h\\R:\\m:\\s\\d> [myisamchk] key_buffer_size=20M sort_buffer_size=20M read_buffer=2M write_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.err 2020-01-20T15:11:46.156633+08:000[System][MY-013169][Server]/usr/local/mysql/bin/mysqld(mysqld8.0.19)initializingofserverinprogressasprocess14822 1002003004005006007008009001000 1002003004005006007008009001000 1002003004005006007008009001000 2020-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/mysql PATH=$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权限自动创建用户,要用createuser创建用户再用grant赋予权限:
[root@localhost~]#mysql-uroot-p Enterpassword: WelcometotheMySQLmonitor.Commandsendwith;or\g. YourMySQLconnectionidis8 Serverversion:8.0.19MySQLCommunityServer-GPL Copyright(c)2000,2020,Oracleand/oritsaffiliates.Allrightsreserved. OracleisaregisteredtrademarkofOracleCorporationand/orits affiliates.Othernamesmaybetrademarksoftheirrespective owners. 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、ERROR1820(HY000):YoumustresetyourpasswordusingALTERUSERstatementbeforeexecutingthisstatement.
解决方式如下:
mysql>ALTERUSERUSER()IDENTIFIEDBY'Xiaoming250';
2、修改root密码
ALTERuser'root'@'localhost'IDENTIFIEDBY'新密码';
总结
以上所述是小编给大家介绍的MySQL8.0.19安装教程,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对毛票票网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:czq8825#qq.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。