来自 电脑知识 2019-10-02 07:57 的文章
当前位置: 威尼斯国际官方网站 > 电脑知识 > 正文

威尼斯国际官方网站:linux-Centos7安装mysql5.7.19

1.下载mysql

网址:

威尼斯国际官方网站 1

 

2.选择源码包,通用版点击下载

 

威尼斯国际官方网站 2

 

一贯下载就能够了,不用登录

 

威尼斯国际官方网站 3

 

3.解压缩编制写翻译

 

先安装相关正视包

 yum install

 pcre pcre-devel zlib zlib-devel openssl openssl-devel gd gd-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel lua-devel
 autoconf libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel libidn libidn-devel libtool libtool-libs libevent-devel libevent openldap openldap-devel nss_ldap openldap-clients openldap-servers libtool-ltdl libtool-ltdl-devel bison libgcrypt php-mcrypt libmcrypt libmcrypt-devel cmake gcc gcc-c++ ncurses-devel perl-Data-Dumper libicu-devel libquadmath-devel python-devel bzip2-devel

自个儿也不做区分了;这个是搭建lnpm遭逢急需安装的有关信赖包,就全安装完了。

[root@localhost]#tar -zxvf  mysql-5.7.19.tar.gz

[root@localhost]#cd mysql-5.7.19.tar.gz

创制数量目录 

[root@localhost]#mkdir -p /data/mysql    

先用cmake编写翻译,未有那么些命令须要先yum安装

[root@localhost mysql-5.7.19]# yum install cmake

安装好cmake完成!

[root@localhost]#cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/     #本条是编写翻译安装之后的mysql目录所在地,可自动转移

-DMYSQL_DATADIR=/data/mysql/               #以此针对数据目录

-DMYSQL_UNIX_ADDR=/tmp/mysql.sock

-DSYSCONFDIR=/usr/local/mysql/conf/

-DWITH_MYISAM_STORAGE_ENGINE=1

-DWITH_INNOBASE_STORAGE_ENGINE=1

-DWITH_BLACKHOLE_STORAGE_ENGINE=1

-DWITH_ARCHIVE_STORAGE_ENGINE=1

-DWITH_MEMORY_STORAGE_ENGINE=1

-DWITH_READLINE=1

-DMYSQL_TCP_PORT=3306

-DENABLED_LOCAL_INFILE=1

-DDEFAULT_CHARSET=utf8

-DDEFAULT_COLLATION=utf8_general_ci

-DMYSQL_USER=mysql

-DWITH_SSL=system

-DWITH_ZLIB=system -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost    #从MySQL 5.7.5最初Boost库是需求安装的

 

 可直接复制下方编写翻译语句:

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ -DMYSQL_DATADIR=/data/mysql/ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DSYSCONFDIR=/usr/local/mysql/conf/ -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_USER=mysql -DWITH_SSL=system -DWITH_ZLIB=system -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost

 

如下图:

威尼斯国际官方网站 4

 

编写翻译之后make && make install  长久的等待....之后就安装实现了

 

设置到位之后路线/usr/local/ 上边会有四个目录 mysql,那个目录就是笔者编写翻译安装设置的不二法门-DCMAKE_INSTALL_PREFIX=/usr/local/mysql/

平时为了安全起见,大家都会创立三个mysql顾客和mysql组,实行以下命令

#添加用户组

groupadd mysql

#添加用户mysql 到用户组mysql

useradd -g mysql mysql

 

给予mysql权限

chown -R mysql:mysql mysql

 

4.接下来配置运营向,设置开机运营

  1. cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
  2. chmod +x /etc/init.d/mysqld
  3. chkconfig --add mysqld
  4. chkconfig mysqld on 

 

 

配置/etc/my.cnf,若无my.cnf可机关新建增加 ,  仅供参谋

[client]
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8mb4
[mysqld]
port = 3306
socket = /tmp/mysql.sock
basedir = /usr/local/mysql
datadir = /data/mysql
pid-file = /data/mysql/mysql.pid
user = mysql
bind-address = 0.0.0.0
server-id = 1
init-connect = 'SET NAMES utf8mb4'
character-set-server = utf8mb4
#skip-name-resolve
#skip-networking
back_log = 300
max_connections = 1000
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 128
max_allowed_packet = 4M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 16M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 4M
thread_cache_size = 8
query_cache_type = 1
query_cache_size = 8M
query_cache_limit = 2M
ft_min_word_len = 4
log_bin = mysql-bin
binlog_format = mixed
expire_logs_days = 30
log_error = /data/mysql/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /data/mysql/mysql-slow.log
performance_schema = 0
explicit_defaults_for_timestamp
#lower_case_table_names = 1
skip-external-locking
default_storage_engine = InnoDB
#default-storage-engine = MyISAM
innodb_file_per_table = 1
innodb_open_files = 500
innodb_buffer_pool_size = 64M
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
interactive_timeout = 28800
wait_timeout = 28800
[mysqldump]
quick
max_allowed_packet = 16M
[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M

 

接下去就进行起首化数据库语句:

注意 mysql_install_db 已经不复推荐应用了,提议改成 mysqld –initialize 完毕实例伊始化。

/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql

 

那步相当的重大,若无伊始化直接开发银行数据库会报错

ERROR! The server quit without updating PID file (/data/mysql/mysql.pid).

设若初阶化败北只怕报以下错误,就要求先清空你的/data/mysql目录了,因为mysql目录下边有数据所以初叶化试行中止。

2017-08-29T13:39:47.241469Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2017-08-29T13:39:47.241536Z 0 [ERROR] Aborting

清空之后再另行初阶化

/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql

 

 

 

接下去能够运转mysql了

service mysqld start

登陆测量试验

/usr/local/mysql/bin/mysql -uroot -p

因为初叶化--initialize-insecure 是暗中认可未有密码的之所以密码不用输入间接规定就行了;

 

假诺登入报错

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

检查一下你运维数据库成功没  可实行  ps -ef | grep mysql  看看进程是或不是开发银行状态

 

空密码不安全所以大家还要设置密码,下面发号施令中的"root"正是安装密码区域,我的密码设置为root,可活动修改

[root@localhost local]# /usr/local/mysql/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by "root" with grant option;"
[root@localhost local]# /usr/local/mysql/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by "root" with grant option;"

 

接下去再登入测量检验叁回密码修改成功并未有就产生啦!

 

 

本文由威尼斯国际官方网站发布于电脑知识,转载请注明出处:威尼斯国际官方网站:linux-Centos7安装mysql5.7.19

关键词: