首页 > 系统 > CentOS > 正文

Linux CentOS MySQL 5.7.18 5.7.X安装教程

2020-10-28 18:46:11
字体:
来源:转载
供稿:网友

废话不多说了,直接给大家贴代码了,具体代码如下所示:

#安装依赖包yum search libaio # search for infoyum install libaio # install library#新建用户组合用户groupadd mysqluseradd mysql -g mysql#解压到data下面tar -zxvf /data/software/mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz -C /data#重命名mv mysql-5.7.18-linux-glibc2.5-x86_64/ mysql#安装cd mysql/mkdir data更改所有者cd ../chown -R mysql:mysql mysql/#授权755chmod -R 755 mysql/cd mysql./bin/mysqld --user=mysql --basedir=/data/mysql --datadir=/data/mysql/data --initialize#注意最下面的密码2017-04-21T02:36:14.351072Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2017-04-21T02:36:15.174993Z 0 [Warning] InnoDB: New log files created, LSN=457902017-04-21T02:36:15.331692Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.2017-04-21T02:36:15.608132Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 4ab0413b-263b-11e7-9795-8e59748c97ed.2017-04-21T02:36:15.615879Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.2017-04-21T02:36:15.620346Z 1 [Note] A temporary password is generated for root@localhost: o*s#gqh)F4Ck#先简单测试一下

执行 ./support-files/mysql.server start

如果提示下面错误

./support-files/mysql.server: line 239: my_print_defaults: command not found./support-files/mysql.server: line 259: cd: /usr/local/mysql: No such file or directoryStarting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)

那就正常了,哈哈

1.cp support-files/mysql.server  /etc/init.d/mysqld

2.chmod 755 /etc/init.d/mysqld

3.vi /etc/init.d/mysqld

将66-73行/usr/local/修改为/data/

修改前

then basedir=/usr/local/mysql bindir=/usr/local/mysql/bin if test -z "$datadir" then  datadir=/usr/local/mysql/data fi sbindir=/usr/local/mysql/bin libexecdir=/usr/local/mysql/binelse

修改后,根据你的实际目录修改

then basedir=/data/mysql bindir=/data/mysql/bin if test -z "$datadir" then  datadir=/data/mysql/data fi sbindir=/data/mysql/bin libexecdir=/data/mysql/binelse

service mysqld start

如果提示Starting MySQL.Logging to '/data/mysql/data/MyServer.err'.

不管它就行,以后重启就不会提示了

接下来来配置my.cnf

先清理一下内存

syncecho 3 > /proc/sys/vm/drop_caches下面是my.cnf的具体配置[client]no-beepsocket =/data/mysql/mysql.sock# pipe# socket=0.0port=3306[mysql]default-character-set=utf8[mysqld]basedir=/data/mysqldatadir=/data/mysql/dataport=3306pid-file=/data/mysql/mysqld.pid#skip-grant-tablesskip-name-resolvesocket = /data/mysql/mysql.sockcharacter-set-server=utf8default-storage-engine=INNODBexplicit_defaults_for_timestamp = true# Server Id.server-id=1max_connections=2000query_cache_size=0table_open_cache=2000tmp_table_size=246Mthread_cache_size=300#限定用于每个数据库线程的栈大小。默认设置足以满足大多数应用thread_stack = 192kkey_buffer_size=512Mread_buffer_size=4Mread_rnd_buffer_size=32Minnodb_data_home_dir = /data/mysql/datainnodb_flush_log_at_trx_commit=0innodb_log_buffer_size=16Minnodb_buffer_pool_size=256Minnodb_log_file_size=128Minnodb_thread_concurrency=128innodb_autoextend_increment=1000innodb_buffer_pool_instances=8innodb_concurrency_tickets=5000innodb_old_blocks_time=1000innodb_open_files=300innodb_stats_on_metadata=0innodb_file_per_table=1innodb_checksum_algorithm=0back_log=80flush_time=0join_buffer_size=128Mmax_allowed_packet=1024Mmax_connect_errors=2000open_files_limit=4161query_cache_type=0sort_buffer_size=32Mtable_definition_cache=1400binlog_row_event_max_size=8Ksync_master_info=10000sync_relay_log=10000sync_relay_log_info=10000#批量插入数据缓存大小,可以有效提高插入效率,默认为8Mbulk_insert_buffer_size = 64Minteractive_timeout = 120wait_timeout = 120log-bin-trust-function-creators=1sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

修改密码

/data/mysql/bin/mysql -uroot -p密码初装的时候有SET PASSWORD = PASSWORD('mima123');grant all privileges on *.* to root@'%' identified by 'mima123';flush privileges;

以上所述是小编给大家介绍的Linux CentOS MySQL 5.7.18 5.7.X安装教程,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对武林网网站的支持!

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表