centos7.9 安装配置mysql5.6

2022/6/15 2:20:16

本文主要是介绍centos7.9 安装配置mysql5.6,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

一、解压安装包:

# tar xf  MySQL-5.6.23-1.el6.x86_64.rpm-bundle.tar

解出来的文件:

1、MySQL-embedded-5.6.23-1.el6.x86_64.rpm

2、MySQL-devel-5.6.23-1.el6.x86_64.rpm 

3、MySQL-shared-5.6.23-1.el6.x86_64.rpm

4、MySQL-shared-compat-5.6.23-1.el6.x86_64.rpm

5、MySQL-test-5.6.23-1.el6.x86_64.rpm

6、MySQL-client-5.6.23-1.el6.x86_64.rpm

7、MySQL-server-5.6.23-1.el6.x86_64.rpm

二、检查是否安装过mysql:

# rpm -qa |grep mysql

卸载原来的安装包

三、安装mysql包:

# rpm -ivh MySQL-embedded-5.6.23-1.el6.x86_64.rpm --nodeps --force

# rpm -ivh MySQL-devel-5.6.23-1.el6.x86_64.rpm  --nodeps --force

# rpm -ivh MySQL-shared-5.6.23-1.el6.x86_64.rpm --nodeps --force

# rpm -ivh MySQL-shared-compat-5.6.23-1.el6.x86_64.rpm --nodeps --force

# rpm -ivh MySQL-client-5.6.23-1.el6.x86_64.rpm --nodeps --force

# rpm -ivh MySQL-server-5.6.23-1.el6.x86_64.rpm --nodeps --force

如果出现

FATAL ERROR: please install the following Perl modules before executing /usr/bin/mysql_install_db:
Data::Dumper

原因:
  缺少依赖包autoconf
解决办法:
  通过yum安装autoconf
# yum -y install autoconf

然后再执行安装:

# rpm -ivh MySQL-server-5.6.23-1.el6.x86_64.rpm --nodeps --force

默认情况下,mysql的dat目录为:/var/lib/mysql  配置文件位置为:/etc/my.cnf,默认的dat目录不要删除,可在配置文件里修改dat目录。

四、编辑my.cnf 配置文件内容如下:

[mysqld]

#根据情况修改
datadir=/web/mysqldat/mysql

#默认勿改
socket=/var/lib/mysql/mysql.sock

symbolic-links=0

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

!includedir /etc/my.cnf.d

character-set-server=utf8
default-storage-engine=INNODB
port=3306
group_concat_max_len=50000000
server_id = 1
log-error="UF10162179.err"
slow_query_log = 1
slow_query_log_file="UF10162179-slow.log"
long_query_time = 1
log-queries-not-using-indexes
max_connections = 1024
back_log = 128
wait_timeout = 60
interactive_timeout = 7200
key_buffer_size = 512M
query_cache_size = 512M
query_cache_type = 1
query_cache_limit = 50M
max_connect_errors = 20
sort_buffer_size = 2M
max_allowed_packet = 32M
join_buffer_size = 2M
thread_cache_size = 200
innodb_buffer_pool_size = 2048M
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 128M
innodb_log_file_size = 128M
innodb_log_files_in_group = 3
binlog_cache_size = 2M
max_binlog_cache_size = 8M
max_binlog_size = 512M
expire_logs_days = 7
read_buffer_size = 1M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

五、初始化数据库

# cd /bin

# ./mysql_install_db --user=mysql

如果出现错误:

Installing MySQL system tables.../usr/sbin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

缺少依赖包,执行:

# yum install -y libaio

安装完依赖包再次执行:

# ./mysql_install_db --user=mysql

六、启动mysql

# service mysql start

 

登录mysql

 # mysql -uroot -p

如果提示需要密码,可以查看初始密码:

# cat /root/.mysql_secret

登录后修改密码:

mysql> SET PASSWORD = PASSWORD('111111');

mysql> flush privileges;

修改能远程登录:

mysql> use mysql;

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '111111' WITH GRANT OPTION;



这篇关于centos7.9 安装配置mysql5.6的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程