一、解压安装包:
# 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;
原创文章,作者:端木书台,如若转载,请注明出处:https://blog.ytso.com/267431.html